-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecute.lua
More file actions
36 lines (27 loc) · 831 Bytes
/
execute.lua
File metadata and controls
36 lines (27 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
local SCAN_FOR = {"ore"}
local tArgs = {...}
if #tArgs ~= 10 then
error("Usage: /execute ...\n1) press f3+c to save coords\n2) press control-v to paste into computer\n3) press enter",0)
end
local x, y, z = tonumber(tArgs[6]), tonumber(tArgs[7]), tonumber(tArgs[8])
local scanner = peripheral.find("geoScanner")
if not scanner then
error("must place geoScanner next to computer", 0)
end
local blocks = scanner.scan(8)
if not blocks then
error("geoScanner scan returns nil", 0)
end
local result = io.open("result","w")
function result:print(...)
self:write(table.concat({...},",\t"),"\n")
end
for _,block in pairs(blocks) do
for _,needle in pairs(SCAN_FOR) do
if block.name:find(needle) then
result:print(x+block.x,y+block.y,z+block.z,block.name)
end
end
end
result:close()
shell.run("edit result")