spaces->tab, equipper improvements, supertreefarm rewrite, follow improvements, sensor cleanup, milo multiple items allowed in recipes, remote canvas access

This commit is contained in:
kepler155c@gmail.com
2019-06-18 15:23:20 -04:00
parent 3b9b509429
commit 045b32884f
162 changed files with 20448 additions and 20286 deletions

View File

@@ -8,14 +8,14 @@ reboot
Use multiple brewing stands at once to brew potions.
SETUP:
Place an introspection module into the turtles inventory.
Connect turtle to milo network with a wired modem.
Connect turtle to a second wired modem that is connected to brewing stands ONLY.
Add as many brewing stands as needed.
Place an introspection module into the turtles inventory.
Connect turtle to milo network with a wired modem.
Connect turtle to a second wired modem that is connected to brewing stands ONLY.
Add as many brewing stands as needed.
CONFIGURATION:
Set turtle as a "Generic Inventory"
export blaze powder to slot 5
import from slots 7-9
Set turtle as a "Generic Inventory"
export blaze powder to slot 5
import from slots 7-9
Use this turtle for machine crafting.
--]]
@@ -31,23 +31,23 @@ local turtle = _G.turtle
local STARTUP_FILE = 'usr/autorun/brewArray.lua'
local function equip(side, item, rawName)
local equipped = peripheral.getType(side)
local equipped = peripheral.getType(side)
if equipped == item then
return true
end
if equipped == item then
return true
end
if not turtle.equip(side, rawName or item) then
if not turtle.selectSlotWithQuantity(0) then
error('No slots available')
end
turtle.equip(side)
if not turtle.equip(side, item) then
error('Unable to equip ' .. item)
end
end
if not turtle.equip(side, rawName or item) then
if not turtle.selectSlotWithQuantity(0) then
error('No slots available')
end
turtle.equip(side)
if not turtle.equip(side, item) then
error('Unable to equip ' .. item)
end
end
turtle.select(1)
turtle.select(1)
end
equip('left', 'plethora:introspection', 'plethora:module:0')
@@ -55,8 +55,8 @@ local intro = device['plethora:introspection']
local inv = intro.getInventory()
if not fs.exists(STARTUP_FILE) then
Util.writeFile(STARTUP_FILE,
[[os.sleep(1)
Util.writeFile(STARTUP_FILE,
[[os.sleep(1)
shell.openForegroundTab('packages/milo/apps/brewArray.lua')]])
end
@@ -65,27 +65,27 @@ local localName
print('detecting wired modem connected to brewing stands...')
for _, dev in pairs(device) do
if dev.type == 'wired_modem' then
local list = dev.getNamesRemote()
brew = { }
localName = dev.getNameLocal()
for _, name in pairs(list) do
if device[name].type ~= 'minecraft:brewing_stand' then
brew = nil
break
end
table.insert(brew, device[name])
end
end
if brew then
print('Using wired modem: ' .. dev.name)
print('Brewing stands: ' .. #brew)
break
end
if dev.type == 'wired_modem' then
local list = dev.getNamesRemote()
brew = { }
localName = dev.getNameLocal()
for _, name in pairs(list) do
if device[name].type ~= 'minecraft:brewing_stand' then
brew = nil
break
end
table.insert(brew, device[name])
end
end
if brew then
print('Using wired modem: ' .. dev.name)
print('Brewing stands: ' .. #brew)
break
end
end
if not brew then
error('Turtle must be connected to a second wired_modem connected to brewing stands only')
error('Turtle must be connected to a second wired_modem connected to brewing stands only')
end
_G.printError([[Program must be restarted if new brewing stands are added.]])
@@ -95,66 +95,66 @@ _G.printError([[Program must be restarted if new brewing stands are added.]])
-- slot 5: blaze powder
local function process(list)
local active = false
local active = false
for _, brewing in ipairs(Util.shallowCopy(brew)) do
local s, m = pcall(function()-- block updates can cause errors
local bs = brewing.list()
for _, brewing in ipairs(Util.shallowCopy(brew)) do
local s, m = pcall(function()-- block updates can cause errors
local bs = brewing.list()
local cooking = bs[1] and bs[2] and bs[3] and bs[4]
if cooking then
active = true
end
local cooking = bs[1] and bs[2] and bs[3] and bs[4]
if cooking then
active = true
end
-- fuel
local fuel = bs[5] or { count = 0 }
if fuel.count < 1 then
print('fueling ' ..brewing.name)
brewing.pullItems(localName, 5, 1, 5)
end
-- fuel
local fuel = bs[5] or { count = 0 }
if fuel.count < 1 then
print('fueling ' ..brewing.name)
brewing.pullItems(localName, 5, 1, 5)
end
if not cooking and (bs[1] or bs[2] or bs[3] or bs[4]) then
print('pulling from : ' .. brewing.name)
for i = 1, 4 do
brewing.pushItems(localName, i, 1, 6 + i)
end
end
if not cooking and (bs[1] or bs[2] or bs[3] or bs[4]) then
print('pulling from : ' .. brewing.name)
for i = 1, 4 do
brewing.pushItems(localName, i, 1, 6 + i)
end
end
if not cooking and list[1] and list[2] and list[3] and list[4] then
print('brewing : ' .. brewing.name)
for i = 1, 4 do
brewing.pullItems(localName, i, 1, i)
list[i].count = list[i].count - 1
if list[i].count == 0 then
list[i] = nil
end
end
if not cooking and list[1] and list[2] and list[3] and list[4] then
print('brewing : ' .. brewing.name)
for i = 1, 4 do
brewing.pullItems(localName, i, 1, i)
list[i].count = list[i].count - 1
if list[i].count == 0 then
list[i] = nil
end
end
-- push brewing stand to end of list
Util.removeByValue(brew, brewing)
table.insert(brew, brewing)
end
end)
if not s and m then
_G.printError(m)
end
end
-- push brewing stand to end of list
Util.removeByValue(brew, brewing)
table.insert(brew, brewing)
end
end)
if not s and m then
_G.printError(m)
end
end
return active
return active
end
Event.on('turtle_inventory', function()
while true do
if not process(inv.list()) then
break
end
os.sleep(3)
end
while true do
if not process(inv.list()) then
break
end
os.sleep(3)
end
end)
Event.onInterval(5, function()
-- for some reason, it keeps stalling ...
os.queueEvent('turtle_inventory')
-- for some reason, it keeps stalling ...
os.queueEvent('turtle_inventory')
end)
os.queueEvent('turtle_inventory')

View File

@@ -7,22 +7,22 @@ local turtle = _G.turtle
local STARTUP_FILE = 'usr/autorun/cobbleGen.lua'
if not fs.exists(STARTUP_FILE) then
Util.writeFile(STARTUP_FILE,
[[os.sleep(1)
Util.writeFile(STARTUP_FILE,
[[os.sleep(1)
shell.openForegroundTab('packages/milo/apps/cobblegen')]])
end
os.queueEvent('turtle_inventory')
while true do
print('waiting')
os.pullEvent('turtle_inventory')
print('waiting for cobble')
for _ = 1, 20 do
if turtle.inspectDown() then
break
end
os.sleep(.1)
end
print('digging')
turtle.digDown()
print('waiting')
os.pullEvent('turtle_inventory')
print('waiting for cobble')
for _ = 1, 20 do
if turtle.inspectDown() then
break
end
os.sleep(.1)
end
print('digging')
turtle.digDown()
end

View File

@@ -13,48 +13,48 @@ local turtle = _G.turtle
local STARTUP_FILE = 'usr/autorun/enderchest.lua'
local enderChest = device.manipulator and
device.manipulator.getEnder or
error('Must be connected to a manipulator with a bound introspection module')
device.manipulator.getEnder or
error('Must be connected to a manipulator with a bound introspection module')
if not fs.exists(STARTUP_FILE) then
Util.writeFile(STARTUP_FILE,
[[os.sleep(1)
Util.writeFile(STARTUP_FILE,
[[os.sleep(1)
shell.openForegroundTab('packages/milo/apps/enderchest')]])
end
local directions = Util.transpose {
'north', 'south', 'east', 'west', 'up', 'down'
'north', 'south', 'east', 'west', 'up', 'down'
}
Event.on('turtle_inventory', function()
local s, m = pcall(function()
local direction
local s, m = pcall(function()
local direction
for _, d in pairs(enderChest().getTransferLocations()) do
if directions[d] then
direction = d
break
end
end
for _, d in pairs(enderChest().getTransferLocations()) do
if directions[d] then
direction = d
break
end
end
if not direction then
error('Unable to determine transfer direction')
end
if not direction then
error('Unable to determine transfer direction')
end
turtle.eachFilledSlot(function(s)
print('sending')
enderChest().pullItems(direction, s.index)
end)
end)
if not s and m then
_G.printError(m)
end
print('idle')
turtle.eachFilledSlot(function(s)
print('sending')
enderChest().pullItems(direction, s.index)
end)
end)
if not s and m then
_G.printError(m)
end
print('idle')
end)
Event.onInterval(5, function()
-- for some reason, it keeps stalling ...
os.queueEvent('turtle_inventory')
-- for some reason, it keeps stalling ...
os.queueEvent('turtle_inventory')
end)
os.queueEvent('turtle_inventory')

View File

@@ -2,15 +2,15 @@
Use multiple furnaces at once to smelt items.
SETUP:
Place an introspection module into the turtles inventory.
Connect turtle to milo network with a wired modem.
Connect turtle to a second wired modem that is connected to furnaces ONLY.
Add as many furnaces as needed.
Place an introspection module into the turtles inventory.
Connect turtle to milo network with a wired modem.
Connect turtle to a second wired modem that is connected to furnaces ONLY.
Add as many furnaces as needed.
CONFIGURATION:
Set turtle as a "Generic Inventory"
export coal to slot 2
import from slot 3
Set turtle as a "Generic Inventory"
export coal to slot 2
import from slot 3
Use this turtle for machine crafting.
--]]
@@ -31,23 +31,23 @@ local FUEL_SLOT = 2
local OUTPUT_SLOT = 3
local function equip(side, item, rawName)
local equipped = peripheral.getType(side)
local equipped = peripheral.getType(side)
if equipped == item then
return true
end
if equipped == item then
return true
end
if not turtle.equip(side, rawName or item) then
if not turtle.selectSlotWithQuantity(0) then
error('No slots available')
end
turtle.equip(side)
if not turtle.equip(side, item) then
error('Unable to equip ' .. item)
end
end
if not turtle.equip(side, rawName or item) then
if not turtle.selectSlotWithQuantity(0) then
error('No slots available')
end
turtle.equip(side)
if not turtle.equip(side, item) then
error('Unable to equip ' .. item)
end
end
turtle.select(1)
turtle.select(1)
end
equip('left', 'plethora:introspection', 'plethora:module:0')
@@ -55,8 +55,8 @@ local intro = device['plethora:introspection']
local inv = intro.getInventory()
if not fs.exists(STARTUP_FILE) then
Util.writeFile(STARTUP_FILE,
[[os.sleep(1)
Util.writeFile(STARTUP_FILE,
[[os.sleep(1)
shell.openForegroundTab('packages/milo/apps/furni')]])
end
@@ -65,121 +65,121 @@ local localName
print('detecting wired modem connected to furnaces...')
for _, dev in pairs(device) do
if dev.type == 'wired_modem' and dev.getNameLocal then
local list = dev.getNamesRemote()
furnaces = { }
localName = dev.getNameLocal()
for _, name in pairs(list) do
if device[name].type ~= 'minecraft:furnace' then
furnaces = nil
break
end
table.insert(furnaces, {
dev = device[name],
list = device[name].list(),
})
end
end
if furnaces then
print('Using wired modem: ' .. dev.name)
print('Furnaces: ' .. #furnaces)
break
end
if dev.type == 'wired_modem' and dev.getNameLocal then
local list = dev.getNamesRemote()
furnaces = { }
localName = dev.getNameLocal()
for _, name in pairs(list) do
if device[name].type ~= 'minecraft:furnace' then
furnaces = nil
break
end
table.insert(furnaces, {
dev = device[name],
list = device[name].list(),
})
end
end
if furnaces then
print('Using wired modem: ' .. dev.name)
print('Furnaces: ' .. #furnaces)
break
end
end
if not furnaces then
error('Turtle must be connected to a second wired_modem connected to furnaces only')
error('Turtle must be connected to a second wired_modem connected to furnaces only')
end
_G.printError([[Program must be restarted if new furnaces are added.]])
local function getSlot(furnace, slotNo)
if not furnace.list[slotNo] then
furnace.list[slotNo] = {
count = 0
}
end
return furnace.list[slotNo]
if not furnace.list[slotNo] then
furnace.list[slotNo] = {
count = 0
}
end
return furnace.list[slotNo]
end
local function process(list)
local inItem = list[INPUT_SLOT]
local inFuel = list[FUEL_SLOT]
local inReturn = list[OUTPUT_SLOT] or { count = 0 }
local inItem = list[INPUT_SLOT]
local inFuel = list[FUEL_SLOT]
local inReturn = list[OUTPUT_SLOT] or { count = 0 }
for _, furnace in ipairs(Util.shallowCopy(furnaces)) do
local s, m = pcall(function()
if furnace.list[INPUT_SLOT] and furnace.list[INPUT_SLOT].count > 0 then
furnace.list = furnace.dev.list()
print('listing ' .. furnace.dev.name)
end
for _, furnace in ipairs(Util.shallowCopy(furnaces)) do
local s, m = pcall(function()
if furnace.list[INPUT_SLOT] and furnace.list[INPUT_SLOT].count > 0 then
furnace.list = furnace.dev.list()
print('listing ' .. furnace.dev.name)
end
-- items to cook
local cooking = getSlot(furnace, INPUT_SLOT)
if cooking.count < 64 and inItem and inItem.count > 0 then
if cooking.count == 0 or cooking.name == inItem.name then
print('cooking : ' .. furnace.dev.name)
local count = furnace.dev.pullItems(localName, INPUT_SLOT, SMELT_AMOUNT, INPUT_SLOT)
-- items to cook
local cooking = getSlot(furnace, INPUT_SLOT)
if cooking.count < 64 and inItem and inItem.count > 0 then
if cooking.count == 0 or cooking.name == inItem.name then
print('cooking : ' .. furnace.dev.name)
local count = furnace.dev.pullItems(localName, INPUT_SLOT, SMELT_AMOUNT, INPUT_SLOT)
if count > 0 then
inItem.count = inItem.count - count
if count > 0 then
inItem.count = inItem.count - count
cooking.name = inItem.name
cooking.count = cooking.count + count
cooking.name = inItem.name
cooking.count = cooking.count + count
-- push to end of queue
Util.removeByValue(furnaces, furnace)
table.insert(furnaces, furnace)
end
end
end
-- push to end of queue
Util.removeByValue(furnaces, furnace)
table.insert(furnaces, furnace)
end
end
end
-- fuel
local fuel = getSlot(furnace, FUEL_SLOT)
if fuel.count < 8 and inFuel and inFuel.count > 0 then
if fuel.count == 0 or fuel.name == inFuel.name then
print('fueling ' .. furnace.dev.name)
local count = furnace.dev.pullItems(localName, FUEL_SLOT, 8 - fuel.count, FUEL_SLOT)
if count > 0 then
inFuel.count = inFuel.count - count
-- fuel
local fuel = getSlot(furnace, FUEL_SLOT)
if fuel.count < 8 and inFuel and inFuel.count > 0 then
if fuel.count == 0 or fuel.name == inFuel.name then
print('fueling ' .. furnace.dev.name)
local count = furnace.dev.pullItems(localName, FUEL_SLOT, 8 - fuel.count, FUEL_SLOT)
if count > 0 then
inFuel.count = inFuel.count - count
fuel.name = inFuel.name
fuel.count = fuel.count + count
end
end
end
fuel.name = inFuel.name
fuel.count = fuel.count + count
end
end
end
local result = getSlot(furnace, OUTPUT_SLOT)
if result.count > 0 then
if inReturn.count == 0 or result.name == inReturn.name then
print('pulling from : ' .. furnace.dev.name)
local count = furnace.dev.pushItems(localName, OUTPUT_SLOT, result.count, OUTPUT_SLOT)
local result = getSlot(furnace, OUTPUT_SLOT)
if result.count > 0 then
if inReturn.count == 0 or result.name == inReturn.name then
print('pulling from : ' .. furnace.dev.name)
local count = furnace.dev.pushItems(localName, OUTPUT_SLOT, result.count, OUTPUT_SLOT)
if count > 0 then
result.count = result.count - count
if result.count == 0 then
furnace.list[OUTPUT_SLOT] = nil
end
if count > 0 then
result.count = result.count - count
if result.count == 0 then
furnace.list[OUTPUT_SLOT] = nil
end
inReturn.name = result.name
inReturn.count = inReturn.count + count
end
end
end
end)
if not s and m then
_G.printError(m)
end
end
inReturn.name = result.name
inReturn.count = inReturn.count + count
end
end
end
end)
if not s and m then
_G.printError(m)
end
end
end
Event.on('turtle_inventory', function()
process(inv.list())
print('idle')
process(inv.list())
print('idle')
end)
Event.onInterval(3, function()
os.queueEvent('turtle_inventory')
os.queueEvent('turtle_inventory')
end)
os.queueEvent('turtle_inventory')

View File

@@ -1,5 +1,5 @@
--[[
For initially setting up large amounts of storage chests.
For initially setting up large amounts of storage chests.
]]
local Util = require('util')
@@ -11,17 +11,17 @@ local st = args[1] or error('Specify a storage type (ie. minecraft:chest)')
local config = { }
peripheral.find(st, function(n)
config[n] = {
name = n,
category = 'storage',
mtype = 'storage',
}
config[n] = {
name = n,
category = 'storage',
mtype = 'storage',
}
end)
print('Found ' .. Util.size(config))
if Util.size(config) == 0 then
error('Invalid peripheral type')
error('Invalid peripheral type')
end
Util.writeTable('usr/config/storageGen', config)