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
if empty then
for k,v in pairs(inv) do
local item = itemDB:get(v, function() ni.getInventory().getItemMeta(k) end)
if item then
if context.state.autostore[makeKey(item)] then
ni.getInventory().pushItems(target, k, v.count, slot)
break
pcall(function() -- prevent errors from some mod items
for k,v in pairs(inv) do
local item = itemDB:get(v, function() ni.getInventory().getItemMeta(k) end)
if item then
if context.state.autostore[makeKey(item)] then
ni.getInventory().pushItems(target, k, v.count, slot)
break
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 function learn()
@@ -19,7 +19,7 @@ context.responseHandlers['craft'] = function(response)
end
return {
menuItem = 'Learn Recipe',
menuItem = 'Learn recipe',
callback = function()
learn()
end,

View File

@@ -5,27 +5,16 @@ local context = Milo:getContext()
local device = _G.device
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 slots = {
[1] = 1, [2] = 2, [3] = 3,
[5] = 10, [6] = 11, [7] = 12,
[9] = 19, [10] = 20, [11] = 21,
}
local node = makeNode()
if node then
local inventory = device[user .. ':inventory']
if inventory then
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
local recipe, msg = Milo:learnRecipe()
if recipe then
@@ -35,7 +24,7 @@ local function craftHandler(user, message, socket)
success = true,
})
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
else
socket:write({
@@ -43,7 +32,7 @@ local function craftHandler(user, message, socket)
msg = msg,
})
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