milo tweaks + cloud catcher

This commit is contained in:
kepler155c@gmail.com
2019-01-23 15:30:14 -05:00
parent 4276ea533f
commit 1de92f153f
4 changed files with 17 additions and 39 deletions

View File

@@ -1,13 +0,0 @@
local read = _G.read
local shell = _ENV.shell
if not _G.cloud_catcher then
print('Paste key: ')
local key = read()
if #key == 0 then
return
end
shell.openHiddenTab('cloud ' .. key)
end
shell.run('cloud edit ' .. table.unpack({ ... }))

View File

@@ -133,15 +133,17 @@ Event.onInterval(5, function()
end end
if empty then if empty then
for k,v in pairs(inv) do pcall(function() -- prevent errors from some mod items
local item = itemDB:get(v, function() ni.getInventory().getItemMeta(k) end) for k,v in pairs(inv) do
if item then local item = itemDB:get(v, function() ni.getInventory().getItemMeta(k) end)
if context.state.autostore[makeKey(item)] then if item then
ni.getInventory().pushItems(target, k, v.count, slot) if context.state.autostore[makeKey(item)] then
break ni.getInventory().pushItems(target, k, v.count, slot)
break
end
end end
end end
end end)
end end
end end
end) end)

View File

@@ -1,6 +1,6 @@
local Sound = require('sound') local Sound = require('sound')
local args = { ... } local args = { ... }
local context = args[1] local context = args[1]
local function learn() local function learn()
@@ -19,7 +19,7 @@ context.responseHandlers['craft'] = function(response)
end end
return { return {
menuItem = 'Learn Recipe', menuItem = 'Learn recipe',
callback = function() callback = function()
learn() learn()
end, end,

View File

@@ -5,27 +5,16 @@ local context = Milo:getContext()
local device = _G.device local device = _G.device
local function craftHandler(user, message, socket) local function craftHandler(user, message, socket)
local function makeNode()
local devName = user .. ':inventory'
local adapter = device[devName]
if adapter then
return {
adapter = adapter,
name = devName,
}
end
end
local function craft() local function craft()
local slots = { local slots = {
[1] = 1, [2] = 2, [3] = 3, [1] = 1, [2] = 2, [3] = 3,
[5] = 10, [6] = 11, [7] = 12, [5] = 10, [6] = 11, [7] = 12,
[9] = 19, [10] = 20, [11] = 21, [9] = 19, [10] = 20, [11] = 21,
} }
local node = makeNode() local inventory = device[user .. ':inventory']
if node then if inventory then
for k, v in pairs(slots) do for k, v in pairs(slots) do
node.adapter.pushItems(context.turtleInventory.name, v + message.slot - 1, 1, k) inventory.pushItems(context.turtleInventory.name, v + message.slot - 1, 1, k)
end end
local recipe, msg = Milo:learnRecipe() local recipe, msg = Milo:learnRecipe()
if recipe then if recipe then
@@ -35,7 +24,7 @@ local function craftHandler(user, message, socket)
success = true, success = true,
}) })
for k,v in pairs(context.turtleInventory.adapter.list()) do for k,v in pairs(context.turtleInventory.adapter.list()) do
node.adapter.pullItems(context.turtleInventory.name, k, v.count) inventory.pullItems(context.turtleInventory.name, k, v.count)
end end
else else
socket:write({ socket:write({
@@ -43,7 +32,7 @@ local function craftHandler(user, message, socket)
msg = msg, msg = msg,
}) })
for k, v in pairs(slots) do for k, v in pairs(slots) do
node.adapter.pullItems(context.turtleInventory.name, k, 1, v + message.slot - 1) inventory.pullItems(context.turtleInventory.name, k, 1, v + message.slot - 1)
end end
end end
end end