0 Members and 1 Guest are viewing this topic.
I am a proud cynic.
number = 0function on.paint(gc) --If number is still zero (we just started the application), start the timer (set to tick every 1 seconds) if number==0 then timer.start(1) end --Draw the number on the screen gc:drawString(tonumber(number),10, 10, "top")end--This get's now called every 1 seconds until you stop the timerfunction on.timer() --Add one to number number = number + 1 --Force the screen to be redrawn platform.window:invalidate() --If number is 10, stop the timer if number==10 then timer.stop() endend
a={1,2,3,4,5}
a[3] = 1337
{1,2,1337,4,5}
a={1,2,3}b={1,2,4}function on.paint(gc)if a==b thengc:drawString("E",0,0,"top")elsegc:drawString("I",0,0,"top")end
function compare(t1, t2) for i, p in pairs(t1) do if p~=t2[i] then return false end end return trueenda={1,2,3}b={1,2,3}if compare(a, b) then--they are equalelse--they are not equalend
mytable={1,2,3,"a","b","c"} for i, p in pairs(mytable) do print("Spot: " . i) print("Content: " . p) end
Spot: 1Content: 1Spot: 2Content: 2Spot: 3Content: 3Spot: 4Content: aSpot: 5Content: bSpot: 6Content: c