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

Problem :16: '=' expected

Started by vantheman1wald, 12 January 2013 - 08:13 AM
vantheman1wald #1
Posted 12 January 2013 - 09:13 AM
I wanted to completely rewrite my Bridge builder and everytime I wanna start it this comes : bios:338: [string "Bruecke"]:16: '=' expected
I post this because I couldn't find the error and checked it 10 times there ARE the ()s
Here's the code: http://pastebin.com/tEJyyuvk
Sorry for my bad English ^^
Greetings from Germany!
Kingdaro #2
Posted 12 January 2013 - 09:16 AM
That == on line 16 should only be one equal sign.

Also, greetings from 'Murica!
remiX #3
Posted 12 January 2013 - 09:32 AM
write("Soll links und rechts ein Zaun gebaut werden?(Ja oder Nein")
zaun = tonumber(read())
write("In welche Richtung soll die Turtle bauen?(Links oder Rechts)")
richtung = tonumber(read())

No need to tonumber those btw :)/>

Also, greetings from South Africa xD
KaoS #4
Posted 12 January 2013 - 10:07 AM
also when you are running your if statements on the user input you should convert it all to lower case to be sure. example:

if string.lower(richtung) == "rechts" then

that way they can even say rEcHtS and it will work fine

PS:
Also, greetings from South Africa xD
WOOO! go SA :D/>
vantheman1wald #5
Posted 12 January 2013 - 08:43 PM
so,nox i've got 2 other errors it has sth to do with richtung(Line 9)
when i answer the question with rechts:Bruecke:13: bad argument:string expected, got nil
when i answer the question with inks the next question comes when i answer this question : Bruecke:20: attempt to call nil
new code : http://pastebin.com/w9tFLWBv
KaoS #6
Posted 13 January 2013 - 01:50 AM
on line 11 and 14 you overwrite the richtung variable with turnRight or turnLeft, when you enter rechts you make richtung=turnRight (turnRight=nil because it is a variable. you need it to be a string) and then on line 13 it checks richtung again, this time it is nil so the string.lower function gets confused

here is a corrected version of the code

EDIT: corrected a few more minor problems


textutils.slowPrint("#######################################")
textutils.slowPrint("########Brueckenbauer aktiviert########")
textutils.slowPrint("#######################################")
write("Wie lang soll die Bruecke sein?")
laenge = tonumber(read())
write("Wie breit soll die Bruecke sein?")
breite = tonumber(read())
write("In welche Richtung soll die Turtle bauen?(Links oder Rechts)")
richtung = read()
if string.lower(richtung) == "rechts" then
richtung = "turnRight"
end
if string.lower(richtung) == "links" then
richtung = "turnLeft"
end
write("Soll links und rechts ein Zaun gebaut werden?(Ja oder Nein)")
zaun = read()
if string.lower(zaun) == "ja" then
for a = 0, laenge do
  turtle[richtung]()
  turtle.select(2)
  for x = 1, breite do
   turtle.placeDown()
   turtle.forward()
  end
  turtle.placeDown()
  turtle.up()
  turtle.select(3)
  turtle.placeDown()
  for b = 0, 2 do
   turtle[richtung]()
  end
  for c = 0, breite do
   turtle.forward()
  end
  turtle.placeDown()
  turtle[richtung]()
  turtle.forward()
  turtle.down()
end
end

if string.lower(zaun) == "nein" then
for d = 0, laenge do
turtle[richtung]()
turtle.select(2)
for y = 1, breite do
turtle.placeDown()
turtle.forward()
end
for e = 0, 2 do
turtle.richung()
end
for f = 0, breite do
turtle.forward()
end
turtle[richtung]()
end
end
if not turtle.forward() then
turtle.dig()
turtle.digUp()
turtle.attack()
end
Edited on 13 January 2013 - 01:04 AM
vantheman1wald #7
Posted 13 January 2013 - 03:04 AM
thanks man!