parent
e31d0986b8
commit
93ecf28013
@ -0,0 +1,27 @@
|
||||
local component = require('component')
|
||||
|
||||
local geo = component.geolyzer
|
||||
|
||||
---Scan 64 blocks south and return farthest found ore
|
||||
---@param depth number how many block deep to scan
|
||||
---@param y_offset number y offset, 0 means same height as the robot, 1 means the layer above the robot
|
||||
---@return integer
|
||||
local function deep_scan(depth, y_offset)
|
||||
local results = geo.scan(0, 1, y_offset, 1, depth, 1)
|
||||
|
||||
local max_depth = 0
|
||||
for i = 1, depth do
|
||||
if results[i] >= 2 and results[i] ~= 100 then -- 100 is lava or water, ignore that
|
||||
if i > max_depth then
|
||||
max_depth = i
|
||||
end
|
||||
-- print("Got " .. results[i] .. " at " .. i .. " (y+" .. y_offset .. ")")
|
||||
end
|
||||
end
|
||||
|
||||
return max_depth
|
||||
end
|
||||
|
||||
return {
|
||||
deep_scan = deep_scan
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
local robot = require("robot")
|
||||
local component = require("component")
|
||||
|
||||
local inventory = component.inventory_controller;
|
||||
|
||||
---Place a torch above the robot
|
||||
---@param side number|nil which side of the empty space to place the torch
|
||||
local function place_torch(side)
|
||||
local stack = inventory.getStackInInternalSlot(1)
|
||||
|
||||
if stack.name == "minecraft:torch" then
|
||||
robot.select(1)
|
||||
robot.placeUp(side)
|
||||
else
|
||||
print('Out of torches')
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
place_torch = place_torch
|
||||
}
|
Loading…
Reference in new issue