Posted 28 February 2013 - 10:08 PM
Hello everyone, I have been playing with computercraft, very new to everything, and learning lua has been fun so far, and not too difficult as I already have a bit of programming experience myself.
I made one of my first scripts, a simple thing to ask me for a number, then build a floor out of whatever material I give it. After realizing i needed it to get rid of stuff in its inventory it picks up to function correctly i attempted to add a section that switches to the last free space in the inventory, drops the item, then switches back to the slot it was on.
I am sure it is some kind of logical error, the compiler says there is an error on line 18, and that is it missing a number, which made no sense to me.
I have not searched for any pre-made floor making programs becaue I want to start making things myself. I was using a few premade scripts but i couldnt understand them all that well becaue they were not commented at all and were way to long to figure out, along with me not knowing lua' syntax. I searched for an answer but dont know exactly how to phrase the problem, or dont know the problem well enough to phrase it at all? Anyway heres my code, its rather short so i hope its not too hard to figure out where i went wrong.
I made one of my first scripts, a simple thing to ask me for a number, then build a floor out of whatever material I give it. After realizing i needed it to get rid of stuff in its inventory it picks up to function correctly i attempted to add a section that switches to the last free space in the inventory, drops the item, then switches back to the slot it was on.
I am sure it is some kind of logical error, the compiler says there is an error on line 18, and that is it missing a number, which made no sense to me.
I have not searched for any pre-made floor making programs becaue I want to start making things myself. I was using a few premade scripts but i couldnt understand them all that well becaue they were not commented at all and were way to long to figure out, along with me not knowing lua' syntax. I searched for an answer but dont know exactly how to phrase the problem, or dont know the problem well enough to phrase it at all? Anyway heres my code, its rather short so i hope its not too hard to figure out where i went wrong.
term.clear()
term.setCursorPos(1,1)
local length
print("Please put block to build with in slot 1")
print("type in number of blocks to build out to: ")
--variable inputs
local length = read()
local count
local slot = 1
local lastSlot
print("Please Type in the last empty slot")
print("slot 1 is top left, slot 16 is bottem right")
lastSlot = read()
count = turtle.getItemCount(slot)
--floor laying loop
for i=1, length do
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.select(lastSlot)
turtle.drop(1)
turtle.select(slot)
if count<1 then
turtle.select(slot+1)
slot = slot+1
end
end
term.clear()