Jump to content




[Lua][Error]


  • You cannot reply to this topic
2 replies to this topic

#1 IceCrasher

  • Members
  • 40 posts

Posted 23 September 2012 - 09:05 PM

Hi guys, I play computercraft since two days, so I'm not a really good programer, but I know you guys out there are awesome and I hope you will help my. (the name of my program is: calculate2)

After it printed "How much HVSolars do you have already?", I tiped in 5 and pressed enter, the computer gives my an error message:
calculate2:2: attempt to call nil

please help me:
print("How much HVSolars do you have already?")
a = tonuumber(read())

x     =     1
hv    = 12500
stop  = 0
power = 1000000
delay = 90
t     = 0
tt1   = 0
tt2   = 0
tt3   = 1
tt4   = 0

while stop == 0 do
   if tt3 > 0 then
      while x < a do
         tt1 = power / 512 / 20 / x * hv
         tt2 = tt1 - delay
         tt3 = tt2 / tt1
         x   = x + 1
         t   = t + tt1 + tt4
      end
   else
      print("Ab "..x.." ist tt3 =< als 0")
      stop = 1
   end
end

print(t.." sec")

tinm = t / 60
print(tinmin.." min")

tinh = tinm / 60
print(tinh.." h")

tind = tinh / 24
print(tind.." d")


#2 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 23 September 2012 - 09:07 PM

It's the 3-4 post about the same code, please just ask in the same thread instead of doing multiple ones with the same stuff.
The problem is that you wrote tonuumber instead of tonumber.

Edit: Also, I just noticed that your loop will never end. You set it to stop when tt3 is less or equal to 0, but the only change you do to it is dividing it, wich will never return 0. This will create an infinite loop that will crash the computer.

#3 IceCrasher

  • Members
  • 40 posts

Posted 23 September 2012 - 09:08 PM

thank you, ok I'll be more carefull...





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users