commit | author | age
|
ee0765
|
1 |
local mining_drill_max_charge = 60000 |
S |
2 |
local mining_drill_mk2_max_charge = 240000 |
|
3 |
local mining_drill_mk3_max_charge = 960000 |
|
4 |
local mining_drill_power_usage = 200 |
|
5 |
local mining_drill_mk2_power_usage = 600 |
|
6 |
local mining_drill_mk3_power_usage = 1800 |
82cba9
|
7 |
|
R |
8 |
minetest.register_craft({ |
|
9 |
output = 'technic:mining_drill', |
|
10 |
recipe = { |
eac484
|
11 |
{'technic:stainless_steel_ingot', 'technic:diamond_drill_head', 'technic:stainless_steel_ingot'}, |
S |
12 |
{'technic:stainless_steel_ingot', 'technic:motor', 'technic:stainless_steel_ingot'}, |
|
13 |
{'', 'technic:red_energy_crystal', 'moreores:copper_ingot'}, |
82cba9
|
14 |
} |
R |
15 |
}) |
e23f87
|
16 |
minetest.register_craft({ |
R |
17 |
output = 'technic:mining_drill_mk2', |
|
18 |
recipe = { |
eac484
|
19 |
{'technic:diamond_drill_head', 'technic:diamond_drill_head', 'technic:diamond_drill_head'}, |
S |
20 |
{'technic:stainless_steel_ingot', 'technic:mining_drill', 'technic:stainless_steel_ingot'}, |
|
21 |
{'', 'technic:green_energy_crystal', ''}, |
e23f87
|
22 |
} |
R |
23 |
}) |
|
24 |
minetest.register_craft({ |
|
25 |
output = 'technic:mining_drill_mk3', |
|
26 |
recipe = { |
eac484
|
27 |
{'technic:diamond_drill_head', 'technic:diamond_drill_head', 'technic:diamond_drill_head'}, |
S |
28 |
{'technic:stainless_steel_ingot', 'technic:mining_drill_mk2', 'technic:stainless_steel_ingot'}, |
|
29 |
{'', 'technic:blue_energy_crystal', ''}, |
e23f87
|
30 |
} |
R |
31 |
}) |
eac484
|
32 |
for i = 1, 4 do |
ee0765
|
33 |
minetest.register_craft({ |
S |
34 |
output = 'technic:mining_drill_mk3', |
|
35 |
recipe = { |
|
36 |
{'technic:diamond_drill_head', 'technic:diamond_drill_head', 'technic:diamond_drill_head'}, |
|
37 |
{'technic:stainless_steel_ingot', 'technic:mining_drill_mk2_'..i, 'technic:stainless_steel_ingot'}, |
|
38 |
{'', 'technic:blue_energy_crystal', ''}, |
|
39 |
} |
|
40 |
}) |
91329b
|
41 |
end |
82cba9
|
42 |
|
eac484
|
43 |
function drill_dig_it(pos, player, drill_type, mode) |
e23f87
|
44 |
local charge |
eac484
|
45 |
if mode == 1 then |
S |
46 |
drill_dig_it0(pos, player) |
e23f87
|
47 |
end |
R |
48 |
|
eac484
|
49 |
if mode == 2 then -- 3 deep |
S |
50 |
dir = drill_dig_it1(player) |
|
51 |
if dir == 0 then -- x+ |
|
52 |
drill_dig_it0(pos, player) |
|
53 |
pos.x = pos.x + 1 |
|
54 |
drill_dig_it0(pos, player) |
|
55 |
pos.x = pos.x + 1 |
|
56 |
drill_dig_it0(pos, player) |
e23f87
|
57 |
end |
eac484
|
58 |
if dir == 1 then -- x- |
S |
59 |
drill_dig_it0(pos, player) |
e23f87
|
60 |
pos.x=pos.x-1 |
R |
61 |
drill_dig_it0 (pos,player) |
|
62 |
pos.x=pos.x-1 |
|
63 |
drill_dig_it0 (pos,player) |
|
64 |
end |
|
65 |
if dir==2 then -- z+ |
|
66 |
drill_dig_it0 (pos,player) |
|
67 |
pos.z=pos.z+1 |
|
68 |
drill_dig_it0 (pos,player) |
|
69 |
pos.z=pos.z+1 |
|
70 |
drill_dig_it0 (pos,player) |
|
71 |
end |
|
72 |
if dir==3 then -- z- |
|
73 |
drill_dig_it0 (pos,player) |
|
74 |
pos.z=pos.z+1 |
|
75 |
drill_dig_it0 (pos,player) |
|
76 |
pos.z=pos.z+1 |
|
77 |
drill_dig_it0 (pos,player) |
|
78 |
end |
|
79 |
end |
|
80 |
|
|
81 |
if mode==3 then -- 3 wide |
|
82 |
dir=drill_dig_it1(player) |
|
83 |
if dir==0 or dir==1 then -- x |
|
84 |
drill_dig_it0 (pos,player) |
|
85 |
pos.z=pos.z+1 |
|
86 |
drill_dig_it0 (pos,player) |
|
87 |
pos.z=pos.z-2 |
|
88 |
drill_dig_it0 (pos,player) |
|
89 |
end |
|
90 |
if dir==2 or dir==3 then -- z |
|
91 |
drill_dig_it0 (pos,player) |
|
92 |
pos.x=pos.x+1 |
|
93 |
drill_dig_it0 (pos,player) |
|
94 |
pos.x=pos.x-2 |
|
95 |
drill_dig_it0 (pos,player) |
|
96 |
end |
|
97 |
end |
|
98 |
|
|
99 |
if mode==4 then -- 3 tall, selected in the middle |
|
100 |
drill_dig_it0 (pos,player) |
|
101 |
pos.y=pos.y+1 |
|
102 |
drill_dig_it0 (pos,player) |
|
103 |
pos.y=pos.y-2 |
|
104 |
drill_dig_it0 (pos,player) |
|
105 |
end |
82cba9
|
106 |
|
e23f87
|
107 |
if mode==5 then -- 3 x 3 |
R |
108 |
local dir=player:get_look_dir() |
|
109 |
if math.abs(dir.y)<0.5 then |
|
110 |
dir=drill_dig_it1(player) |
|
111 |
if dir==0 or dir==1 then -- x |
|
112 |
drill_dig_it2(pos,player) |
|
113 |
end |
|
114 |
if dir==2 or dir==3 then -- z |
|
115 |
drill_dig_it3(pos,player) |
|
116 |
end |
|
117 |
else |
|
118 |
drill_dig_it4(pos,player) |
|
119 |
end |
|
120 |
end |
|
121 |
|
|
122 |
if drill_type==1 then charge=mining_drill_power_usage end |
|
123 |
if drill_type==2 then |
|
124 |
if mode==1 then charge=mining_drill_mk2_power_usage end |
|
125 |
if (mode==2 or mode==3 or mode==4) then charge=mining_drill_mk2_power_usage*3 end |
|
126 |
end |
|
127 |
if drill_type==3 then |
|
128 |
if mode==1 then charge=mining_drill_power_usage end |
|
129 |
if (mode==2 or mode==3 or mode==4) then charge=mining_drill_mk2_power_usage*6 end |
|
130 |
if mode==5 then charge=mining_drill_mk2_power_usage*9 end |
|
131 |
end |
|
132 |
minetest.sound_play("mining_drill", {pos = pos, gain = 1.0, max_hear_distance = 10,}) |
|
133 |
return charge |
|
134 |
end |
82cba9
|
135 |
|
e23f87
|
136 |
function drill_dig_it0 (pos,player) |
82cba9
|
137 |
local node=minetest.env:get_node(pos) |
R |
138 |
if node.name == "air" or node.name == "ignore" then return end |
|
139 |
if node.name == "default:lava_source" then return end |
|
140 |
if node.name == "default:lava_flowing" then return end |
|
141 |
if node.name == "default:water_source" then minetest.env:remove_node(pos) return end |
|
142 |
if node.name == "default:water_flowing" then minetest.env:remove_node(pos) return end |
|
143 |
minetest.node_dig(pos,node,player) |
e23f87
|
144 |
end |
82cba9
|
145 |
|
e23f87
|
146 |
function drill_dig_it1 (player) |
R |
147 |
local dir=player:get_look_dir() |
|
148 |
if math.abs(dir.x)>math.abs(dir.z) then |
|
149 |
if dir.x>0 then return 0 end |
|
150 |
return 1 |
|
151 |
end |
|
152 |
if dir.z>0 then return 2 end |
|
153 |
return 3 |
|
154 |
end |
|
155 |
|
|
156 |
function drill_dig_it2 (pos,player) |
|
157 |
drill_dig_it0 (pos,player) |
|
158 |
pos.z=pos.z+1 |
|
159 |
drill_dig_it0 (pos,player) |
|
160 |
pos.z=pos.z-2 |
|
161 |
drill_dig_it0 (pos,player) |
|
162 |
pos.z=pos.z+1 |
|
163 |
pos.y=pos.y+1 |
|
164 |
drill_dig_it0 (pos,player) |
|
165 |
pos.z=pos.z+1 |
|
166 |
drill_dig_it0 (pos,player) |
|
167 |
pos.z=pos.z-2 |
|
168 |
drill_dig_it0 (pos,player) |
|
169 |
pos.z=pos.z+1 |
|
170 |
pos.y=pos.y-2 |
|
171 |
drill_dig_it0 (pos,player) |
|
172 |
pos.z=pos.z+1 |
|
173 |
drill_dig_it0 (pos,player) |
|
174 |
pos.z=pos.z-2 |
|
175 |
drill_dig_it0 (pos,player) |
|
176 |
end |
|
177 |
function drill_dig_it3 (pos,player) |
|
178 |
drill_dig_it0 (pos,player) |
|
179 |
pos.x=pos.x+1 |
|
180 |
drill_dig_it0 (pos,player) |
|
181 |
pos.x=pos.x-2 |
|
182 |
drill_dig_it0 (pos,player) |
|
183 |
pos.x=pos.x+1 |
|
184 |
pos.y=pos.y+1 |
|
185 |
drill_dig_it0 (pos,player) |
|
186 |
pos.x=pos.x+1 |
|
187 |
drill_dig_it0 (pos,player) |
|
188 |
pos.x=pos.x-2 |
|
189 |
drill_dig_it0 (pos,player) |
|
190 |
pos.x=pos.x+1 |
|
191 |
pos.y=pos.y-2 |
|
192 |
drill_dig_it0 (pos,player) |
|
193 |
pos.x=pos.x+1 |
|
194 |
drill_dig_it0 (pos,player) |
|
195 |
pos.x=pos.x-2 |
|
196 |
drill_dig_it0 (pos,player) |
|
197 |
end |
|
198 |
|
|
199 |
function drill_dig_it4 (pos,player) |
|
200 |
drill_dig_it0 (pos,player) |
|
201 |
pos.x=pos.x+1 |
|
202 |
drill_dig_it0 (pos,player) |
|
203 |
pos.x=pos.x-2 |
|
204 |
drill_dig_it0 (pos,player) |
|
205 |
pos.x=pos.x+1 |
|
206 |
pos.z=pos.z+1 |
|
207 |
drill_dig_it0 (pos,player) |
|
208 |
pos.x=pos.x+1 |
|
209 |
drill_dig_it0 (pos,player) |
|
210 |
pos.x=pos.x-2 |
|
211 |
drill_dig_it0 (pos,player) |
|
212 |
pos.x=pos.x+1 |
|
213 |
pos.z=pos.z-2 |
|
214 |
drill_dig_it0 (pos,player) |
|
215 |
pos.x=pos.x+1 |
|
216 |
drill_dig_it0 (pos,player) |
|
217 |
pos.x=pos.x-2 |
|
218 |
drill_dig_it0 (pos,player) |
|
219 |
end |
|
220 |
|
ee0765
|
221 |
technic.register_power_tool("technic:mining_drill", mining_drill_max_charge) |
e23f87
|
222 |
minetest.register_tool("technic:mining_drill", { |
R |
223 |
description = "Mining Drill Mk1", |
|
224 |
inventory_image = "technic_mining_drill.png", |
|
225 |
stack_max = 1, |
|
226 |
on_use = function(itemstack, user, pointed_thing) |
eac484
|
227 |
if pointed_thing.type ~= "node" then |
S |
228 |
return itemstack |
e23f87
|
229 |
end |
eac484
|
230 |
local meta = get_item_meta(itemstack:get_metadata()) |
S |
231 |
if not meta or not meta.charge then |
|
232 |
return |
|
233 |
end |
|
234 |
if meta.charge - mining_drill_power_usage > 0 then |
|
235 |
local pos = minetest.get_pointed_thing_position(pointed_thing, above) |
|
236 |
charge_to_take = drill_dig_it(pos, user, 1, 1) |
|
237 |
meta.charge = meta.charge - mining_drill_power_usage |
|
238 |
itemstack:set_metadata(set_item_meta(meta)) |
|
239 |
technic.set_RE_wear(itemstack, meta.charge, mining_drill_max_charge) |
|
240 |
end |
|
241 |
return itemstack |
e23f87
|
242 |
end, |
R |
243 |
}) |
|
244 |
|
|
245 |
minetest.register_tool("technic:mining_drill_mk2", { |
|
246 |
description = "Mining Drill Mk2", |
|
247 |
inventory_image = "technic_mining_drill_mk2.png", |
|
248 |
on_use = function(itemstack, user, pointed_thing) |
eac484
|
249 |
mining_drill_mk2_handler(itemstack, user, pointed_thing) |
S |
250 |
return itemstack |
e23f87
|
251 |
end, |
R |
252 |
}) |
ee0765
|
253 |
|
S |
254 |
technic.register_power_tool("technic:mining_drill_mk2", mining_drill_mk2_max_charge) |
e23f87
|
255 |
|
eac484
|
256 |
for i = 1, 4 do |
ee0765
|
257 |
technic.register_power_tool("technic:mining_drill_mk2_"..i, mining_drill_mk2_max_charge) |
S |
258 |
minetest.register_tool("technic:mining_drill_mk2_"..i, { |
|
259 |
description = "Mining Drill Mk2 in Mode "..i, |
|
260 |
inventory_image = "technic_mining_drill_mk2.png^technic_tool_mode"..i..".png", |
|
261 |
wield_image = "technic_mining_drill_mk2.png", |
|
262 |
groups = {not_in_creative_inventory=1}, |
|
263 |
on_use = function(itemstack, user, pointed_thing) |
|
264 |
mining_drill_mk2_handler(itemstack, user, pointed_thing) |
|
265 |
return itemstack |
|
266 |
end, |
|
267 |
}) |
e23f87
|
268 |
end |
R |
269 |
|
|
270 |
minetest.register_tool("technic:mining_drill_mk3", { |
|
271 |
description = "Mining Drill Mk3", |
|
272 |
inventory_image = "technic_mining_drill_mk3.png", |
|
273 |
on_use = function(itemstack, user, pointed_thing) |
|
274 |
mining_drill_mk3_handler(itemstack,user,pointed_thing) |
|
275 |
return itemstack |
|
276 |
end, |
|
277 |
}) |
ee0765
|
278 |
|
S |
279 |
technic.register_power_tool("technic:mining_drill_mk3", mining_drill_mk3_max_charge) |
e23f87
|
280 |
|
R |
281 |
for i=1,5,1 do |
ee0765
|
282 |
technic.register_power_tool("technic:mining_drill_mk3_"..i, mining_drill_mk3_max_charge) |
S |
283 |
minetest.register_tool("technic:mining_drill_mk3_"..i, { |
|
284 |
description = "Mining Drill Mk3 in Mode "..i, |
|
285 |
inventory_image = "technic_mining_drill_mk3.png^technic_tool_mode"..i..".png", |
|
286 |
wield_image = "technic_mining_drill_mk3.png", |
|
287 |
groups = {not_in_creative_inventory=1}, |
|
288 |
on_use = function(itemstack, user, pointed_thing) |
|
289 |
mining_drill_mk3_handler(itemstack,user,pointed_thing) |
|
290 |
return itemstack |
|
291 |
end, |
|
292 |
}) |
e23f87
|
293 |
end |
R |
294 |
|
eac484
|
295 |
function mining_drill_mk2_handler(itemstack, user, pointed_thing) |
S |
296 |
local keys = user:get_player_control() |
|
297 |
local player_name = user:get_player_name() |
|
298 |
local meta = get_item_meta(itemstack:get_metadata()) |
|
299 |
if not meta or not meta.mode or keys.sneak then |
|
300 |
return mining_drill_mk2_setmode(user, itemstack) |
|
301 |
end |
|
302 |
if pointed_thing.type ~= "node" or not meta.charge then |
|
303 |
return |
|
304 |
end |
|
305 |
if meta.charge - mining_drill_power_usage > 0 then |
|
306 |
local pos = minetest.get_pointed_thing_position(pointed_thing, above) |
|
307 |
local charge_to_take = drill_dig_it(pos, user, 2, meta.mode) |
|
308 |
meta.charge = meta.charge - charge_to_take |
|
309 |
meta.charge = math.max(meta.charge, 0) |
|
310 |
itemstack:set_metadata(set_item_meta(meta)) |
|
311 |
technic.set_RE_wear(itemstack, meta.charge, mining_drill_mk2_max_charge) |
e23f87
|
312 |
end |
R |
313 |
return itemstack |
|
314 |
end |
|
315 |
|
eac484
|
316 |
function mining_drill_mk3_handler(itemstack, user, pointed_thing) |
S |
317 |
local keys = user:get_player_control() |
|
318 |
local player_name = user:get_player_name() |
|
319 |
local meta = get_item_meta(itemstack:get_metadata()) |
|
320 |
if not meta or not meta.mode or keys.sneak then |
|
321 |
return mining_drill_mk3_setmode(user, itemstack) |
|
322 |
end |
|
323 |
if pointed_thing.type ~= "node" or not meta.charge then |
|
324 |
return |
|
325 |
end |
|
326 |
if meta.charge - mining_drill_power_usage > 0 then |
|
327 |
local pos = minetest.get_pointed_thing_position(pointed_thing, above) |
|
328 |
local charge_to_take = drill_dig_it(pos, user, 3, meta.mode) |
|
329 |
meta.charge = meta.charge - charge_to_take |
|
330 |
meta.charge = math.max(meta.charge, 0) |
|
331 |
itemstack:set_metadata(set_item_meta(meta)) |
|
332 |
technic.set_RE_wear(itemstack, meta.charge, mining_drill_mk3_max_charge) |
e23f87
|
333 |
end |
R |
334 |
return itemstack |
|
335 |
end |
|
336 |
|
eac484
|
337 |
mining_drill_mode_text = { |
S |
338 |
{"Single node."}, |
|
339 |
{"3 nodes deep."}, |
|
340 |
{"3 modes wide."}, |
|
341 |
{"3 modes tall."}, |
|
342 |
{"3x3 nodes."}, |
e23f87
|
343 |
} |
R |
344 |
|
|
345 |
function mining_drill_mk2_setmode(user,itemstack) |
|
346 |
local player_name=user:get_player_name() |
|
347 |
local item=itemstack:to_table() |
|
348 |
local meta=get_item_meta(item["metadata"]) |
|
349 |
if meta==nil then |
|
350 |
meta={} |
|
351 |
mode=0 |
|
352 |
end |
|
353 |
if meta["mode"]==nil then |
|
354 |
minetest.chat_send_player(player_name,"Hold shift and use to change Mining Drill Mk2 modes.") |
|
355 |
meta["mode"]=0 |
|
356 |
mode=0 |
|
357 |
end |
|
358 |
mode=(meta["mode"]) |
|
359 |
mode=mode+1 |
|
360 |
if mode>=5 then mode=1 end |
|
361 |
minetest.chat_send_player(player_name, "Mining Drill Mk2 mode : "..mode.." - "..mining_drill_mode_text[mode][1] ) |
|
362 |
item["name"]="technic:mining_drill_mk2_"..mode |
|
363 |
meta["mode"]=mode |
|
364 |
item["metadata"]=set_item_meta(meta) |
|
365 |
itemstack:replace(item) |
|
366 |
return itemstack |
|
367 |
end |
|
368 |
|
|
369 |
function mining_drill_mk3_setmode(user,itemstack) |
|
370 |
local player_name=user:get_player_name() |
|
371 |
local item=itemstack:to_table() |
|
372 |
local meta=get_item_meta(item["metadata"]) |
|
373 |
if meta==nil then |
|
374 |
meta={} |
|
375 |
mode=0 |
|
376 |
end |
|
377 |
if meta["mode"]==nil then |
|
378 |
minetest.chat_send_player(player_name,"Hold shift and use to change Mining Drill Mk3 modes.") |
|
379 |
meta["mode"]=0 |
|
380 |
mode=0 |
|
381 |
end |
|
382 |
mode=(meta["mode"]) |
|
383 |
mode=mode+1 |
|
384 |
if mode>=6 then mode=1 end |
|
385 |
minetest.chat_send_player(player_name, "Mining Drill Mk3 mode : "..mode.." - "..mining_drill_mode_text[mode][1] ) |
|
386 |
item["name"]="technic:mining_drill_mk3_"..mode |
|
387 |
meta["mode"]=mode |
|
388 |
item["metadata"]=set_item_meta(meta) |
|
389 |
itemstack:replace(item) |
|
390 |
return itemstack |
|
391 |
end |
ee0765
|
392 |
|