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

i get an error

Started by neto333, 18 May 2012 - 10:22 PM
neto333 #1
Posted 19 May 2012 - 12:22 AM
bios: 206: [string"stairs"]:1: unexpected symbol
I'm trying to put this program
repeat
A = turtle.down()
until A == false

for v=1,10 do change the 10 to how much steps you want
turtle
.up()
turtle.dig()
turtle.forward()
turtle.digUp()
end

i guess that I'm doing something wrong, i copy and paste the program in a .txt file, and then i put in computer craft….programs, turtle, and delete de extension.
Or if someone can upload the file of some stairs, no digging stairs , stairs putting blocks, thank you.
MathManiac #2
Posted 19 May 2012 - 12:38 AM
replace the repeat … until block with a while … end block. If you're stuck on how to do it, look in the spoiler.

Spoiler
A = true
while (A ~= false)
    A = turtle.down()
end
neto333 #3
Posted 19 May 2012 - 01:49 AM
im, still getting the error, i put the program like this.

A = true

while (A ~= false)

A = turtle.down()
end


for v=1,10 do

turtle.up()
turtle.dig()
turtle.forward()
turtle.digUp()
end
PixelToast #4
Posted 19 May 2012 - 02:11 AM
use

while turtle.down() do end
for v=1,10 do
turtle.up()
turtle.dig()
turtle.forward()
turtle.digUp()
end
MysticT #5
Posted 19 May 2012 - 02:12 AM
The code is fine, both of them, so the problem might be in the file. Check if there's something on the first line of the file (not the first line of code, the start of the file).
neto333 #6
Posted 19 May 2012 - 02:20 AM
i make with text wrangler and seems to be ok now, but now my problem is that the code is for dig, but i wanna make stairs, i try to change dig to place, but now is making some strange structures D;:
MysticT #7
Posted 19 May 2012 - 02:26 AM
Try with this (not tested):

local nSlot = 1 -- the number of the slot with the blocks
local nHeight = 10 -- the amount of blocks to place

while turtle.down() do end

turtle.select(nSlot)
for _= 1, nHeight do
  turtle.up()
  turtle.placeDown()
  turtle.forward()
end
neto333 #8
Posted 19 May 2012 - 02:31 AM
Is working fine, thank you, is there a way that i can say the diameter and height in the game without chang it in the program.
Lyqyd #9
Posted 19 May 2012 - 02:35 AM
Is working fine, thank you, is there a way that i can say the diameter and height in the game without chang it in the program.

Yep. At the beginning of the program,


tArgs = {...}
if tArgs < 2 then
print("Usage: progname <diameter> <height>")
return
else
diameter = tArgs[1]
height = tArgs[2]
end

That should make it require two arguments when running it (type in: "progname 12 4" or similar), then it will set two variables from those two numbers.
MysticT #10
Posted 19 May 2012 - 02:38 AM
This will let you choose the height and the slot to use (the slot is optional, defaults to 1):

local function printUsage()
  print("Usage: stairs <height> <slot>")
end

local tArgs = { ... }
if #tArgs ~= 2 then
  printUsage()
  return
end

local nHeight = tonumber(tArgs[1])
if not nHeight then
  printUsage()
  return
end
local nSlot = tonumber(tArgs[2]) or 1

while turtle.down() do end

turtle.select(nSlot)
for _= 1, nHeight do
  turtle.up()
  turtle.placeDown()
  turtle.forward()
end
For diameter you would need to change the program depending how you want the stairs to be.
neto333 #11
Posted 19 May 2012 - 02:40 AM
thank you, now I'm testing.
Edit:Is working good :P/>/>

thank you very much to all.
MathManiac #12
Posted 19 May 2012 - 04:04 AM
thank you, now I'm testing.
Edit:Is working good :P/>/>

thank you very much to all.

Happy coding!