summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2016-01-12 22:01:46 -0600
committercheapie <no-email-for-you@example.com>2016-01-12 22:01:46 -0600
commit4a3a3f40beabcae10d634e085fc2788a4f402915 (patch)
treedbf4f775350b8e38b2b94fe9140b4bfe599bd625
parent3a9a4bd5f3209a494cc61f05668514c1f793c5e1 (diff)
downloadroads-4a3a3f40beabcae10d634e085fc2788a4f402915.tar
roads-4a3a3f40beabcae10d634e085fc2788a4f402915.tar.gz
roads-4a3a3f40beabcae10d634e085fc2788a4f402915.tar.bz2
roads-4a3a3f40beabcae10d634e085fc2788a4f402915.tar.xz
roads-4a3a3f40beabcae10d634e085fc2788a4f402915.zip
Move automatic warning device to animated textures and fix a bunch of bugs in it
-rw-r--r--infrastructure/advanced_automatic_warning_device.lua814
-rw-r--r--infrastructure/init.lua2
-rw-r--r--infrastructure/textures/infrastructure_automatic_warning_device_middle_center_2.pngbin2670 -> 0 bytes
-rw-r--r--infrastructure/textures/infrastructure_automatic_warning_device_middle_center_3.pngbin2635 -> 0 bytes
-rw-r--r--infrastructure/textures/infrastructure_automatic_warning_device_middle_center_anim.pngbin0 -> 3429 bytes
-rw-r--r--infrastructure/textures/infrastructure_automatic_warning_device_middle_center_off.png (renamed from infrastructure/textures/infrastructure_automatic_warning_device_middle_center_1.png)bin2259 -> 2259 bytes
-rw-r--r--infrastructure/textures/infrastructure_automatic_warning_device_middle_left_2.pngbin501 -> 0 bytes
-rw-r--r--infrastructure/textures/infrastructure_automatic_warning_device_middle_left_anim.pngbin0 -> 795 bytes
-rw-r--r--infrastructure/textures/infrastructure_automatic_warning_device_middle_left_off.png (renamed from infrastructure/textures/infrastructure_automatic_warning_device_middle_left_1.png)bin373 -> 373 bytes
-rw-r--r--infrastructure/textures/infrastructure_automatic_warning_device_middle_right_2.pngbin567 -> 0 bytes
-rw-r--r--infrastructure/textures/infrastructure_automatic_warning_device_middle_right_anim.pngbin0 -> 822 bytes
-rw-r--r--infrastructure/textures/infrastructure_automatic_warning_device_middle_right_off.png (renamed from infrastructure/textures/infrastructure_automatic_warning_device_middle_right_1.png)bin413 -> 413 bytes
12 files changed, 436 insertions, 380 deletions
diff --git a/infrastructure/advanced_automatic_warning_device.lua b/infrastructure/advanced_automatic_warning_device.lua
index 3e2f7a2..b938c07 100644
--- a/infrastructure/advanced_automatic_warning_device.lua
+++ b/infrastructure/advanced_automatic_warning_device.lua
@@ -1,410 +1,464 @@
-- Automatic warning device
-local sound_handles = {}
-local function play_bell(pos)
- local pos_hash = minetest.hash_node_position(pos)
- sound_handles[pos_hash] = minetest.sound_play("infrastructure_ebell",
- {pos = pos, gain = AUTOMATIC_WARNING_DEVICE_VOLUME, loop = true, max_hear_distance = 30,})
+infrastructure.sound_handles = {}
+
+function infrastructure.play_bell(pos)
+ local pos_hash = minetest.hash_node_position(pos)
+ if not infrastructure.sound_handles[pos_hash] then
+ infrastructure.sound_handles[pos_hash] = minetest.sound_play("infrastructure_ebell",
+ {pos = pos, gain = AUTOMATIC_WARNING_DEVICE_VOLUME, loop = true, max_hear_distance = 30,})
+ end
end
-local function stop_bell(pos, node)
+function infrastructure.stop_bell(pos)
local pos_hash = minetest.hash_node_position(pos)
- local sound_handle = sound_handles[pos_hash]
+ local sound_handle = infrastructure.sound_handles[pos_hash]
if sound_handle then
minetest.sound_stop(sound_handle)
- sound_handles[pos_hash] = nil
+ infrastructure.sound_handles[pos_hash] = nil
end
end
- function left_light_direction(pos, param2)
- if param2 == 0 then
- pos.x = pos.x - 1
- elseif param2 == 1 then
- pos.z = pos.z + 1
- elseif param2 == 2 then
- pos.x = pos.x + 1
- elseif param2 == 3 then
- pos.z = pos.z - 1
- end
+function infrastructure.left_light_direction(pos, param2)
+ if param2 == 0 then
+ pos.x = pos.x - 1
+ elseif param2 == 1 then
+ pos.z = pos.z + 1
+ elseif param2 == 2 then
+ pos.x = pos.x + 1
+ elseif param2 == 3 then
+ pos.z = pos.z - 1
end
+end
- function right_light_direction(pos, param2)
- if param2 == 0 then
- pos.x = pos.x + 2
- elseif param2 == 1 then
- pos.z = pos.z - 2
- elseif param2 == 2 then
- pos.x = pos.x - 2
- elseif param2 == 3 then
- pos.z = pos.z + 2
- end
+function infrastructure.right_light_direction(pos, param2)
+ if param2 == 0 then
+ pos.x = pos.x + 2
+ elseif param2 == 1 then
+ pos.z = pos.z - 2
+ elseif param2 == 2 then
+ pos.x = pos.x - 2
+ elseif param2 == 3 then
+ pos.z = pos.z + 2
end
+end
- function lights_enabled(pos, node)
- local node = minetest.env:get_node(pos)
- local param2 = node.param2
- if (node.name == "infrastructure:automatic_warning_device_middle_center_3") then
- minetest.swap_node(pos, {name = "infrastructure:automatic_warning_device_middle_center_2", param2 = node.param2})
- left_light_direction(pos, param2)
- minetest.swap_node(pos, {name = "infrastructure:automatic_warning_device_middle_left_2", param2 = node.param2})
- right_light_direction(pos, param2)
- minetest.swap_node(pos, {name = "infrastructure:automatic_warning_device_middle_right_1", param2 = node.param2})
- elseif node.name == "infrastructure:automatic_warning_device_middle_center_2" then
- minetest.swap_node(pos, {name = "infrastructure:automatic_warning_device_middle_center_3", param2 = node.param2})
- left_light_direction(pos, param2)
- minetest.swap_node(pos, {name = "infrastructure:automatic_warning_device_middle_left_1", param2 = node.param2})
- right_light_direction(pos, param2)
- minetest.swap_node(pos, {name = "infrastructure:automatic_warning_device_middle_right_2", param2 = node.param2})
- end
+function infrastructure.lights_enabled(pos)
+ local node = minetest.get_node(pos)
+ local param2 = node.param2
+ minetest.swap_node(pos, {name = "infrastructure:automatic_warning_device_middle_center_on", param2 = node.param2})
+ infrastructure.left_light_direction(pos, param2)
+ minetest.swap_node(pos, {name = "infrastructure:automatic_warning_device_middle_left_on", param2 = node.param2})
+ infrastructure.right_light_direction(pos, param2)
+ minetest.swap_node(pos, {name = "infrastructure:automatic_warning_device_middle_right_on", param2 = node.param2})
+end
+
+function infrastructure.lights_disabled(pos)
+ local node = minetest.get_node(pos)
+ local param2 = node.param2
+ minetest.swap_node(pos, {name = "infrastructure:automatic_warning_device_middle_center_off", param2 = node.param2})
+ infrastructure.left_light_direction(pos, param2)
+ minetest.swap_node(pos, {name = "infrastructure:automatic_warning_device_middle_left_off", param2 = node.param2})
+ infrastructure.right_light_direction(pos, param2)
+ minetest.swap_node(pos, {name = "infrastructure:automatic_warning_device_middle_right_off", param2 = node.param2})
+end
+
+function infrastructure.activate_lights(pos)
+ pos.y = pos.y + 2
+ local node = minetest.get_node(pos)
+ if node.name == "infrastructure:automatic_warning_device_middle_center_off" then
+ infrastructure.play_bell(pos)
+ infrastructure.lights_enabled(pos)
+ elseif (node.name == "infrastructure:automatic_warning_device_middle_center_on") then
+ infrastructure.stop_bell(pos,node)
+ infrastructure.lights_disabled(pos, node)
end
+end
- function lights_disabled(pos, node)
- local node = minetest.env:get_node(pos)
+minetest.register_node("infrastructure:automatic_warning_device_top", {
+ tiles = {
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_automatic_warning_device_top_side.png",
+ "infrastructure_automatic_warning_device_top_side.png",
+ "infrastructure_automatic_warning_device_top_side.png",
+ "infrastructure_automatic_warning_device_top.png"
+ },
+ on_destruct = stop_bell,
+ drawtype = "nodebox",
+ paramtype = "light",
+ paramtype2 = "facedir",
+ groups = {cracky = 3, not_in_creative_inventory = 1},
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-1/16, -1/2, -1/16, 1/16, 0, 1/16},
+ {-1/8, 0, -1/8, 1/8, 3/8, 1/8},
+ {-1/4, 1/8, -1/4, 1/4, 1/4, 1/4},
+ {-1/2, -1/2, -1/16, 1/2, 0, -1/16},
+ {-1/8, -1/2, -1/16, 1/8, -1/4, 1/8}
+ }
+ },
+ selection_box = {
+ type = "fixed",
+ fixed = {0, 0, 0, 0, 0, 0}
+ }
+})
+
+minetest.register_node("infrastructure:automatic_warning_device_middle_right_on", {
+ tiles = {
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_automatic_warning_device_middle_right_side.png",
+ {name="infrastructure_automatic_warning_device_middle_right_anim.png",animation={type="vertical_frames", aspect_w=64, aspect_h=64, length=1.5}}
+ },
+ drawtype = "nodebox",
+ paramtype = "light",
+ paramtype2 = "facedir",
+ light_source = AUTOMATIC_WARNING_DEVICE_LIGHT_RANGE,
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-1/2, -1/2, -1/16, -1/4, 1/2, -1/16},
+ {-1/2, -5/16, -1/16, -7/16, 1/16, 3/16},
+ {-1/2, 1/32, -5/16, -15/32, 3/32, -1/16},
+ {-15/32, -1/8, -3/16, -13/32, 1/32, -1/16}
+ }
+ },
+ selection_box = {
+ type = "fixed",
+ fixed = {0, 0, 0, 0, 0, 0}
+ }
+})
+
+minetest.register_node("infrastructure:automatic_warning_device_middle_right_off", {
+ tiles = {
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_automatic_warning_device_middle_right_side.png",
+ "infrastructure_automatic_warning_device_middle_right_off.png"
+ },
+ drawtype = "nodebox",
+ paramtype = "light",
+ paramtype2 = "facedir",
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-1/2, -1/2, -1/16, -1/4, 1/2, -1/16},
+ {-1/2, -5/16, -1/16, -7/16, 1/16, 3/16},
+ {-1/2, 1/32, -5/16, -15/32, 3/32, -1/16},
+ {-15/32, -1/8, -3/16, -13/32, 1/32, -1/16}
+ }
+ },
+ selection_box = {
+ type = "fixed",
+ fixed = {0, 0, 0, 0, 0, 0}
+ }
+})
+
+minetest.register_node("infrastructure:automatic_warning_device_middle_left_on", {
+ tiles = {
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_automatic_warning_device_middle_left_side.png",
+ {name="infrastructure_automatic_warning_device_middle_left_anim.png",animation={type="vertical_frames", aspect_w=64, aspect_h=64, length=1.5}}
+ },
+ drawtype = "nodebox",
+ paramtype = "light",
+ paramtype2 = "facedir",
+ light_source = AUTOMATIC_WARNING_DEVICE_LIGHT_RANGE,
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {1/4, -1/2, -1/16, 1/2, 1/2, -1/16},
+ {7/16, -5/16, -1/16, 1/2, 1/16, 3/16},
+ {15/32, 1/32, -5/16, 1/2, 3/32, -1/16},
+ {13/32, -1/8, -3/16, 15/32, 1/32, -1/16}
+ }
+ },
+ selection_box = {
+ type = "fixed",
+ fixed = {0, 0, 0, 0, 0, 0}
+ }
+})
+
+minetest.register_node("infrastructure:automatic_warning_device_middle_left_off", {
+ tiles = {
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_automatic_warning_device_middle_left_side.png",
+ "infrastructure_automatic_warning_device_middle_left_off.png"
+ },
+ drawtype = "nodebox",
+ paramtype = "light",
+ paramtype2 = "facedir",
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {1/4, -1/2, -1/16, 1/2, 1/2, -1/16},
+ {7/16, -5/16, -1/16, 1/2, 1/16, 3/16},
+ {15/32, 1/32, -5/16, 1/2, 3/32, -1/16},
+ {13/32, -1/8, -3/16, 15/32, 1/32, -1/16}
+ }
+ },
+ selection_box = {
+ type = "fixed",
+ fixed = {0, 0, 0, 0, 0, 0}
+ }
+})
+
+minetest.register_node("infrastructure:automatic_warning_device_middle_center_on", {
+ tiles = {
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_automatic_warning_device_middle_center_side.png",
+ "infrastructure_automatic_warning_device_middle_center_side.png",
+ "infrastructure_automatic_warning_device_middle_center_side.png",
+ {name="infrastructure_automatic_warning_device_middle_center_anim.png",animation={type="vertical_frames", aspect_w=64, aspect_h=64, length=1.5}}
+ },
+ drawtype = "nodebox",
+ paramtype = "light",
+ paramtype2 = "facedir",
+ light_source = LIGHT_SOURCE,
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-1/16, -1/2, -1/16, 1/16, 1/2, 1/16},
+ {-1/2, -1/2, -1/16, 1/2, 1/2, -1/16},
+ {-1/2, -5/16, -1/16, -3/16, 1/16, 3/16},
+ {3/16, -5/16, -1/16, 1/2, 1/16, 3/16},
+ {-3/16, -3/16, -1/16, 3/16, -1/16, 1/8},
+ {-1/2, 1/32, -5/16, -7/32, 3/32, -1/16},
+ {-7/32, -1/8, -3/16, -5/32, 1/32, -1/16},
+ {7/32, 1/32, -5/16, 1/2, 3/32, -1/16},
+ {5/32, -1/8, -3/16, 7/32, 1/32, -1/16}
+ }
+ },
+ selection_box = {
+ type = "fixed",
+ fixed = {0, 0, 0, 0, 0, 0}
+ }
+})
+
+
+minetest.register_node("infrastructure:automatic_warning_device_middle_center_off", {
+ tiles = {
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_automatic_warning_device_middle_center_side.png",
+ "infrastructure_automatic_warning_device_middle_center_side.png",
+ "infrastructure_automatic_warning_device_middle_center_side.png",
+ "infrastructure_automatic_warning_device_middle_center_off.png"
+ },
+ drawtype = "nodebox",
+ paramtype = "light",
+ paramtype2 = "facedir",
+ light_source = LIGHT_SOURCE,
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-1/16, -1/2, -1/16, 1/16, 1/2, 1/16},
+ {-1/2, -1/2, -1/16, 1/2, 1/2, -1/16},
+ {-1/2, -5/16, -1/16, -3/16, 1/16, 3/16},
+ {3/16, -5/16, -1/16, 1/2, 1/16, 3/16},
+ {-3/16, -3/16, -1/16, 3/16, -1/16, 1/8},
+ {-1/2, 1/32, -5/16, -7/32, 3/32, -1/16},
+ {-7/32, -1/8, -3/16, -5/32, 1/32, -1/16},
+ {7/32, 1/32, -5/16, 1/2, 3/32, -1/16},
+ {5/32, -1/8, -3/16, 7/32, 1/32, -1/16}
+ }
+ },
+ selection_box = {
+ type = "fixed",
+ fixed = {0, 0, 0, 0, 0, 0}
+ }
+})
+
+
+minetest.register_node("infrastructure:automatic_warning_device_middle", {
+ tiles = {
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_automatic_warning_device_middle_side.png",
+ "infrastructure_automatic_warning_device_middle_side.png",
+ "infrastructure_automatic_warning_device_middle_side.png",
+ "infrastructure_automatic_warning_device_middle.png"
+ },
+ drawtype = "nodebox",
+ paramtype = "light",
+ paramtype2 = "facedir",
+ groups = {cracky = 3, not_in_creative_inventory = 1},
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-1/16, -1/2, -1/16, 1/16, 1/2, 1/16},
+ {-3/8, -3/8, -1/8, 3/8, 3/8, -1/16},
+ {-1/8, -1/8, -1/16, 1/8, 1/8, 1/8}
+ }
+ },
+ selection_box = {
+ type = "fixed",
+ fixed = {0, 0, 0, 0, 0, 0}
+ }
+})
+
+minetest.register_node("infrastructure:automatic_warning_device_bottom", {
+ description = "Automatic warning device",
+ inventory_image = "infrastructure_automatic_warning_device.png",
+ wield_image = "infrastructure_automatic_warning_device.png",
+ tiles = {
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_traffic_lights_side.png",
+ "infrastructure_automatic_warning_device_bottom.png",
+ "infrastructure_automatic_warning_device_bottom.png",
+ "infrastructure_automatic_warning_device_bottom.png",
+ "infrastructure_automatic_warning_device_bottom.png"
+ },
+ drawtype = "nodebox",
+ paramtype = "light",
+ paramtype2 = "facedir",
+ groups = {cracky = 3},
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-1/16, 0, -1/16, 1/16, 1/2, 1/16},
+ {-1/2, -1/2, -1/4, 1/2, -3/8, 1/4},
+ {-1/4, -1/2, -1/2, 1/4, -3/8, 1/2},
+ {-1/8, -3/8, -1/8, 1/8, 0, 1/8}
+ }
+ },
+ selection_box = {
+ type = "fixed",
+ fixed = {
+ -- top
+ {-1/8, 0 + 3, -1/8, 1/8, 3/8 + 3, 1/8},
+ {-1/4, 1/8 + 3, -1/4, 1/4, 1/4 + 3, 1/4},
+ {-1/8, -1/2 + 3, -1/16 + 0.01, 1/8, -1/4 + 3, 1/8},
+ -- middle center, left and right
+ {-9/16, -5/16 + 2, -1/16, -3/16, 1/16 + 2, 3/16},
+ {3/16, -5/16 + 2, -1/16, 9/16, 1/16 + 2, 3/16},
+
+ {-3/16, -3/16 + 2, -1/16 + 0.01, 3/16, -1/16 + 2, 1/8},
+
+ {-1/2, 1/32 + 2, -5/16, -7/32, 3/32 + 2, -1/16 - 0.01},
+ {-7/32, -1/8 + 2, -3/16, -5/32, 1/32 + 2, -1/16 - 0.01},
+ {13/32 - 1, -1/8 + 2, -3/16, 15/32 - 1, 1/32 + 2, -1/16 - 0.01},
+
+ {7/32, 1/32 + 2, -5/16, 1/2, 3/32 + 2, -1/16 - 0.01},
+ {5/32, -1/8 + 2, -3/16, 7/32, 1/32 + 2, -1/16 - 0.01},
+ {-15/32 + 1, -1/8 + 2, -3/16, -13/32 + 1, 1/32 + 2, -1/16 - 0.01},
+ -- middle
+ {-3/8, -3/8 + 1, -1/8, 3/8, 3/8 + 1, -1/16},
+ {-1/8, -1/8 + 1, -1/16, 1/8, 1/8 + 1, 1/8},
+ -- bottom
+ {-1/2, -1/2, -1/4, 1/2, -3/8, 1/4},
+ {-1/4, -1/2, -1/2, 1/4, -3/8, 1/2},
+ {-1/8, -3/8, -1/8, 1/8, 0, 1/8},
+ -- post
+ {-1/16, 0, -1/16, 1/16, 3, 1/16}
+ }
+ },
+
+ on_construct = function(pos)
+ local node = minetest.get_node(pos)
local param2 = node.param2
- minetest.swap_node(pos, {name = "infrastructure:automatic_warning_device_middle_center_1", param2 = node.param2})
- left_light_direction(pos, param2)
- minetest.swap_node(pos, {name = "infrastructure:automatic_warning_device_middle_left_1", param2 = node.param2})
- right_light_direction(pos, param2)
- minetest.swap_node(pos, {name = "infrastructure:automatic_warning_device_middle_right_1", param2 = node.param2})
- end
- function activate_lights(pos, node)
+ local meta = minetest.get_meta(pos)
+ meta:set_string("formspec", "field[channel;Channel;${channel}]")
+
+ pos.y = pos.y + 1
+ node.name = "infrastructure:automatic_warning_device_middle"
+ minetest.set_node(pos, node)
+
pos.y = pos.y + 2
- local node = minetest.env:get_node(pos)
- if node.name == "infrastructure:automatic_warning_device_middle_center_1" then
- play_bell(pos)
- minetest.swap_node(pos, {name = "infrastructure:automatic_warning_device_middle_center_2", param2 = node.param2})
- elseif (node.name == "infrastructure:automatic_warning_device_middle_center_2" or node.name == "infrastructure:automatic_warning_device_middle_center_3") then
- stop_bell(pos,node)
- lights_disabled(pos, node)
- end
- end
+ node.name = "infrastructure:automatic_warning_device_top"
+ minetest.set_node(pos, node)
- minetest.register_abm( {
- nodenames = {"infrastructure:automatic_warning_device_middle_center_2", "infrastructure:automatic_warning_device_middle_center_3"},
- interval = 1,
- chance = 1,
- action = function(pos, node)
- lights_enabled(pos,node)
- end
- })
-
- minetest.register_node("infrastructure:automatic_warning_device_top", {
- tiles = {
- "infrastructure_traffic_lights_side.png",
- "infrastructure_traffic_lights_side.png",
- "infrastructure_automatic_warning_device_top_side.png",
- "infrastructure_automatic_warning_device_top_side.png",
- "infrastructure_automatic_warning_device_top_side.png",
- "infrastructure_automatic_warning_device_top.png"
- },
- on_destruct = stop_bell,
- drawtype = "nodebox",
- paramtype = "light",
- paramtype2 = "facedir",
- groups = {cracky = 3, not_in_creative_inventory = 1},
- node_box = {
- type = "fixed",
- fixed = {
- {-1/16, -1/2, -1/16, 1/16, 0, 1/16},
- {-1/8, 0, -1/8, 1/8, 3/8, 1/8},
- {-1/4, 1/8, -1/4, 1/4, 1/4, 1/4},
- {-1/2, -1/2, -1/16, 1/2, 0, -1/16},
- {-1/8, -1/2, -1/16, 1/8, -1/4, 1/8}
- }
- },
- selection_box = {
- type = "fixed",
- fixed = {0, 0, 0, 0, 0, 0}
- }
- })
-
- for i = 1, 2 do
- local groups = {}
- groups = {cracky = 3, not_in_creative_inventory = 1}
-
- if (i == 1) then
- LIGHT_SOURCE = 0
- else
- LIGHT_SOURCE = AUTOMATIC_WARNING_DEVICE_LIGHT_RANGE
- end
+ pos.y = pos.y - 1
+ node.name = "infrastructure:automatic_warning_device_middle_center_1"
+ minetest.set_node(pos, node)
- minetest.register_node("infrastructure:automatic_warning_device_middle_right_"..tostring(i), {
- tiles = {
- "infrastructure_traffic_lights_side.png",
- "infrastructure_traffic_lights_side.png",
- "infrastructure_traffic_lights_side.png",
- "infrastructure_traffic_lights_side.png",
- "infrastructure_automatic_warning_device_middle_right_side.png",
- "infrastructure_automatic_warning_device_middle_right_"..tostring(i)..".png"
- },
- drawtype = "nodebox",
- paramtype = "light",
- paramtype2 = "facedir",
- light_source = LIGHT_SOURCE,
- node_box = {
- type = "fixed",
- fixed = {
- {-1/2, -1/2, -1/16, -1/4, 1/2, -1/16},
- {-1/2, -5/16, -1/16, -7/16, 1/16, 3/16},
- {-1/2, 1/32, -5/16, -15/32, 3/32, -1/16},
- {-15/32, -1/8, -3/16, -13/32, 1/32, -1/16}
- }
- },
- selection_box = {
- type = "fixed",
- fixed = {0, 0, 0, 0, 0, 0}
- }
- })
-
- minetest.register_node("infrastructure:automatic_warning_device_middle_left_"..tostring(i), {
- tiles = {
- "infrastructure_traffic_lights_side.png",
- "infrastructure_traffic_lights_side.png",
- "infrastructure_traffic_lights_side.png",
- "infrastructure_traffic_lights_side.png",
- "infrastructure_automatic_warning_device_middle_left_side.png",
- "infrastructure_automatic_warning_device_middle_left_"..tostring(i)..".png"
- },
- drawtype = "nodebox",
- paramtype = "light",
- paramtype2 = "facedir",
- light_source = LIGHT_SOURCE,
- node_box = {
- type = "fixed",
- fixed = {
- {1/4, -1/2, -1/16, 1/2, 1/2, -1/16},
- {7/16, -5/16, -1/16, 1/2, 1/16, 3/16},
- {15/32, 1/32, -5/16, 1/2, 3/32, -1/16},
- {13/32, -1/8, -3/16, 15/32, 1/32, -1/16}
- }
- },
- selection_box = {
- type = "fixed",
- fixed = {0, 0, 0, 0, 0, 0}
- }
- })
- end
+ infrastructure.left_light_direction(pos, param2)
+ node.name = "infrastructure:automatic_warning_device_middle_left_1"
+ minetest.set_node(pos, node)
+
+ infrastructure.right_light_direction(pos, param2)
+ node.name = "infrastructure:automatic_warning_device_middle_right_1"
+ minetest.set_node(pos, node)
+ end,
- for i = 1, 3 do
- local groups = {}
- groups = {cracky = 3, not_in_creative_inventory = 1}
+ on_destruct = function(pos)
+ local node = minetest.get_node(pos)
+ local param2 = node.param2
+ pos.y=pos.y+2
+ infrastructure.stop_bell(pos, node)
+ pos.y=pos.y-2
- if (i == 1) then
- LIGHT_SOURCE = 0
- else
- LIGHT_SOURCE = AUTOMATIC_WARNING_DEVICE_LIGHT_RANGE
+ for i = 1, 3 do
+ pos.y = pos.y + 1
+ minetest.remove_node(pos)
end
- minetest.register_node("infrastructure:automatic_warning_device_middle_center_"..tostring(i), {
- tiles = {
- "infrastructure_traffic_lights_side.png",
- "infrastructure_traffic_lights_side.png",
- "infrastructure_automatic_warning_device_middle_center_side.png",
- "infrastructure_automatic_warning_device_middle_center_side.png",
- "infrastructure_automatic_warning_device_middle_center_side.png",
- "infrastructure_automatic_warning_device_middle_center_"..tostring(i)..".png"
- },
- drawtype = "nodebox",
- paramtype = "light",
- paramtype2 = "facedir",
- light_source = LIGHT_SOURCE,
- node_box = {
- type = "fixed",
- fixed = {
- {-1/16, -1/2, -1/16, 1/16, 1/2, 1/16},
- {-1/2, -1/2, -1/16, 1/2, 1/2, -1/16},
- {-1/2, -5/16, -1/16, -3/16, 1/16, 3/16},
- {3/16, -5/16, -1/16, 1/2, 1/16, 3/16},
- {-3/16, -3/16, -1/16, 3/16, -1/16, 1/8},
- {-1/2, 1/32, -5/16, -7/32, 3/32, -1/16},
- {-7/32, -1/8, -3/16, -5/32, 1/32, -1/16},
- {7/32, 1/32, -5/16, 1/2, 3/32, -1/16},
- {5/32, -1/8, -3/16, 7/32, 1/32, -1/16}
- }
- },
- selection_box = {
- type = "fixed",
- fixed = {0, 0, 0, 0, 0, 0}
- }
- })
- end
+ pos.y = pos.y - 1
- minetest.register_node("infrastructure:automatic_warning_device_middle", {
- tiles = {
- "infrastructure_traffic_lights_side.png",
- "infrastructure_traffic_lights_side.png",
- "infrastructure_automatic_warning_device_middle_side.png",
- "infrastructure_automatic_warning_device_middle_side.png",
- "infrastructure_automatic_warning_device_middle_side.png",
- "infrastructure_automatic_warning_device_middle.png"
- },
- drawtype = "nodebox",
- paramtype = "light",
- paramtype2 = "facedir",
- groups = {cracky = 3, not_in_creative_inventory = 1},
- node_box = {
- type = "fixed",
- fixed = {
- {-1/16, -1/2, -1/16, 1/16, 1/2, 1/16},
- {-3/8, -3/8, -1/8, 3/8, 3/8, -1/16},
- {-1/8, -1/8, -1/16, 1/8, 1/8, 1/8}
- }
- },
- selection_box = {
- type = "fixed",
- fixed = {0, 0, 0, 0, 0, 0}
- }
- })
-
- minetest.register_node("infrastructure:automatic_warning_device_bottom", {
- description = "Automatic warning device",
- inventory_image = "infrastructure_automatic_warning_device.png",
- wield_image = "infrastructure_automatic_warning_device.png",
- tiles = {
- "infrastructure_traffic_lights_side.png",
- "infrastructure_traffic_lights_side.png",
- "infrastructure_automatic_warning_device_bottom.png",
- "infrastructure_automatic_warning_device_bottom.png",
- "infrastructure_automatic_warning_device_bottom.png",
- "infrastructure_automatic_warning_device_bottom.png"
- },
- drawtype = "nodebox",
- paramtype = "light",
- paramtype2 = "facedir",
- groups = {cracky = 3},
- node_box = {
- type = "fixed",
- fixed = {
- {-1/16, 0, -1/16, 1/16, 1/2, 1/16},
- {-1/2, -1/2, -1/4, 1/2, -3/8, 1/4},
- {-1/4, -1/2, -1/2, 1/4, -3/8, 1/2},
- {-1/8, -3/8, -1/8, 1/8, 0, 1/8}
- }
- },
- selection_box = {
- type = "fixed",
- fixed = {
- -- top
- {-1/8, 0 + 3, -1/8, 1/8, 3/8 + 3, 1/8},
- {-1/4, 1/8 + 3, -1/4, 1/4, 1/4 + 3, 1/4},
- {-1/8, -1/2 + 3, -1/16 + 0.01, 1/8, -1/4 + 3, 1/8},
- -- middle center, left and right
- {-9/16, -5/16 + 2, -1/16, -3/16, 1/16 + 2, 3/16},
- {3/16, -5/16 + 2, -1/16, 9/16, 1/16 + 2, 3/16},
-
- {-3/16, -3/16 + 2, -1/16 + 0.01, 3/16, -1/16 + 2, 1/8},
-
- {-1/2, 1/32 + 2, -5/16, -7/32, 3/32 + 2, -1/16 - 0.01},
- {-7/32, -1/8 + 2, -3/16, -5/32, 1/32 + 2, -1/16 - 0.01},
- {13/32 - 1, -1/8 + 2, -3/16, 15/32 - 1, 1/32 + 2, -1/16 - 0.01},
-
- {7/32, 1/32 + 2, -5/16, 1/2, 3/32 + 2, -1/16 - 0.01},
- {5/32, -1/8 + 2, -3/16, 7/32, 1/32 + 2, -1/16 - 0.01},
- {-15/32 + 1, -1/8 + 2, -3/16, -13/32 + 1, 1/32 + 2, -1/16 - 0.01},
- -- middle
- {-3/8, -3/8 + 1, -1/8, 3/8, 3/8 + 1, -1/16},
- {-1/8, -1/8 + 1, -1/16, 1/8, 1/8 + 1, 1/8},
- -- bottom
- {-1/2, -1/2, -1/4, 1/2, -3/8, 1/4},
- {-1/4, -1/2, -1/2, 1/4, -3/8, 1/2},
- {-1/8, -3/8, -1/8, 1/8, 0, 1/8},
- -- post
- {-1/16, 0, -1/16, 1/16, 3, 1/16}
- }
- },
-
- on_construct = function(pos)
- local node = minetest.env:get_node(pos)
- local param2 = node.param2
-
- local meta = minetest.get_meta(pos)
- meta:set_string("formspec", "field[channel;Channel;${channel}]")
-
- pos.y = pos.y + 1
- node.name = "infrastructure:automatic_warning_device_middle"
- minetest.env:add_node(pos, node)
-
- pos.y = pos.y + 2
- node.name = "infrastructure:automatic_warning_device_top"
- minetest.env:add_node(pos, node)
-
- pos.y = pos.y - 1
- node.name = "infrastructure:automatic_warning_device_middle_center_1"
- minetest.env:add_node(pos, node)
-
- left_light_direction(pos, param2)
- node.name = "infrastructure:automatic_warning_device_middle_left_1"
- minetest.env:add_node(pos, node)
-
- right_light_direction(pos, param2)
- node.name = "infrastructure:automatic_warning_device_middle_right_1"
- minetest.env:add_node(pos, node)
- end,
-
- on_destruct = function(pos)
- local node = minetest.env:get_node(pos)
- local param2 = node.param2
- pos.y=pos.y+2
- stop_bell(pos, node)
- pos.y=pos.y-2
-
- for i = 1, 3 do
- pos.y = pos.y + 1
- minetest.env:remove_node(pos)
- end
+ infrastructure.left_light_direction(pos, param2)
+ minetest.remove_node(pos)
+
+ infrastructure.right_light_direction(pos, param2)
+ minetest.remove_node(pos)
+ end,
- pos.y = pos.y - 1
+ on_punch = function(pos, node)
+ infrastructure.activate_lights(pos, node)
+ end,
+
+ on_receive_fields = function(pos, formname, fields, sender)
+ if (fields.channel) then
+ minetest.get_meta(pos):set_string("channel", fields.channel)
+ minetest.get_meta(pos):set_string("state", "Off")
+ end
+ end,
+
+ digiline = {
+ receptor = {},
+ effector = {
+ action = function(pos, node, channel, msg)
+ local setchan = minetest.get_meta(pos):get_string("channel")
+ if setchan ~= channel then
+ return
+ end
+ if (msg=="bell_on") then
+ infrastructure.play_bell(pos)
+ elseif (msg=="bell_off") then
+ infrastructure.stop_bell(pos)
+ elseif (msg=="lights_on") then
+ pos.y = pos.y+2
+ infrastructure.lights_enabled(pos)
+ elseif (msg=="lights_off") then
+ pos.y = pos.y+2
+ infrastructure.lights_disabled(pos)
+ end
+ end
+ }
+ }
+})
- left_light_direction(pos, param2)
- minetest.env:remove_node(pos)
- right_light_direction(pos, param2)
- minetest.env:remove_node(pos)
- end,
- on_punch = function(pos, node)
- activate_lights(pos, node)
- end,
- on_receive_fields = function(pos, formname, fields, sender)
- if (fields.channel) then
- minetest.get_meta(pos):set_string("channel", fields.channel)
- minetest.get_meta(pos):set_string("state", "Off")
- end
- end,
-
- digiline = {
- receptor = {},
- effector = {
- action = function(pos, node, channel, msg)
- local setchan = minetest.get_meta(pos):get_string("channel")
- if setchan ~= channel then
- return
- end
- if (msg=="bell_on") then
- play_bell(pos)
- elseif (msg=="bell_off") then
- stop_bell(pos,node)
- elseif (msg=="lights_on") then
- pos.y = pos.y + 2
- local node = minetest.env:get_node(pos)
- if node.name == "infrastructure:automatic_warning_device_middle_center_1" then
- minetest.swap_node(pos, {name = "infrastructure:automatic_warning_device_middle_center_2", param2 = node.param2})
- end
- elseif (msg=="lights_off") then
- pos.y = pos.y + 2
- local node = minetest.env:get_node(pos)
- if (node.name == "infrastructure:automatic_warning_device_middle_center_2" or node.name == "infrastructure:automatic_warning_device_middle_center_3") then
- lights_disabled(pos, node)
- end
- end
- end
- }
- }
- })
-
-
-
-
- minetest.register_alias("infrastructure:automatic_warning_device", "infrastructure:automatic_warning_device_bottom")
- minetest.register_alias("awd", "infrastructure:automatic_warning_device_bottom")
+minetest.register_alias("infrastructure:automatic_warning_device", "infrastructure:automatic_warning_device_bottom")
+minetest.register_alias("awd", "infrastructure:automatic_warning_device_bottom")
+minetest.register_alias("infrastructure:automatic_warning_device_middle_left_1","infrastructure:automatic_warning_device_middle_left_off")
+minetest.register_alias("infrastructure:automatic_warning_device_middle_left_2","infrastructure:automatic_warning_device_middle_left_off")
+minetest.register_alias("infrastructure:automatic_warning_device_middle_right_1","infrastructure:automatic_warning_device_middle_right_off")
+minetest.register_alias("infrastructure:automatic_warning_device_middle_right_2","infrastructure:automatic_warning_device_middle_right_off")
+minetest.register_alias("infrastructure:automatic_warning_device_middle_center_1","infrastructure:automatic_warning_device_middle_center_off")
+minetest.register_alias("infrastructure:automatic_warning_device_middle_center_2","infrastructure:automatic_warning_device_middle_center_off")
+minetest.register_alias("infrastructure:automatic_warning_device_middle_center_3","infrastructure:automatic_warning_device_middle_center_off")
diff --git a/infrastructure/init.lua b/infrastructure/init.lua
index 8b79b00..76d94f3 100644
--- a/infrastructure/init.lua
+++ b/infrastructure/init.lua
@@ -1,3 +1,5 @@
+infrastructure = {}
+
-- Load settings
dofile(minetest.get_modpath("infrastructure").."/settings.lua")
diff --git a/infrastructure/textures/infrastructure_automatic_warning_device_middle_center_2.png b/infrastructure/textures/infrastructure_automatic_warning_device_middle_center_2.png
deleted file mode 100644
index 9e38834..0000000
--- a/infrastructure/textures/infrastructure_automatic_warning_device_middle_center_2.png
+++ /dev/null
Binary files differ
diff --git a/infrastructure/textures/infrastructure_automatic_warning_device_middle_center_3.png b/infrastructure/textures/infrastructure_automatic_warning_device_middle_center_3.png
deleted file mode 100644
index f741647..0000000
--- a/infrastructure/textures/infrastructure_automatic_warning_device_middle_center_3.png
+++ /dev/null
Binary files differ
diff --git a/infrastructure/textures/infrastructure_automatic_warning_device_middle_center_anim.png b/infrastructure/textures/infrastructure_automatic_warning_device_middle_center_anim.png
new file mode 100644
index 0000000..575ebca
--- /dev/null
+++ b/infrastructure/textures/infrastructure_automatic_warning_device_middle_center_anim.png
Binary files differ
diff --git a/infrastructure/textures/infrastructure_automatic_warning_device_middle_center_1.png b/infrastructure/textures/infrastructure_automatic_warning_device_middle_center_off.png
index ac85b26..ac85b26 100644
--- a/infrastructure/textures/infrastructure_automatic_warning_device_middle_center_1.png
+++ b/infrastructure/textures/infrastructure_automatic_warning_device_middle_center_off.png
Binary files differ
diff --git a/infrastructure/textures/infrastructure_automatic_warning_device_middle_left_2.png b/infrastructure/textures/infrastructure_automatic_warning_device_middle_left_2.png
deleted file mode 100644
index dbb2428..0000000
--- a/infrastructure/textures/infrastructure_automatic_warning_device_middle_left_2.png
+++ /dev/null
Binary files differ
diff --git a/infrastructure/textures/infrastructure_automatic_warning_device_middle_left_anim.png b/infrastructure/textures/infrastructure_automatic_warning_device_middle_left_anim.png
new file mode 100644
index 0000000..6d6851b
--- /dev/null
+++ b/infrastructure/textures/infrastructure_automatic_warning_device_middle_left_anim.png
Binary files differ
diff --git a/infrastructure/textures/infrastructure_automatic_warning_device_middle_left_1.png b/infrastructure/textures/infrastructure_automatic_warning_device_middle_left_off.png
index 3acc761..3acc761 100644
--- a/infrastructure/textures/infrastructure_automatic_warning_device_middle_left_1.png
+++ b/infrastructure/textures/infrastructure_automatic_warning_device_middle_left_off.png
Binary files differ
diff --git a/infrastructure/textures/infrastructure_automatic_warning_device_middle_right_2.png b/infrastructure/textures/infrastructure_automatic_warning_device_middle_right_2.png
deleted file mode 100644
index d1b150e..0000000
--- a/infrastructure/textures/infrastructure_automatic_warning_device_middle_right_2.png
+++ /dev/null
Binary files differ
diff --git a/infrastructure/textures/infrastructure_automatic_warning_device_middle_right_anim.png b/infrastructure/textures/infrastructure_automatic_warning_device_middle_right_anim.png
new file mode 100644
index 0000000..5517f0d
--- /dev/null
+++ b/infrastructure/textures/infrastructure_automatic_warning_device_middle_right_anim.png
Binary files differ
diff --git a/infrastructure/textures/infrastructure_automatic_warning_device_middle_right_1.png b/infrastructure/textures/infrastructure_automatic_warning_device_middle_right_off.png
index d3e378a..d3e378a 100644
--- a/infrastructure/textures/infrastructure_automatic_warning_device_middle_right_1.png
+++ b/infrastructure/textures/infrastructure_automatic_warning_device_middle_right_off.png
Binary files differ