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

[Lua][Error] Expected number

Started by River_Chief, 05 November 2012 - 08:58 AM
River_Chief #1
Posted 05 November 2012 - 09:58 AM
Working on "Elo's Turtle Army" quarry code. I'm using BSG samuels goto quarry code and have found this enderchest drop off function. I'm getting a "Expected number" error in bold below
Spoilerfunction checkInvSpace()
for i = 1,15 do – For loop, cycles 15 times
if turtle.getItemSpace(i) > 0 then – looks at each space if > than "0" items to finish a stack
turtle.select(i) – selects that slot
return true – returns true
end
end
if turtle.getItemSpace < 1 then – looks at each space if < than "1" items to finish stack
return false – returns false
end
end

if turtle.getItemSpace() < 1 then – if it's less than 1 item left to fill the stack in this slot
if not checkInvSpace() then – getting expected number error on this line
turtle.select(16) – selects the enderchest
turtle.placeUp() – places it above the turtle
for j = 1,15 do – cycles 15 times
turtle.select(j) – each cycle selects a slot
turtle.dropUp() – pushes out contents of each slot
end
turtle.select(16) – selects slot 16 (Ender chest location)
turtle.digUp() – breaks the chest above
turtle.select(1) – selects slot 1 for more quarried items
end
end

Incidentally I'm using notepad++ with the lua plug in. The code formatting including colors, spaces and indents - they're all very helpful. Pasting it in here? Lost…. I spend some time trying to avoid the wall of code for your review here - how are you guys posting properly formatted code for others to review?
Leo Verto #2
Posted 05 November 2012 - 11:19 AM
Replace
if turtle.getItemSpace < 1 then -- looks at each space if < than "1" items to finish stack
with
if turtle.getItemSpace(i) < 1 then -- looks at each space if < than "1" items to finish stack