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

countdown help

Started by PawniX, 14 December 2013 - 09:18 AM
PawniX #1
Posted 14 December 2013 - 10:18 AM
so basicly i have no clue why its not working it says countdown:36: attempt to call number what am i doing wrong ???


d = 1 --days
h = 1 --hours
m = 23 --minutes
s = 45 --seconds

function check()

if s <= 0 then
  m = m-1
  s = 60
end

if m < 0 then
  h = h-1
  m = 60
end

if h < 0 then
  d = d-1
  h = 24
end

if d == 0 and h == 0 and m ==0 and s == 0 then
  term.clear()
  print("...World...")
  print("...RESET...")
end
end

while true do
term.clear()
term.setCursorPos(1,1)
print("The World ") --replace world name
print("Resets in..")
print(d.."D "..h.."H "..m.."M "..s"S ")
sleep(1)
s = s-1
check()
end
ElvishJerricco #2
Posted 14 December 2013 - 12:35 PM
So it's a problem with you're sleep call. My guess is it's a problem with you're convention of defining globals. All your variables and functions should be declared as local. Otherwise when some program you used earlier defines a variable called "sleep" that's defined as a number, the next program that gets run (this one) finds that sleep is set to a number instead of a function.
TheOddByte #3
Posted 14 December 2013 - 07:38 PM
@ElvisJerrico
Your*

@PawniX
Error

    print(d.."D "..h.."H "..m.."M "..s"S ") -- Right next to the s you forgot '..'