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

Bios 338 Error pls help

Started by Boomenx, 08 January 2013 - 09:00 AM
Boomenx #1
Posted 08 January 2013 - 10:00 AM
Can anyone help me with this error i get
bios:338: {string "Digging"}:2: '=' expected
Pastebin : http://pastebin.com/RFrujNK8
I don't get where do i have to put an = since in that line i have got only an if statement.
I'm new to Lua and turtles so please dont be harsh to me
Also i have some experience with other programming languages such as C and Pascal.


Edit1: After changing If to if now it gets me the same error but for line 29
bios:338: {string "Digging"}:29: '=' expected
Edit2: Solved Thanks everyone
Luanub #2
Posted 08 January 2013 - 10:02 AM
line 2 you have If, Lua is case sensitive it needs to be if

You actually have that in several places that needs to be fixed.
Boomenx #3
Posted 08 January 2013 - 10:05 AM
didnt know that thanks
Now it Gives me an error about line 29
remiX #4
Posted 08 January 2013 - 10:20 AM
If you're wanting to use another program within your program you need to use shell.run()

try this:
shell.run("go forward " .. xpos-1 .. " down " .. zpos-1 .. " left " .. ypos-1)
Boomenx #5
Posted 08 January 2013 - 10:38 AM
Thanks everyone i got it working
no errors for me now)
Luanub #6
Posted 08 January 2013 - 10:38 AM
You need to separate the args with comma's for shell.run()

shell.run("go forward ",xpos-1," down ",zpos-1," left ",ypos-1)
Heracles421 #7
Posted 08 January 2013 - 10:39 AM

function Prov()
  if turtle.detect() then
     for i = 1, 8 do
      turtle.dig()
     end
  end
end
function Sbros()
  for g = 1,16 do
   turtle.select(g)
   turtle.drop()
  end 
k=read()
l=read()
ypos=0
xpos=0
zpos=0
for z = 1,5 do
 zpos=z+1
 for y = 1,l do
  ypos=y+1
  for x = 1,k do
    xpos = x+1
    turtle.dig()
    Prov()
    turtle.forward()
    if turtle.getItemCount(16) ~= 0 then
       if math.fmod(y,2)==0 then
          turtle.forward()
          xpos = xpos-1 
          turtle.down()
          zpos = zpos-1 
          turtle.turnLeft()
          ypos = ypos-1
          Sbros()
       else
          turtle.back()
          xpos = xpos-1 
          turtle.down()
          zpos = zpos-1
          turtle.turnLeft() 
          ypos = ypos-1
          Sbros()
       end
    end
   end
  turtle.turnLeft()
  turtle.dig()
  Prov()
  turtle.forward()
  for x = 1,k-1 do
   xpos=x-1
   turtle.dig()
   Prov()
   turtle.forward()
  end
  turtle.turnRight()
  turtle.forward()
  turtle.turnRight() 
 end
 if z == 5 then
    turtle.turnLeft()
    ypos = ypos-1
    turtle.down()
    zpos = zpos-1
    Sbros()
 end
turtle.turnRight()
for i = 1,l do
 turtle.forward()
end
turtle.up()
turtle.turnLeft()
end
I don't know what are you trying to do, but here's the fixed code.
First of all, the functions go forward/back/left don't exist, they're not even written as functions.
Second, if you want to change a variable with math operations you should always write:

var1 = 1 -- any number
var1 = var1 + 1 -- any number
If you want to assign x value to the variable, this is not needed, but if you want to do maths with the variable itself you need it.
Third, lua is case sensitive, "If" is not the same as "if". That applies to everything within lua, be it functions, variables, conditional statements, loops, etc

And for the sake of order, write your program with format, not just in a single column. Ex:

for i = 1,4 do
    do something
end
And not like this:

for i = 1,4 do
do something
end

Makes it easier to debug

The things above me also work, but I don't like calling external programs unless I really need it
Boomenx #8
Posted 08 January 2013 - 11:16 AM
Everyone thnx for your replies)
Moderators if you can pls close this thread since it is solved thnx in advance