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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
-- Crosswalk warning light
minetest.register_abm( {
nodenames = {"infrastructure:crosswalk_warning_light_bright", "infrastructure:crosswalk_warning_light_dark"},
interval = 1,
chance = 1,
action = function(pos, node)
local node = minetest.env:get_node(pos)
if node.name == "infrastructure:crosswalk_warning_light_bright" then
minetest.swap_node(pos, {name = "infrastructure:crosswalk_warning_light_dark", param2 = node.param2})
elseif node.name == "infrastructure:crosswalk_warning_light_dark" then
minetest.swap_node(pos, {name = "infrastructure:crosswalk_warning_light_bright", param2 = node.param2})
end
end
})
function on_off_light(pos, node)
local node = minetest.env:get_node(pos)
if node.name == "infrastructure:crosswalk_warning_light_off" then
minetest.swap_node(pos, {name = "infrastructure:crosswalk_warning_light_bright", param2 = node.param2})
elseif (node.name == "infrastructure:crosswalk_warning_light_dark" or node.name == "infrastructure:crosswalk_warning_light_bright") then
minetest.swap_node(pos, {name = "infrastructure:crosswalk_warning_light_off", param2 = node.param2})
end
end
minetest.register_node("infrastructure:crosswalk_warning_light_off", {
description = "Crosswalk warning light",
inventory_image = "infrastructure_crosswalk_warning_light_front_bright.png",
wield_image = "infrastructure_crosswalk_warning_light_front_bright.png",
tiles = {
"infrastructure_traffic_lights_side.png",
"infrastructure_traffic_lights_side.png",
"infrastructure_traffic_lights_side.png",
"infrastructure_traffic_lights_side.png",
"infrastructure_crosswalk_warning_light_back.png",
"infrastructure_crosswalk_warning_light_front_dark.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky = 3, not_in_creative_inventory = 0},
node_box = {
type = "fixed",
fixed = {
{-5/16, -5/16, -1/8, 5/16, 3/8, 1/8},
{-1/2, -1/2, -1/8, 1/2, 1/2, -1/8},
{-5/16, 1/4, -5/16, 5/16, 5/16, -1/8},
{-5/16, 0, -1/4, -1/4, 1/4, -1/8},
{1/4, 0, -1/4, 5/16, 1/4, -1/8},
{-1/16, -1/4, 1/8, 1/16, 1/4, 3/8},
{-1/4, -1/16, 1/8, 1/4, 1/16, 3/8},
{-1/4, -1/4, 3/8, 1/4, 1/4, 1/2 - 0.001}
}
},
selection_box = {
type = "fixed",
fixed = {
{-5/16, -5/16, -1/8, 5/16, 3/8, 1/8},
{-5/16, 1/4, -5/16, 5/16, 5/16, -1/8},
{-5/16, 0, -1/4, -1/4, 1/4, -1/8},
{1/4, 0, -1/4, 5/16, 1/4, -1/8},
{-1/16, -1/4, 1/8, 1/16, 1/4, 3/8},
{-1/4, -1/16, 1/8, 1/4, 1/16, 3/8},
{-1/4, -1/4, 3/8, 1/4, 1/4, 1/2 - 0.01}
}
},
on_punch = function(pos, node)
on_off_light(pos, node)
end,
mesecons = {effector = {
action_on = function(pos, node)
on_off_light(pos, node)
end,
}}
})
minetest.register_node("infrastructure:crosswalk_warning_light_dark", {
tiles = {
"infrastructure_traffic_lights_side.png",
"infrastructure_traffic_lights_side.png",
"infrastructure_traffic_lights_side.png",
"infrastructure_traffic_lights_side.png",
"infrastructure_crosswalk_warning_light_back.png",
"infrastructure_crosswalk_warning_light_front_dark.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky = 3, not_in_creative_inventory = 1},
drop = "infrastructure:crosswalk_warning_light_off",
node_box = {
type = "fixed",
fixed = {
{-5/16, -5/16, -1/8, 5/16, 3/8, 1/8},
{-1/2, -1/2, -1/8, 1/2, 1/2, -1/8},
{-5/16, 1/4, -5/16, 5/16, 5/16, -1/8},
{-5/16, 0, -1/4, -1/4, 1/4, -1/8},
{1/4, 0, -1/4, 5/16, 1/4, -1/8},
{-1/16, -1/4, 1/8, 1/16, 1/4, 3/8},
{-1/4, -1/16, 1/8, 1/4, 1/16, 3/8},
{-1/4, -1/4, 3/8, 1/4, 1/4, 1/2 - 0.001}
}
},
selection_box = {
type = "fixed",
fixed = {
{-5/16, -5/16, -1/8, 5/16, 3/8, 1/8},
{-5/16, 1/4, -5/16, 5/16, 5/16, -1/8},
{-5/16, 0, -1/4, -1/4, 1/4, -1/8},
{1/4, 0, -1/4, 5/16, 1/4, -1/8},
{-1/16, -1/4, 1/8, 1/16, 1/4, 3/8},
{-1/4, -1/16, 1/8, 1/4, 1/16, 3/8},
{-1/4, -1/4, 3/8, 1/4, 1/4, 1/2 - 0.01}
}
},
on_punch = function(pos, node)
on_off_light(pos, node)
end,
mesecons = {effector = {
action_on = function(pos, node)
on_off_light(pos, node)
end,
}}
})
minetest.register_node("infrastructure:crosswalk_warning_light_bright", {
tiles = {
"infrastructure_traffic_lights_side.png",
"infrastructure_traffic_lights_side.png",
"infrastructure_traffic_lights_side.png",
"infrastructure_traffic_lights_side.png",
"infrastructure_crosswalk_warning_light_back.png",
"infrastructure_crosswalk_warning_light_front_bright.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky = 3, not_in_creative_inventory = 1},
light_source = TRAFFIC_LIGHTS_LIGHT_RANGE,
drop = "infrastructure:crosswalk_warning_light_off",
node_box = {
type = "fixed",
fixed = {
{-5/16, -5/16, -1/8, 5/16, 3/8, 1/8},
{-1/2, -1/2, -1/8, 1/2, 1/2, -1/8},
{-5/16, 1/4, -5/16, 5/16, 5/16, -1/8},
{-5/16, 0, -1/4, -1/4, 1/4, -1/8},
{1/4, 0, -1/4, 5/16, 1/4, -1/8},
{-1/16, -1/4, 1/8, 1/16, 1/4, 3/8},
{-1/4, -1/16, 1/8, 1/4, 1/16, 3/8},
{-1/4, -1/4, 3/8, 1/4, 1/4, 1/2 - 0.001}
}
},
selection_box = {
type = "fixed",
fixed = {
{-5/16, -5/16, -1/8, 5/16, 3/8, 1/8},
{-5/16, 1/4, -5/16, 5/16, 5/16, -1/8},
{-5/16, 0, -1/4, -1/4, 1/4, -1/8},
{1/4, 0, -1/4, 5/16, 1/4, -1/8},
{-1/16, -1/4, 1/8, 1/16, 1/4, 3/8},
{-1/4, -1/16, 1/8, 1/4, 1/16, 3/8},
{-1/4, -1/4, 3/8, 1/4, 1/4, 1/2 - 0.01}
}
},
on_punch = function(pos, node)
on_off_light(pos, node)
end,
mesecons = {effector = {
action_on = function(pos, node)
on_off_light(pos, node)
end,
}}
})
minetest.register_alias("infrastructure:crosswalk_warning_light", "infrastructure:crosswalk_warning_light_off")
|