Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
22 May, 2013, 15:29:44 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1]   Go Down
  Print  
Author Topic: Platform-specific Problem -  (Read 798 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
NecroBumpist
LV4 Regular (Next: 200)
****
Offline Offline

Gender: Male
Last Login: 04 November, 2012, 07:02:18
Date Registered: 18 August, 2011, 05:44:50
Location: In my IDE, programming shit
Posts: 129


Total Post Ratings: +9

View Profile
« on: 14 October, 2011, 03:37:36 »
0

Functions based inside gc (ie gc:drawRect(), gc:drawString(), etc) only work if they are called indirectly from within on.paint().
And as said earlier, you have to refresh the screen yourself, so either set a timer, or do it manually.

Examples:

1
2
3
4
5
6
7
8
9
10
local ggc; -- global graphics context

function on.paint(gc)
gcc = gc;
end

function on.enterKey()
gcc:drawString("Herp", 0, 0, "top");
end

That will not work. This will.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
local extra;

function on.paint(gc)
-- do normal painting

if extra then
extra(gc);
extra = nil;
end
end

function on.enterKey()
extra = function(gc) gc:drawString("Herp", 0, 0, "top"); end

platform.window:invalidate();
end

You're problem for 2 is most likely either you're passing the wrong arguments, or your accessing part of the table that doesn't exist (out of bounds), causing it to return a nil value, which is later compared to something else, like a number. Lua doesn't allow this.

Either read through the calling function, or add some conditional code to make sure the inputs are safe.

The error's line number would be appreciated as well.
« Last Edit: 14 October, 2011, 03:39:07 by NecroBumpist » Logged

Developing Lua scripts for the NSpire ?
Check out the Necrotorium
Need a few routines to run faster ? Checkout the MODS Lua Assembly Toolkit.
Need to save space for your scripts ? Checkout LuaSrcDiet
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.254 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.