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

i always get error on this one

Started by peppy, 26 February 2017 - 12:12 PM
peppy #1
Posted 26 February 2017 - 01:12 PM
so i always get this: bios:14:[ string "autohouse"]:3: '<name>' expeced

P = read()
B = read()

function ("rogi")
turtle.select(1)
turtle.place()
turtle.up()
turtle.place()
turtle.up()
turtle.place()
turtle.down()
turtle.down()
turtle.down())
end

function ("normalna sciana")
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
turtle.select(2)
turtle.place()
turtle.up()
turtle.select(3)
turtle.place()
turtle.up()
turtle.place()
turtle.down()
turtle.down())
end

function ("obrot")
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
turtle.forward()
turtle.turnLeft())
end

rogi
B = B-2
for i=1,B do
normalna sciana
Dave-ee Jones #2
Posted 26 February 2017 - 10:45 PM
Try this:


function rogi() -- rogi() is the name of the function
  -- Your Rogi function code here
end
-- ...
rogi() -- Calls the function you created earlier

You need the brackets '()' to show that it is a function and not a string/other type. Also, you don't need "rogi" as it defines it as a string and not a function. That would break it :P/>

Do the same for your other functions as well.


function obrot()
  -- Your code
end
function normlna_sciana()
-- Your code
end

Or whatever you want to name them. Remember that you cannot have spaces in the names of functions. It doesn't like it :)/>

Also, when you initialize B do it like this:


local B = read()
B = tonumber(B)/>

Ignore the />'s, they are automatically put there. Don't put them in your code.

When you put a number into read() it still keeps it as a string, like so:


"0" -- Example

But you want it to be:


0 -- Example

Otherwise it won't see it as a number but a string.

Another thing, with the for loop, it needs to be set out like this:


for i=1,B do -- Starts at 1, goes until it hits the value of B e.g. 6
  normalna_sciana()
end -- Remember to end it as well
Edited on 26 February 2017 - 09:46 PM
Bomb Bloke #3
Posted 28 February 2017 - 08:52 AM
For more on correctly defining functions, try this tutorial.

Ignore the />'s, they are automatically put there.

Try disabling emoticons within the full post editor.
Edited on 28 February 2017 - 07:53 AM