summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2020-04-19 18:56:32 -0500
committercheapie <no-email-for-you@example.com>2020-04-19 18:56:32 -0500
commitda5e18e1c67f7c2bcb35da52033b5f00a696216b (patch)
treea5d87266961cd30ed62e2e60d95fd57dd8605927
parentff427f26a7343f2688114a0c51ae031d8ce7626e (diff)
downloadroads-da5e18e1c67f7c2bcb35da52033b5f00a696216b.tar
roads-da5e18e1c67f7c2bcb35da52033b5f00a696216b.tar.gz
roads-da5e18e1c67f7c2bcb35da52033b5f00a696216b.tar.bz2
roads-da5e18e1c67f7c2bcb35da52033b5f00a696216b.tar.xz
roads-da5e18e1c67f7c2bcb35da52033b5f00a696216b.zip
Add new standalone e-bell and some sounds to go with it, and also improve the sound of the "automatic warning device" assembly thing
-rw-r--r--infrastructure/advanced_automatic_warning_device.lua119
-rw-r--r--infrastructure/sounds/infrastructure_ebell.oggbin26398 -> 0 bytes
-rw-r--r--infrastructure/sounds/infrastructure_ebell_de.oggbin0 -> 69347 bytes
-rw-r--r--infrastructure/sounds/infrastructure_ebell_gstype2.oggbin0 -> 49582 bytes
-rw-r--r--infrastructure/sounds/infrastructure_ebell_nl.oggbin0 -> 48042 bytes
-rw-r--r--infrastructure/sounds/infrastructure_ebell_safetrantype1.oggbin0 -> 51393 bytes
-rw-r--r--infrastructure/sounds/infrastructure_ebell_safetrantype3.oggbin0 -> 22153 bytes
-rw-r--r--infrastructure/sounds/infrastructure_ebell_uk.oggbin0 -> 27984 bytes
-rw-r--r--infrastructure/sounds/infrastructure_ebell_wch.oggbin0 -> 50161 bytes
-rw-r--r--infrastructure/textures/infrastructure_ebell_sides.pngbin0 -> 1912 bytes
10 files changed, 118 insertions, 1 deletions
diff --git a/infrastructure/advanced_automatic_warning_device.lua b/infrastructure/advanced_automatic_warning_device.lua
index f6fc08d..0545e6e 100644
--- a/infrastructure/advanced_automatic_warning_device.lua
+++ b/infrastructure/advanced_automatic_warning_device.lua
@@ -2,10 +2,38 @@
infrastructure.sound_handles = {}
+local soundnames = {
+ "gstype2",
+ "safetrantype1",
+ "safetrantype3",
+ "wch",
+ "nl",
+ "uk",
+ "de",
+}
+
+local soundfriendlynames = {
+ ["gstype2"] = "US - GS \"Type 2\"",
+ ["safetrantype1"] = "US - Safetran \"Type 1\"",
+ ["safetrantype3"] = "US - Safetran \"Type 3\"",
+ ["wch"] = "US - WCH",
+ ["nl"] = "Netherlands",
+ ["uk"] = "UK",
+ ["de"] = "Germany",
+}
+
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",
+ local meta = minetest.get_meta(pos)
+ local soundname = "infrastructure_ebell_"
+ local selectedsound = meta:get_string("selectedsound")
+ if selectedsound and string.len(selectedsound) > 0 then
+ soundname = soundname..selectedsound
+ else
+ soundname = soundname.."gstype2"
+ end
+ infrastructure.sound_handles[pos_hash] = minetest.sound_play(soundname,
{pos = pos, gain = AUTOMATIC_WARNING_DEVICE_VOLUME, loop = true, max_hear_distance = 30,})
end
end
@@ -74,6 +102,95 @@ function infrastructure.activate_lights(pos)
end
end
+local function ebell_updateformspec(pos)
+ local meta = minetest.get_meta(pos)
+ local fs = "size[5,3]"
+ fs = fs.."field[0.3,0.3;5,1;channel;Channel;${channel}]"
+ fs = fs.."label[0,0.7;Model (changes will be applied on next start)]"
+ fs = fs.."dropdown[0,1.1;5;sound;"
+ for _,model in ipairs(soundnames) do
+ fs = fs..minetest.formspec_escape(soundfriendlynames[model])..","
+ end
+ fs = string.sub(fs,1,-2)
+ local idx = 1
+ local selected = meta:get_string("selectedsound")
+ for k,v in ipairs(soundnames) do
+ if selected == v then idx = k end
+ end
+ fs = fs..";"..idx.."]"
+ fs = fs.."button_exit[1,2.1;2,1;save;OK]"
+ meta:set_string("formspec",fs)
+end
+
+minetest.register_node("infrastructure:ebell",{
+ description = "Railroad Crossing Electronic Bell",
+ tiles = {
+ "streets_pole.png",
+ "streets_pole.png",
+ "infrastructure_ebell_sides.png",
+ "infrastructure_ebell_sides.png",
+ "infrastructure_ebell_sides.png",
+ "infrastructure_ebell_sides.png",
+ },
+ paramtype = "light",
+ drawtype = "nodebox",
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.2,-0.5,-0.2,0.2,-0.35,0.2,},
+ {-0.12,-0.35,-0.12,0.12,0.2,0.12,},
+ },
+ },
+ groups = {cracky = 3,},
+ on_destruct = infrastructure.stop_bell,
+ after_place_node = ebell_updateformspec,
+ on_receive_fields = function(pos,formname,fields,sender)
+ if not fields.save then return end
+ local name = sender:get_player_name()
+ if minetest.is_protected(pos,name) and not minetest.check_player_privs(name,{protection_bypass=true}) then
+ minetest.record_protection_violation(pos,name)
+ return
+ end
+ local meta = minetest.get_meta(pos)
+ if fields.channel then
+ meta:set_string("channel",fields.channel)
+ end
+ if fields.sound then
+ for _,sound in ipairs(soundnames) do
+ if fields.sound == soundfriendlynames[sound] then
+ meta:set_string("selectedsound",sound)
+ ebell_updateformspec(pos)
+ end
+ end
+ end
+ end,
+ digiline = {
+ wire = {
+ rules = {
+ {x = 1,y = 0,z = 0},
+ {x = -1,y = 0,z = 0},
+ {x = 0,y = 0,z = 1},
+ {x = 0,y = 0,z = -1},
+ {x = 0,y = -1,z = 0},
+ },
+ },
+ 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" or msg == "on" then
+ infrastructure.play_bell(pos)
+ elseif msg == "bell_off" or msg == "off" then
+ infrastructure.stop_bell(pos)
+ end
+ end
+ }
+ }
+})
+
minetest.register_node("infrastructure:automatic_warning_device_top", {
tiles = {
"infrastructure_traffic_lights_side.png",
diff --git a/infrastructure/sounds/infrastructure_ebell.ogg b/infrastructure/sounds/infrastructure_ebell.ogg
deleted file mode 100644
index d59d1b9..0000000
--- a/infrastructure/sounds/infrastructure_ebell.ogg
+++ /dev/null
Binary files differ
diff --git a/infrastructure/sounds/infrastructure_ebell_de.ogg b/infrastructure/sounds/infrastructure_ebell_de.ogg
new file mode 100644
index 0000000..78b1c75
--- /dev/null
+++ b/infrastructure/sounds/infrastructure_ebell_de.ogg
Binary files differ
diff --git a/infrastructure/sounds/infrastructure_ebell_gstype2.ogg b/infrastructure/sounds/infrastructure_ebell_gstype2.ogg
new file mode 100644
index 0000000..be5c09b
--- /dev/null
+++ b/infrastructure/sounds/infrastructure_ebell_gstype2.ogg
Binary files differ
diff --git a/infrastructure/sounds/infrastructure_ebell_nl.ogg b/infrastructure/sounds/infrastructure_ebell_nl.ogg
new file mode 100644
index 0000000..74b24ff
--- /dev/null
+++ b/infrastructure/sounds/infrastructure_ebell_nl.ogg
Binary files differ
diff --git a/infrastructure/sounds/infrastructure_ebell_safetrantype1.ogg b/infrastructure/sounds/infrastructure_ebell_safetrantype1.ogg
new file mode 100644
index 0000000..7aa4828
--- /dev/null
+++ b/infrastructure/sounds/infrastructure_ebell_safetrantype1.ogg
Binary files differ
diff --git a/infrastructure/sounds/infrastructure_ebell_safetrantype3.ogg b/infrastructure/sounds/infrastructure_ebell_safetrantype3.ogg
new file mode 100644
index 0000000..86ba1cc
--- /dev/null
+++ b/infrastructure/sounds/infrastructure_ebell_safetrantype3.ogg
Binary files differ
diff --git a/infrastructure/sounds/infrastructure_ebell_uk.ogg b/infrastructure/sounds/infrastructure_ebell_uk.ogg
new file mode 100644
index 0000000..2063af9
--- /dev/null
+++ b/infrastructure/sounds/infrastructure_ebell_uk.ogg
Binary files differ
diff --git a/infrastructure/sounds/infrastructure_ebell_wch.ogg b/infrastructure/sounds/infrastructure_ebell_wch.ogg
new file mode 100644
index 0000000..1423460
--- /dev/null
+++ b/infrastructure/sounds/infrastructure_ebell_wch.ogg
Binary files differ
diff --git a/infrastructure/textures/infrastructure_ebell_sides.png b/infrastructure/textures/infrastructure_ebell_sides.png
new file mode 100644
index 0000000..7631fb6
--- /dev/null
+++ b/infrastructure/textures/infrastructure_ebell_sides.png
Binary files differ