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.