This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Nullname123's profile picture

Timer doesnt work

Started by Nullname123, 09 April 2015 - 04:54 PM
Nullname123 #1
Posted 09 April 2015 - 06:54 PM
This is my little Timer, but it doesn`t work

s = 0
m = 0


function s()
sleep(1)
s =s+1
end

function m()
if s == 60 then
m = m+1
end
end

s()
m()
write("Sec: "..s"Min: "..m)


Sorry i don`t know how to upload the pastebin

The error is:Timer: attempt to perform arithmetic __add on function and number.

Thanks for your help!
Edited on 09 April 2015 - 04:54 PM
KingofGamesYami #2
Posted 09 April 2015 - 07:02 PM
You cannot use the same name for your variables and functions. They overwrite each other.

In addition, you never reset the seconds to 0, could cause some problems.
Nullname123 #3
Posted 09 April 2015 - 07:03 PM
thanks a lot it works now