commit | author | age
|
82cba9
|
1 |
minetest.register_craft({ |
R |
2 |
output = 'technic:nodebreaker_off 1', |
|
3 |
recipe = { |
|
4 |
{'default:wood', 'default:pick_mese','default:wood'}, |
|
5 |
{'default:stone', 'mesecons:piston','default:stone'}, |
|
6 |
{'default:stone', 'mesecons:mesecon','default:stone'}, |
|
7 |
|
|
8 |
} |
|
9 |
}) |
|
10 |
|
|
11 |
node_breaker_on = function(pos, node) |
|
12 |
if node.name == "technic:nodebreaker_off" then |
|
13 |
hacky_swap_node(pos,"technic:nodebreaker_on") |
|
14 |
break_node (pos,node.param2) |
|
15 |
nodeupdate(pos) |
|
16 |
end |
|
17 |
end |
|
18 |
|
|
19 |
node_breaker_off = function(pos, node) |
|
20 |
if node.name == "technic:nodebreaker_on" then |
|
21 |
hacky_swap_node(pos,"technic:nodebreaker_off") |
|
22 |
nodeupdate(pos) |
|
23 |
end |
|
24 |
end |
|
25 |
|
|
26 |
minetest.register_node("technic:nodebreaker_off", { |
|
27 |
description = "Node Breaker", |
|
28 |
tile_images = {"technic_nodebreaker_top_off.png","technic_nodebreaker_bottom_off.png","technic_nodebreaker_side2_off.png","technic_nodebreaker_side1_off.png", |
|
29 |
"technic_nodebreaker_back.png","technic_nodebreaker_front_off.png"}, |
|
30 |
is_ground_content = true, |
|
31 |
paramtype2 = "facedir", |
|
32 |
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1}, |
|
33 |
mesecons= {effector={action_on=node_breaker_on, action_off=node_breaker_off}}, |
|
34 |
sounds = default.node_sound_stone_defaults(), |
|
35 |
on_construct = function(pos) |
|
36 |
local meta = minetest.env:get_meta(pos) |
|
37 |
end, |
|
38 |
|
|
39 |
}) |
|
40 |
|
|
41 |
minetest.register_node("technic:nodebreaker_on", { |
|
42 |
description = "Node Breaker", |
|
43 |
tile_images = {"technic_nodebreaker_top_on.png","technic_nodebreaker_bottom_on.png","technic_nodebreaker_side2_on.png","technic_nodebreaker_side1_on.png", |
|
44 |
"technic_nodebreaker_back.png","technic_nodebreaker_front_on.png"}, |
|
45 |
mesecons= {effector={action_on=node_breaker_on, action_off=node_breaker_off}}, |
|
46 |
is_ground_content = true, |
|
47 |
paramtype2 = "facedir", |
|
48 |
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1,not_in_creative_inventory=1}, |
|
49 |
sounds = default.node_sound_stone_defaults(), |
|
50 |
}) |
|
51 |
|
|
52 |
|
|
53 |
function break_node (pos,n_param) |
|
54 |
local pos1={} |
|
55 |
local pos2={} |
|
56 |
pos1.x=pos.x |
|
57 |
pos1.y=pos.y |
|
58 |
pos1.z=pos.z |
|
59 |
pos2.x=pos.x |
|
60 |
pos2.y=pos.y |
|
61 |
pos2.z=pos.z |
|
62 |
|
|
63 |
--param2 3=x+ 1=x- 2=z+ 0=z- |
|
64 |
local x_velocity=0 |
|
65 |
local z_velocity=0 |
|
66 |
|
|
67 |
if n_param==3 then pos2.x=pos2.x+1 pos1.x=pos1.x-1 x_velocity=-1 end |
|
68 |
if n_param==2 then pos2.z=pos2.z+1 pos1.z=pos1.z-1 z_velocity=-1 end |
|
69 |
if n_param==1 then pos2.x=pos2.x-1 pos1.x=pos1.x+1 x_velocity=1 end |
|
70 |
if n_param==0 then pos2.z=pos2.z-1 pos1.x=pos1.z+1 z_velocity=1 end |
|
71 |
|
|
72 |
local node=minetest.env:get_node(pos2) |
|
73 |
if node.name == "air" then return nil end |
|
74 |
if node.name == "default:lava_source" then return nil end |
|
75 |
if node.name == "default:lava_flowing" then return nil end |
|
76 |
if node.name == "default:water_source" then minetest.env:remove_node(pos2) return nil end |
|
77 |
if node.name == "default:water_flowing" then minetest.env:remove_node(pos2) return nil end |
|
78 |
if node.name == "ignore" then minetest.env:remove_node(pos2) return nil end |
|
79 |
local drops = minetest.get_node_drops(node.name, "default:pick_mese") |
|
80 |
local _, dropped_item |
|
81 |
for _, dropped_item in ipairs(drops) do |
|
82 |
local item1=tube_item({x=pos.x,y=pos.y,z=pos.z},dropped_item) |
|
83 |
item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z} |
|
84 |
item1:setvelocity({x=x_velocity, y=0, z=z_velocity}) |
|
85 |
item1:setacceleration({x=0, y=0, z=0}) |
|
86 |
end |
|
87 |
minetest.env:remove_node(pos2) |
|
88 |
end |
|
89 |
|