Jump to content




[Lua][Error]


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

#1 IceCrasher

  • Members
  • 40 posts

Posted 23 September 2012 - 08:14 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 computer gives my an error message in line 30, it means print should be a variable :P/>

please help me:
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")


#2 Goof

  • Members
  • 751 posts

Posted 23 September 2012 - 08:22 PM

can u please paste exactly what the error says?

#3 IceCrasher

  • Members
  • 40 posts

Posted 23 September 2012 - 08:24 PM

sorry:
bios:206: [string "calculate"]:30: '=' expected

#4 Grim Reaper

  • Members
  • 503 posts
  • LocationSeattle, WA

Posted 23 September 2012 - 08:30 PM

On line 32 of your program:
while stop=0 do
You use something called the 'assignment' operator which is: '='. That statement basically says while (set stop = 0) do, which is an invalid condition.

You probably meant to use the equals comparison operator '=='.
Try this:
while stop==0 do

Here is the revised version of your program:
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
-- Replaced assignment with comparison.
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")


#5 Goof

  • Members
  • 751 posts

Posted 23 September 2012 - 08:30 PM

I would try to edit whole your code and writing the same program, just error free. As soon as i can.

#6 IceCrasher

  • Members
  • 40 posts

Posted 23 September 2012 - 08:37 PM

@Grim Reaper
thanks, you found a fail in my programm which I didn't know about...but the error message is still there :P/>


@Mikk809h
do you mean because it is a mess ore the fail message coud go away?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users