peripheral updates
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -3,12 +3,12 @@ _G.requireInjector(_ENV)
|
||||
local Config = require('config')
|
||||
local Util = require('util')
|
||||
local Adapter = require('chestAdapter18')
|
||||
local Peripheral = require('peripheral')
|
||||
|
||||
local device = _G.device
|
||||
local fs = _G.fs
|
||||
local os = _G.os
|
||||
local turtle = _G.turtle
|
||||
local device = _G.device
|
||||
local fs = _G.fs
|
||||
local os = _G.os
|
||||
local peripheral = _G.peripheral
|
||||
local turtle = _G.turtle
|
||||
|
||||
local STARTUP_FILE = 'usr/autorun/rancher.lua'
|
||||
|
||||
@@ -33,23 +33,12 @@ local ANIMALS = {
|
||||
local animal = ANIMALS[config.animal]
|
||||
|
||||
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
|
||||
|
||||
local function getLocalName()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
local GPS = require('gps')
|
||||
local Peripheral = require('peripheral')
|
||||
local Point = require('point')
|
||||
local Util = require('util')
|
||||
|
||||
@@ -68,23 +67,12 @@ local state = Util.readTable('usr/config/superTreefarm') or {
|
||||
local clock = os.clock()
|
||||
|
||||
local function equip(side, item, rawName)
|
||||
local equipped = Peripheral.lookup('side/' .. side)
|
||||
|
||||
if equipped and equipped.type == item then
|
||||
if peripheral.getType(side) == item or turtle.equip(side, rawName or item) then
|
||||
turtle.select(1)
|
||||
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 ' .. (rawName or item))
|
||||
end
|
||||
end
|
||||
|
||||
turtle.select(1)
|
||||
error('Unable to equip ' .. (rawName or item))
|
||||
end
|
||||
|
||||
local function inspect(fn)
|
||||
@@ -531,6 +519,7 @@ local function fellTrees(blocks)
|
||||
turtle.digDownAt(pt)
|
||||
if pt.plant then
|
||||
turtle.placeDown(pt.plant)
|
||||
turtle.select(1)
|
||||
end
|
||||
end
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user