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

Expected number error and slot changing problem

Started by MasterGAM, 18 May 2014 - 11:14 PM
MasterGAM #1
Posted 19 May 2014 - 01:14 AM
ok so i have this program working pretty well but when i run it it only build one layer of 25 blocks,= then it turns stops and givers me an error that says turtle:22: Expected number. and my Function Check() wasnt working when i had it working before, please help me with these two problems.

here is the program

function place()
turtle.back()
turtle.placeDown()
end

function turn()
turtle.back()
turtle.turnLeft()
end

function check() –this makes it change its slot if it has less than 20 in its current slot
turtle.select(x)
turtle.getItemCount(x)

while turtle.getItemCout(x) < 20 do
x = (x)=1
turtle.select(x)
end
end

–Main Program
local x
x = 1
local levels
levels = 0
term.write("How many levels should be created:")
levels = read()
for i =1, levels do

for i =1, 25 do
place()
end
turn()
check()
for i =1, 25 do
place()
end
turn()
check()
for i =1, 25 do
place()
end
turn()
check()
for i =1, 25 do
place()
end
turn()
turtle.up()
end
Minion #2
Posted 19 May 2014 - 01:48 AM
levels = read()

try

levels = tonumber(read()) – converts the information that's entered into a number if possible
KingofGamesYami #3
Posted 19 May 2014 - 01:54 AM
use code tags

["code"]
#your code here
["/code"]

Also, I would pass and return variables to and from your functions:

function check(x)
 turtle.select(x)
 local amount = turtle.getItemCount()
 return amount
end
Edited on 18 May 2014 - 11:57 PM