peripheral updates

This commit is contained in:
kepler155c@gmail.com
2018-12-25 02:33:14 -05:00
parent ffab2372de
commit 32a831862b
6 changed files with 28 additions and 84 deletions

View File

@@ -1,12 +1,12 @@
_G.requireInjector(_ENV)
local Peripheral = require('peripheral')
local Point = require('point')
local Util = require('util')
local device = _G.device
local os = _G.os
local turtle = _G.turtle
local device = _G.device
local os = _G.os
local peripheral = _G.peripheral
local turtle = _G.turtle
local args = { ... }
local mobType = args[1] or error('Syntax: attack <mob names>')
@@ -21,23 +21,12 @@ local Runners = {
}
local function equip(side, item, rawName)
local equipped = Peripheral.lookup('side/' .. side)
if equipped and equipped.type == 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
if peripheral.getType(side) ~= item then
if not turtle.equip(side, rawName or item) then
error('Unable to equip ' .. item)
end
turtle.select(1)
end
turtle.select(1)
end
equip('left', 'minecraft:diamond_sword')