Repository navigation
Expand file tree
/
Copy pathapi.lua
More file actions
85 lines (77 loc) · 1.91 KB
/
Copy pathapi.lua
File metadata and controls
85 lines (77 loc) · 1.91 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
-- Create some tables first so that they're only created once
local mesecon_def = {effector = {
rules = {
{x=0, y=1, z=-1},
{x=0, y=0, z=-1},
{x=0, y=-1, z=-1},
{x=0, y=1, z=1},
{x=0, y=-1, z=1},
{x=0, y=0, z=1},
{x=1, y=0, z=0},
{x=1, y=1, z=0},
{x=1, y=-1, z=0},
{x=-1, y=1, z=0},
{x=-1, y=-1, z=0},
{x=-1, y=0, z=0},
{x=0, y=-1, z=0},
{x=0, y=1, z=0},
{x=0, y=2, z=0},
},
action_on = function(pos, node)
if nuke:can_detonate() then
nuke:ignite(pos, node.name)
end
end,
}}
local node_groups = {dig_immediate = 3, mesecon = 2, falling_node=1}
local entity_groups = {punch_operable = 1}
local sounds = default.node_sound_stone_defaults()
local collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}
local function on_punch(pos, node, player)
local stack = player:get_wielded_item()
local player_name = player:get_player_name()
if stack:get_name() == "default:torch" and
nuke:can_detonate(player_name) then
nuke:ignite(pos, node.name, player_name)
end
end
function nuke:register_nuke(name, description, radius, tiles)
minetest.register_node(name, {
tiles = tiles,
description = description,
sounds = sounds,
groups = node_groups,
on_punch = on_punch,
mesecons = mesecon_def,
})
local e = self.entity
minetest.register_entity(name, {
textures = tiles,
radius = radius,
physical = true,
collisionbox = collisionbox,
visual = "cube",
groups = entity_groups,
health = 10,
timer = 10,
blinktimer = 0,
blinkstatus = true,
on_activate = e.on_activate,
on_step = e.on_step,
on_punch = e.on_punch,
get_staticdata = e.get_staticdata,
smoke_spawner = false,
})
self.cid_names[minetest.get_content_id(name)] = name
if nuke:can_detonate() then
minetest.register_abm({
nodenames = {name},
neighbors = {"group:igniter"},
interval = 1,
chance = 1,
action = function(pos, node)
self:ignite(pos, node.name)
end
})
end
end