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

I really need help with this code.

Started by xbmdavross, 04 June 2013 - 04:28 PM
xbmdavross #1
Posted 04 June 2013 - 06:28 PM
i spent a while programing it and keep getting the error "wall2:15: 'for' limit must be a number"


print("This script is to be used Left to Right")

print("please input the amount of pillars")
local amount = read()
amount = z

print("please input the height")
local input = read()
input = y 

print("please input the distance between pillars")
local distance = read()
distance = x

for i = 1,z do

for i = 1,y do
turtle.place()
sleep(.5)
turtle.up()
sleep(.5)
end

turtle.turnRight()
for i = 1,x do
turtle.forward()
sleep(.5)
end
turtle.turnLeft()

end

Thanks for any help
Lyqyd #2
Posted 04 June 2013 - 07:50 PM
Split into new topic.

You set the value of `amount` from a read, then right away overwrite the value with nil, by assigning `amount` to whatever was in `x`. You then try to use `x` in your for loop even though it's still nil.

You have your assignments reversed when dealing with x, y and z. They should be: `local x = amount`, or even better, just get the value directly from the read call. Might as well convert it to a number while you're at it:

local x = tonumber(read())