turtle equip round 2
This commit is contained in:
@@ -2,7 +2,6 @@ local Equipper = require('turtle.equipper')
|
|||||||
local Point = require('point')
|
local Point = require('point')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
local device = _G.device
|
|
||||||
local os = _G.os
|
local os = _G.os
|
||||||
local turtle = _G.turtle
|
local turtle = _G.turtle
|
||||||
|
|
||||||
@@ -19,14 +18,12 @@ local Runners = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Equipper.equipLeft('minecraft:diamond_sword')
|
Equipper.equipLeft('minecraft:diamond_sword')
|
||||||
Equipper.equipRight('plethora:module:2', 'plethora:scanner')
|
local scanner = Equipper.equipRight('plethora:module:2', 'plethora:scanner')
|
||||||
|
|
||||||
local scanner = device['plethora:scanner']
|
|
||||||
local facing = scanner.getBlockMeta(0, 0, 0).state.facing
|
local facing = scanner.getBlockMeta(0, 0, 0).state.facing
|
||||||
turtle.point.heading = Point.facings[facing].heading
|
turtle.point.heading = Point.facings[facing].heading
|
||||||
|
|
||||||
Equipper.equipRight('plethora:module:3', 'plethora:sensor')
|
local sensor = Equipper.equipRight('plethora:module:3', 'plethora:sensor')
|
||||||
local sensor = device['plethora:sensor']
|
|
||||||
|
|
||||||
turtle.setMovementStrategy('goto')
|
turtle.setMovementStrategy('goto')
|
||||||
turtle.set({ attackPolicy = 'attack' })
|
turtle.set({ attackPolicy = 'attack' })
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ local Equipper = require('turtle.equipper')
|
|||||||
local Point = require('point')
|
local Point = require('point')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
local device = _G.device
|
|
||||||
local fs = _G.fs
|
local fs = _G.fs
|
||||||
local os = _G.os
|
local os = _G.os
|
||||||
local peripheral = _G.peripheral
|
local peripheral = _G.peripheral
|
||||||
@@ -18,8 +17,7 @@ local FUEL = Util.transpose {
|
|||||||
'minecraft:blaze_rod:0',
|
'minecraft:blaze_rod:0',
|
||||||
}
|
}
|
||||||
|
|
||||||
Equipper.equipRight('plethora:module:2', 'plethora:scanner')
|
local scanner = Equipper.equipRight('plethora:module:2', 'plethora:scanner')
|
||||||
local scanner = device['plethora:scanner']
|
|
||||||
|
|
||||||
local crops = Util.readTable(CONFIG_FILE) or {
|
local crops = Util.readTable(CONFIG_FILE) or {
|
||||||
['minecraft:wheat'] =
|
['minecraft:wheat'] =
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ local Config = require('config')
|
|||||||
local Equipper = require('turtle.equipper')
|
local Equipper = require('turtle.equipper')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
local device = _G.device
|
|
||||||
local fs = _G.fs
|
local fs = _G.fs
|
||||||
local os = _G.os
|
local os = _G.os
|
||||||
local turtle = _G.turtle
|
local turtle = _G.turtle
|
||||||
@@ -31,9 +30,7 @@ local ANIMALS = {
|
|||||||
local animal = ANIMALS[config.animal]
|
local animal = ANIMALS[config.animal]
|
||||||
|
|
||||||
Equipper.equipLeft('minecraft:diamond_sword')
|
Equipper.equipLeft('minecraft:diamond_sword')
|
||||||
Equipper.equipRight('plethora:module:3', 'plethora:sensor')
|
local sensor = Equipper.equipRight('plethora:module:3', 'plethora:sensor')
|
||||||
|
|
||||||
local sensor = device['plethora:sensor']
|
|
||||||
|
|
||||||
local chest = Adapter({ side = 'bottom', direction = 'up' }) or error('missing chest')
|
local chest = Adapter({ side = 'bottom', direction = 'up' }) or error('missing chest')
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ local Equipper = require('turtle.equipper')
|
|||||||
local Point = require('point')
|
local Point = require('point')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
local device = _G.device
|
|
||||||
local fs = _G.fs
|
local fs = _G.fs
|
||||||
local os = _G.os
|
local os = _G.os
|
||||||
local turtle = _G.turtle
|
local turtle = _G.turtle
|
||||||
@@ -12,8 +11,7 @@ local STARTUP_FILE = 'usr/autorun/spawner.lua'
|
|||||||
local mobTypes = { }
|
local mobTypes = { }
|
||||||
|
|
||||||
Equipper.equipLeft('minecraft:diamond_sword')
|
Equipper.equipLeft('minecraft:diamond_sword')
|
||||||
Equipper.equipRight('plethora:module:2', 'plethora:scanner')
|
local scanner = Equipper.equipRight('plethora:module:2', 'plethora:scanner')
|
||||||
local scanner = device['plethora:scanner']
|
|
||||||
|
|
||||||
turtle.reset()
|
turtle.reset()
|
||||||
local facing = scanner.getBlockMeta(0, 0, 0).state.facing
|
local facing = scanner.getBlockMeta(0, 0, 0).state.facing
|
||||||
@@ -30,8 +28,7 @@ Util.filterInplace(data, function(b)
|
|||||||
end)
|
end)
|
||||||
local chest = Point.closest(spawner, data) or error('missing drop off chest')
|
local chest = Point.closest(spawner, data) or error('missing drop off chest')
|
||||||
|
|
||||||
Equipper.equipRight('plethora:module:3', 'plethora:sensor')
|
local sensor = Equipper.equipRight('plethora:module:3', 'plethora:sensor')
|
||||||
local sensor = device['plethora:sensor']
|
|
||||||
|
|
||||||
if not fs.exists(STARTUP_FILE) then
|
if not fs.exists(STARTUP_FILE) then
|
||||||
Util.writeFile(STARTUP_FILE,
|
Util.writeFile(STARTUP_FILE,
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
_G.requireInjector(_ENV)
|
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Requirements:
|
Requirements:
|
||||||
Place turtle against an oak tree or oak sapling
|
Place turtle against an oak tree or oak sapling
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ local Util = require('util')
|
|||||||
local colors = _G.colors
|
local colors = _G.colors
|
||||||
local fs = _G.fs
|
local fs = _G.fs
|
||||||
local os = _G.os
|
local os = _G.os
|
||||||
local peripheral = _G.peripheral
|
|
||||||
local read = _G.read
|
local read = _G.read
|
||||||
local term = _G.term
|
local term = _G.term
|
||||||
local turtle = _G.turtle
|
local turtle = _G.turtle
|
||||||
@@ -318,8 +317,8 @@ local function collectDrops(suckAction)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function scan()
|
local function scan()
|
||||||
Equipper.equipLeft('plethora:module:2', 'plethora:scanner')
|
local scanner = Equipper.equipLeft('plethora:module:2', 'plethora:scanner')
|
||||||
local blocks = peripheral.call('left', 'scan')
|
local blocks = scanner.scan()
|
||||||
Equipper.equipLeft('minecraft:diamond_pickaxe')
|
Equipper.equipLeft('minecraft:diamond_pickaxe')
|
||||||
local throttle = Util.throttle()
|
local throttle = Util.throttle()
|
||||||
|
|
||||||
@@ -508,8 +507,8 @@ turtle.initialize = function()
|
|||||||
|
|
||||||
--os.sleep(5)
|
--os.sleep(5)
|
||||||
local pt = GPS.getPoint(2) or error('GPS not found')
|
local pt = GPS.getPoint(2) or error('GPS not found')
|
||||||
Equipper.equipLeft('plethora:module:2', 'plethora:scanner')
|
local scanner = Equipper.equipLeft('plethora:module:2', 'plethora:scanner')
|
||||||
local facing = peripheral.call('left', 'getBlockMeta', 0, 0, 0).state.facing
|
local facing = scanner.getBlockMeta(0, 0, 0).state.facing
|
||||||
pt.heading = Point.facings[facing].heading
|
pt.heading = Point.facings[facing].heading
|
||||||
turtle.setPoint(pt, true)
|
turtle.setPoint(pt, true)
|
||||||
Equipper.equipLeft('minecraft:diamond_pickaxe')
|
Equipper.equipLeft('minecraft:diamond_pickaxe')
|
||||||
|
|||||||
@@ -41,18 +41,18 @@ local function getEquipped()
|
|||||||
elseif not Equipper.equipped.left then
|
elseif not Equipper.equipped.left then
|
||||||
local slot = Equipper.unequip('left')
|
local slot = Equipper.unequip('left')
|
||||||
if slot then
|
if slot then
|
||||||
|
turtle.equip('left', slot.name .. ':' .. slot.damage)
|
||||||
Equipper.equipped.left = slot.name .. ':' .. slot.damage
|
Equipper.equipped.left = slot.name .. ':' .. slot.damage
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif not Equipper.equipped.right then
|
elseif not Equipper.equipped.right then
|
||||||
local slot = Equipper.unequip('right')
|
local slot = Equipper.unequip('right')
|
||||||
if slot then
|
if slot then
|
||||||
|
turtle.equip('right', slot.name .. ':' .. slot.damage)
|
||||||
Equipper.equipped.right = slot.name .. ':' .. slot.damage
|
Equipper.equipped.right = slot.name .. ':' .. slot.damage
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
_debug("Detected Equipped")
|
|
||||||
_debug(Equipper.equipped)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Equipper.unequip(side)
|
function Equipper.unequip(side)
|
||||||
@@ -81,7 +81,7 @@ function Equipper.equip(side, invName, equippedName)
|
|||||||
|
|
||||||
-- is it already equipped ?
|
-- is it already equipped ?
|
||||||
if Equipper.equipped[side] == (equippedName or invName) then
|
if Equipper.equipped[side] == (equippedName or invName) then
|
||||||
return
|
return peripheral.getType(side) and peripheral.wrap(side)
|
||||||
end
|
end
|
||||||
-- is it equipped on other side ?
|
-- is it equipped on other side ?
|
||||||
if Equipper.equipped[reversed[side]] == (equippedName or invName) then
|
if Equipper.equipped[reversed[side]] == (equippedName or invName) then
|
||||||
@@ -95,16 +95,15 @@ function Equipper.equip(side, invName, equippedName)
|
|||||||
|
|
||||||
Equipper.equipped[side] = peripheral.getType(side) or invName
|
Equipper.equipped[side] = peripheral.getType(side) or invName
|
||||||
|
|
||||||
_debug("Equipped: " .. invName)
|
return peripheral.getType(side) and peripheral.wrap(side)
|
||||||
_debug(Equipper.equipped)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Equipper.equipLeft(invName, equippedName)
|
function Equipper.equipLeft(invName, equippedName)
|
||||||
Equipper.equip('left', invName, equippedName)
|
return Equipper.equip('left', invName, equippedName)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Equipper.equipRight(invName, equippedName)
|
function Equipper.equipRight(invName, equippedName)
|
||||||
Equipper.equip('right', invName, equippedName)
|
return Equipper.equip('right', invName, equippedName)
|
||||||
end
|
end
|
||||||
|
|
||||||
return Equipper
|
return Equipper
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
local Equipper = require('turtle.equipper')
|
local Equipper = require('turtle.equipper')
|
||||||
local Point = require('point')
|
local Point = require('point')
|
||||||
|
|
||||||
local device = _G.device
|
|
||||||
local peripheral = _G.device
|
local peripheral = _G.device
|
||||||
local turtle = _G.turtle
|
local turtle = _G.turtle
|
||||||
|
|
||||||
@@ -16,9 +15,7 @@ if not turtle.has('minecraft:bucket') then
|
|||||||
end
|
end
|
||||||
|
|
||||||
local swapSide = peripheral.getType('right') == 'modem' and 'left' or 'right'
|
local swapSide = peripheral.getType('right') == 'modem' and 'left' or 'right'
|
||||||
Equipper.equip(swapSide, 'plethora:module:2', 'plethora:scanner')
|
local scanner = Equipper.equip(swapSide, 'plethora:module:2', 'plethora:scanner')
|
||||||
|
|
||||||
local scanner = device['plethora:scanner']
|
|
||||||
|
|
||||||
if not turtle.select('minecraft:bucket') then
|
if not turtle.select('minecraft:bucket') then
|
||||||
error('bucket required')
|
error('bucket required')
|
||||||
|
|||||||
Reference in New Issue
Block a user