|
|
|
@ -26,6 +26,62 @@ local slot_map = {
|
|
|
|
|
9,10,11
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-- local function read_chest_contents()
|
|
|
|
|
-- local size = inventory.getInventorySize(sides.forward)
|
|
|
|
|
-- for slot = 1, size do
|
|
|
|
|
-- local stack = inventory.getStackInSlot(sides.forward, slot)
|
|
|
|
|
-- if stack then
|
|
|
|
|
-- if stack.name == item then
|
|
|
|
|
-- inventory.suckFromSlot(sides.forward, slot, 1)
|
|
|
|
|
-- return true
|
|
|
|
|
-- end
|
|
|
|
|
-- end
|
|
|
|
|
-- end
|
|
|
|
|
-- end
|
|
|
|
|
|
|
|
|
|
-- store the item in the selected slot into the facing inventory
|
|
|
|
|
local function store_item()
|
|
|
|
|
-- check if that item is present in the inventory
|
|
|
|
|
local item = inventory.getStackInInternalSlot()
|
|
|
|
|
|
|
|
|
|
local size = inventory.getInventorySize(sides.forward)
|
|
|
|
|
local empty_slot = -1
|
|
|
|
|
for slot = 1, size do
|
|
|
|
|
local stack = inventory.getStackInSlot(sides.forward, slot)
|
|
|
|
|
if stack then
|
|
|
|
|
if stack.name == item.name then
|
|
|
|
|
inventory.dropIntoSlot(sides.forward, slot)
|
|
|
|
|
-- check if all items have been stored
|
|
|
|
|
local remaining = inventory.getStackInInternalSlot()
|
|
|
|
|
if not remaining then
|
|
|
|
|
print('Stored successfully')
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if empty_slot == -1 then
|
|
|
|
|
empty_slot = slot
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- item not present in inventory
|
|
|
|
|
if empty_slot ~= -1 then
|
|
|
|
|
-- store in first empty slot
|
|
|
|
|
local result, error = inventory.dropIntoSlot(sides.forward, empty_slot)
|
|
|
|
|
if not result then
|
|
|
|
|
print('Cannot store item: ' .. error .. "\n")
|
|
|
|
|
return false
|
|
|
|
|
else
|
|
|
|
|
print('Stored successfully')
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
print('Cannot store item - Inventory full')
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Search the facing chest for "item" and take "count" items and place them in "slot"
|
|
|
|
|
-- Returns number of items fetched
|
|
|
|
|
local function fetch_item(item, output_slot)
|
|
|
|
@ -75,4 +131,5 @@ end
|
|
|
|
|
-- return
|
|
|
|
|
-- end
|
|
|
|
|
|
|
|
|
|
craft_recipe(iron_pickaxe_recipe)
|
|
|
|
|
-- craft_recipe(iron_pickaxe_recipe)
|
|
|
|
|
store_item()
|
|
|
|
|