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
|
minetest.register_node(":firealarm:hornstrobe_off",{
description = "Fire Alarm Horn/Strobe",
groups = { oddly_breakable_by_hand = 1 },
tiles = {
"firealarm_hornstrobe_top.png",
"firealarm_hornstrobe_top.png",
"firealarm_hornstrobe_side.png",
"firealarm_hornstrobe_side.png",
"firealarm_hornstrobe_back.png",
"firealarm_hornstrobe_front_off.png",
},
paramtype = "light",
paramtype2 = "facedir",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-0.15,-0.02,0.4,0.18,0.37,0.5},
},
},
on_punch = function(pos,_,player)
local name = player:get_player_name()
minetest.chat_send_player(name,string.format("Position: %d,%d,%d",pos.x,pos.y,pos.z))
end,
after_place_node = function(pos)
firealarm.setDevInfo("notification",pos,{strobeActive = false,hornActive = false})
end,
after_dig_node = function(pos)
firealarm.setDevInfo("notification",pos,nil)
end,
})
local hornstrobeOnFrontTexture = "[combine:32x320"..
":0,0=firealarm_hornstrobe_front_on.png"..
":0,32=firealarm_hornstrobe_front_off.png"..
":0,64=firealarm_hornstrobe_front_off.png"..
":0,96=firealarm_hornstrobe_front_off.png"..
":0,128=firealarm_hornstrobe_front_off.png"..
":0,160=firealarm_hornstrobe_front_off.png"..
":0,192=firealarm_hornstrobe_front_off.png"..
":0,224=firealarm_hornstrobe_front_off.png"..
":0,256=firealarm_hornstrobe_front_off.png"..
":0,288=firealarm_hornstrobe_front_off.png"
minetest.register_node(":firealarm:hornstrobe_on",{
drop = "firealarm:hornstrobe_off",
description = "Fire Alarm Horn/Strobe (on state - you hacker you!)",
groups = { oddly_breakable_by_hand = 1,not_in_creative_inventory = 1 },
tiles = {
"firealarm_hornstrobe_top.png",
"firealarm_hornstrobe_top.png",
"firealarm_hornstrobe_side.png",
"firealarm_hornstrobe_side.png",
"firealarm_hornstrobe_back.png",
{
name = hornstrobeOnFrontTexture,
animation =
{
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 1,
},
}
},
paramtype = "light",
paramtype2 = "facedir",
light_source = 8,
use_texture_alpha = true,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-0.5,-0.5,0.4,0.5,0.5,0.401},
{-0.15,-0.02,0.4,0.18,0.37,0.5},
},
},
})
minetest.register_abm({
label = "Update horn/strobe state",
nodenames = {"firealarm:hornstrobe_off","firealarm:hornstrobe_on"},
interval = 4,
chance = 1,
action = function(pos,node)
local devInfo = firealarm.getDevInfo("notification",pos)
if not devInfo then return end
if node.name == "firealarm:hornstrobe_off" and devInfo.strobeActive then
node.name = "firealarm:hornstrobe_on"
minetest.set_node(pos,node)
elseif node.name == "firealarm:hornstrobe_on" and not devInfo.strobeActive then
node.name = "firealarm:hornstrobe_off"
minetest.set_node(pos,node)
end
if devInfo.hornActive then
minetest.sound_play("firealarm_horn",{pos=pos})
end
end,
})
|