Posted 26 January 2013 - 09:35 PM
I am trying to code a tower construction program for a Turtle, but I am having an issue with the Turtle returning "turtle:18: Expected number" (the program nor the Turtle are named "turtle").
The error seems to be somewhere after line 28, as the section for restocking the turtle works fine, could anyone shed any light on what this error actually means, I feel like I am beating my head against a brick wall.
The code with updates given by people here can be found here: http://pastebin.com/X0zMYgNr
This is the original code:
For reference, this is the sort of thing the program builds, from a simpler (working :P/>) version of the script.
Thanks in advance.
The error seems to be somewhere after line 28, as the section for restocking the turtle works fine, could anyone shed any light on what this error actually means, I feel like I am beating my head against a brick wall.
The code with updates given by people here can be found here: http://pastebin.com/X0zMYgNr
This is the original code:
shell.run("clear")
print("Note:")
print("- For now, please ensure that this turtle has sufficient fuel already registered")
print("- Please ensure that there is a suitable method of restocking this turtle via enderchest")
sleep(3)
shell.run("clear")
print("How many blocks high do you wish the tower to be?")
sleep(1)
local height = read()
shell.run("clear")
print("Construction in progress")
function RPlace() -- Selecting random block, and placing it down in the world
local q = 0
repeat
local r = math.random(1, 12)
if q == 15 then -- Checking if the turtle needs to be restocked
local q = 0
print("Restocking")
turtle.select(16) -- Enderchest
turtle.placeDown()
local s = 0
repeat
turtle.suckDown()
s = s + 1
until s == 12
turtle.digDown()
end
q = q + 1
until turtle.getItemCount(r) > 1
turtle.select(r)
turtle.placeDown()
end
local k = 0 -- Level counter
repeat
local j = 0 -- Circle Start
repeat
local i = 0
repeat
RPlace() --SB1-5
turtle.forward()
i = i + 1
until i == tonumber(5)
turtle.turnRight()
turtle.forward()
RPlace() -- CB1
turtle.turnLeft()
turtle.forward()
RPlace() -- CB2
turtle.forward()
turtle.turnRight()
turtle.forward()
RPlace() -- CB3
turtle.turnLeft()
turtle.forward()
turtle.turnRight()
turtle.forward()
RPlace() -- CB4
turtle.forward()
RPlace() -- CB5
turtle.turnLeft()
turtle.forward()
turtle.turnRight()
turtle.forward()
j = j + 1
until j == 4
turtle.up()
k = k + 1
until k == height
print("Construction complete!")
For reference, this is the sort of thing the program builds, from a simpler (working :P/>) version of the script.
Thanks in advance.