Posted 27 December 2012 - 12:42 AM
Ok ive been messing around with making a new function that has named timers but it keeps throwing an error :l
heres the code:
I really dont know whats wrong
heres the code:
Spoiler
fps = 20
function startTimer(name,time)
table.insert(timers,{name,time})
end
function updateTimers()
if #timers > 0 then
for i = 1,#timers do
timers[i].time = timers[i].time-(1/fps)
end
end
end
function checkTimerOutput()
timersDone = {}
for i = 1,#timers do
if timers[i].time <= 0 then --error here
table.insert(timersDone,timers[i].name)
end
end
if #timersDone > 0 then
os.queueEvent("Timer",timersDone)
end
end
function main()
term.clear()
secretfunctionname:P.print(1,2,"hello","hi!","boom")
startTimer("ben",3)
event, name = os.pullEvent()
term.clear()
secretfunctionname:P.print(1,1,event,name)
loopBreaker = true
end
k = 0
function update()
k = k+1
checkTimerOutput()
updateTimers()
sleep(1/sky.clock.fps)
secretfunctionname:P.write(1,1,k)
end
while loopBreaker ~= true do
parallel.waitForAny(update,main)
end
I really dont know whats wrong