10 posts
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/tEJyyuvkSorry for my bad English ^^
Greetings from Germany!
1688 posts
Location
'MURICA
Posted 12 January 2013 - 09:16 AM
That == on line 16 should only be one equal sign.
Also, greetings from 'Murica!
2088 posts
Location
South Africa
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
1548 posts
Location
That dark shadow under your bed...
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/>
10 posts
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
1548 posts
Location
That dark shadow under your bed...
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 confusedhere is a corrected version of the codeEDIT: 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
10 posts
Posted 13 January 2013 - 03:04 AM
thanks man!