1 posts
Posted 17 December 2012 - 10:45 AM
Hello everybody!
First of all, sorry for my bad English.
I am currently working on a program that builds a wall for my house. But I don't want to refill it every second so I need a code that automatically goes to the next slot when the first slot is empty. I tried it but with no success. Can someone help me?
Thanks :)/>
7508 posts
Location
Australia
Posted 17 December 2012 - 10:47 AM
try using an if statement with turtle.getSlotCount() which returns how many items are in the slot. then just use turtle.select() to change the slot.
2088 posts
Location
South Africa
Posted 17 December 2012 - 10:52 AM
try using an if statement with turtle.getSlotCount() which returns how many items are in the slot. then just use turtle.select() to change the slot.
it's
turtle.getItemCount(slotNum)
;)/>
This shouldn't be that difficult. Have a variable that stores the current slot it uses and before each place have an if statement like this:
itemCount = turtle.getItemCount(slotNum)
if itemCount == 0 then
slotNum = slotNum + 1
turtle.select(slotNum)
end
-- Then the placing the blocks code here
This should work, give it a try and give us the feedback :)/>
7508 posts
Location
Australia
Posted 17 December 2012 - 11:01 AM
try using an if statement with turtle.getSlotCount() which returns how many items are in the slot. then just use turtle.select() to change the slot.
it's
turtle.getItemCount(slotNum)
;)/>
sorry for the quick typing, typo :P/>
536 posts
Posted 17 December 2012 - 11:04 AM
you could make it loop;
local function getSlot(min, start)
if min == nil then min = 0 end
if start == nil then start = 1 end
for i=start,16 do
if turtle.getSlotCount(i) >= min then return i end
end
return -1
end
Usage would be:
local slot = getSlot()
this would get the first of any slot to have above 0 items, or -1 if none was found (using defaults)
or:
local slot = getSlot(minimumItemCount, startingSlotNumber)
2088 posts
Location
South Africa
Posted 17 December 2012 - 11:15 AM
try using an if statement with turtle.getSlotCount() which returns how many items are in the slot. then just use turtle.select() to change the slot.
it's
turtle.getItemCount(slotNum)
;)/>
sorry for the quick typing, typo :P/>
A
typo is a typing error/mistake. You just didn't know what it was :P/> So I wouldn't call it a typo ;)/>
Sorry if this sounds cocky xD
7508 posts
Location
Australia
Posted 17 December 2012 - 11:18 AM
try using an if statement with turtle.getSlotCount() which returns how many items are in the slot. then just use turtle.select() to change the slot.
it's
turtle.getItemCount(slotNum)
;)/>
sorry for the quick typing, typo :P/>
A
typo is a typing error/mistake. You just didn't know what it was :P/> So I wouldn't call it a typo ;)/>
Sorry if this sounds cocky xD
I use it all the time. i think i know how to use it.
And in normal size. Sorry if this sounds cocky xD … but I dont care :P/>
2088 posts
Location
South Africa
Posted 17 December 2012 - 11:24 AM
Well read the link to typo… Am I not right? uhuh
7508 posts
Location
Australia
Posted 17 December 2012 - 11:29 AM
lets just agree to disagree or call it a lapse in judgement or something and move on, and stop clogging up this with nothing