0 Members and 2 Guests are viewing this topic.
toto = { x=1, y=2, f1=function() return true end, f2=function() return false end, tab={ ..... }}
toto = class()function toto:init() self.x, self.y = 1, 2 self.f1 = function() return true end self.f2 = function() return false end self.tab = {...}end
function creategamedata() screen = "loading" local t1, t2 for t1 = 1, gamelen, 1 do for t2 = 1, t1, 1 do gamedata[t1][t2] = math.random(1,4) end end game()end
gamedata = {}
gamedata[t1][t2] = math.random(1,4)
Simple question: Why doesn't this work?
function creategamedata() screen = "loading" local rand = math.random; for t1 = 1, gamelen do local v = {}; gamedata[t1] = v; for t2 = 1, t1 do v[t2] = rand(1,4) end end game()end
-- since I don't know if you can pass the on.timer() function endless arguments, we'll store them in a locallocal timerFunction;function on.timer() timer.stop(); assert(timerFunction)();endlocal function wait(s, f) timerFunction = f; timer.start(s);endwait(1, function() -- whatever you want to do in 1 secondend)
Seconds, Mode = 0, "Not Timing" --[[Sets default values to Seconds and Mode]]function on.enterKey() --[[This is called when ever the enter key is pressed]] if Mode == "Not Timing" then --[[If the mode is "Not Timing" when enter is pushed this restets the Seconds counter, switches the mode to "Timing" and starts the timer (counting at 0.1 seconds)]] Seconds = 0 Mode = "Timing" timer.start(0.1) else --[[If the mode wasn't "Not Timing" switch it to "Not Timing" and stop calling on.timer]] Mode = "Not Timing" timer.stop() endendfunction on.paint(gc) --[[This is called every time the calculator needs to refresh the screen]] gc:drawString(tostring(Seconds), 0, 0, "top") --[[This displays what the value of the Seconds Counter is]]endfunction on.timer() --[[When Mode is "Timing" this will be called every 0.1 seconds]] Seconds = Seconds + 0.1 --[[Increases the number of seconds counted]] platform.window:invalidate() --[[Forces the screen to refresh and call on.paint so the number of seconds gets updated on the screen]]end
I am a proud cynic.