-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtools.lua
More file actions
107 lines (102 loc) · 3.59 KB
/
Copy pathtools.lua
File metadata and controls
107 lines (102 loc) · 3.59 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
local M = {}
local bot = require("bot")
local doUntil = require("doUntil")
local robot = require("robot")
function M.swingDown(tool)
if tool == "cell" then
if not bot.inventory[0] or bot.inventory[0].name ~= "minecraft:bucket" then
robot.select(
doUntil(function()
return bot.checkItem({name = "IC2:itemCellEmpty", damage = 0}, 1)
end, "缺少空单元")
)
bot.equip()
end
robot.useDown()
bot.inventory[0] = nil
elseif tool == "bucket" then
if not bot.inventory[0] or bot.inventory[0].name ~= "minecraft:bucket" then
robot.select(
doUntil(function()
return bot.checkItem({name = "minecraft:bucket"}, 1)
end, "缺少桶")
)
bot.equip()
end
robot.useDown()
bot.inventory[0] = nil
elseif tool == nil then
if not bot.inventory[0] or bot.inventory[0].name ~= "gregtech:gt.Tool_Vajra" then
robot.select(
doUntil(function()
return bot.checkItem({name = "gregtech:gt.Tool_Vajra"}, 1)
end, "缺少金刚杵")
)
bot.equip()
end
if not (bot.inventory[0].enchantments and bot.inventory[0].enchantments[1] and bot.inventory[0].enchantments[1].name == "enchantment.untouching") then
robot.useUp(nil, true)
bot.inventory[0].enchantments = {{name = "enchantment.untouching", level = 1, label = "精准采集"}}
end
local _1, _2 = robot.swingDown()
if _1 and _2 == "block" then
os.sleep(0.01)
end
else
error("错误的调用tools.swingDown()")
end
end
function M.placeDown(item)
if not item or not item.name then
error("错误的调用tools.placeDown()")
end
if item.tool then
if item.tool == "cell" then
robot.select(
doUntil(function()
return bot.checkItem({name = item.name, damage = item.damage}, 1)
end, "缺少"..(item.label or item.name))
)
bot.down()
local suc = robot.detect()
if suc then
for i = 1,3 do
bot.turnLeft()
suc = robot.detect()
if not suc then
break
end
end
end
if suc then
error("放置"..(item.label or item.name or "").."失败")
end
bot.forward()
bot.turnRight()
bot.turnRight()
robot.placeDown()--是的,IC2单元的放置逻辑就是这么神秘
bot.up()
bot.forward()
bot.inventory[0] = nil
elseif item.tool == "bucket" then
robot.select(
doUntil(function()
return bot.checkItem({name = item.name, damage = item.damage}, 1)
end, "缺少"..(item.label or item.name))
)
bot.equip()
robot.useDown()
bot.inventory[0] = {name = "minecraft:bucket"}
else
error("错误的调用tools.placeDown()")
end
else
robot.select(
doUntil(function()
return bot.checkItem({name = item.name, damage = item.damage}, 1)
end, "缺少"..(item.label or item.name))
)
robot.placeDown()
end
end
return M