Jump to content




[Lua][Error]


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

#1 IceCrasher

  • Members
  • 40 posts

Posted 23 September 2012 - 07:47 PM

Hi guys I'm playing with computercraft since two days, because I'm using the Tekkit modpack I play on the 1.3 Version of computercraft.
Anyway I tried to write a programm, that calculates how much time it uses to make, craft and place hv solar array's automaticly, but I failed :P/>
I'm getting this error message:

bios:206: [string "calculate"]:29: 'then'
expected


I could'nt find out what I did wrong, please help me, I spent two hours by trying to fix this...

Here's the pastebin-link to the code:
http://pastebin.com/bXrjJeQ4

ore here directly in the forum:
--print("How much HvSolars do you have?")
--a = read()
a=10
x=1
hv=12500
t=0
tt1=0
tt2=0
tt3=1
wert=0
  tt1=1000000/512/20/x*hv
  t=t+tt1
  x=x+1
function calculate2()
  while x<a do
    tt1=1000000/512/20/x*hv
    tt2=tt1-30
    tt3=tt2/tt1
    x=x+1
    wert=1000000/512/20*tt3/x*hv
    t=t+wert+tt1
  end
end
function chegcalculate2fortt3()
  if tt3>0 do
    calculate2
  else
    print("Ab "..x.." ist tt3 kleiner als 0")
    stop=1
end
end
stop=0
while stop=0 do
  chegcalculate2fortt3
end
print (""..t.." sec")
tinm=t/60
print (""..tinm.." min")
tinh=tinm/60
print (""..tinh.." h")
tind=tinh/24
print (""..tind.." d")

Please help me.

#2 cant_delete_account

  • Members
  • 484 posts

Posted 23 September 2012 - 07:52 PM

Here's fixed code:
print("How much HvSolars do you have?")
a = tonumber(read())
x=1
hv=12500
t=0
tt1=0
tt2=0
tt3=1
wert=0
  tt1=1000000/512/20/x*hv
  t=t+tt1
  x=x+1
function calculate2()
  while x<a do
	tt1=1000000/512/20/x*hv
	tt2=tt1-30
	tt3=tt2/tt1
	x=x+1
	wert=1000000/512/20*tt3/x*hv
	t=t+wert+tt1
  end
end
function chegcalculate2fortt3()
  if tt3>0 then
	calculate2()
  else
	print("Ab "..x.." ist tt3 kleiner als 0")
	stop=1
end
end
stop=0
while stop=0 do
  chegcalculate2fortt3()
end
print(t.." sec")
tinm=t/60
print(tinm.." min")
tinh=tinm/60
print(tinh.." h")
tind=tinh/24
print(tind.." d")


#3 IceCrasher

  • Members
  • 40 posts

Posted 23 September 2012 - 07:55 PM

thanks bro XD

sorry for that dumb fail

#4 cant_delete_account

  • Members
  • 484 posts

Posted 23 September 2012 - 07:57 PM

View PostIceCrasher, on 23 September 2012 - 07:55 PM, said:

thanks bro XD

sorry for that dumb fail
I updated the post to fix another error and remove unnecessary code.

#5 IceCrasher

  • Members
  • 40 posts

Posted 23 September 2012 - 08:05 PM

thank you, and maybe you can help my one more time, i have an errormessage in line 30 because of the print thingi... it thinks I wanna have print as a variable :P/>





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users