diff options
Diffstat (limited to 'infrastructure')
| -rw-r--r-- | infrastructure/advanced_automatic_warning_device.lua | 119 | ||||
| -rw-r--r-- | infrastructure/sounds/infrastructure_ebell.ogg | bin | 26398 -> 0 bytes | |||
| -rw-r--r-- | infrastructure/sounds/infrastructure_ebell_de.ogg | bin | 0 -> 69347 bytes | |||
| -rw-r--r-- | infrastructure/sounds/infrastructure_ebell_gstype2.ogg | bin | 0 -> 49582 bytes | |||
| -rw-r--r-- | infrastructure/sounds/infrastructure_ebell_nl.ogg | bin | 0 -> 48042 bytes | |||
| -rw-r--r-- | infrastructure/sounds/infrastructure_ebell_safetrantype1.ogg | bin | 0 -> 51393 bytes | |||
| -rw-r--r-- | infrastructure/sounds/infrastructure_ebell_safetrantype3.ogg | bin | 0 -> 22153 bytes | |||
| -rw-r--r-- | infrastructure/sounds/infrastructure_ebell_uk.ogg | bin | 0 -> 27984 bytes | |||
| -rw-r--r-- | infrastructure/sounds/infrastructure_ebell_wch.ogg | bin | 0 -> 50161 bytes | |||
| -rw-r--r-- | infrastructure/textures/infrastructure_ebell_sides.png | bin | 0 -> 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.oggBinary files differ deleted file mode 100644 index d59d1b9..0000000 --- a/infrastructure/sounds/infrastructure_ebell.ogg +++ /dev/null diff --git a/infrastructure/sounds/infrastructure_ebell_de.ogg b/infrastructure/sounds/infrastructure_ebell_de.oggBinary files differ new file mode 100644 index 0000000..78b1c75 --- /dev/null +++ b/infrastructure/sounds/infrastructure_ebell_de.ogg diff --git a/infrastructure/sounds/infrastructure_ebell_gstype2.ogg b/infrastructure/sounds/infrastructure_ebell_gstype2.oggBinary files differ new file mode 100644 index 0000000..be5c09b --- /dev/null +++ b/infrastructure/sounds/infrastructure_ebell_gstype2.ogg diff --git a/infrastructure/sounds/infrastructure_ebell_nl.ogg b/infrastructure/sounds/infrastructure_ebell_nl.oggBinary files differ new file mode 100644 index 0000000..74b24ff --- /dev/null +++ b/infrastructure/sounds/infrastructure_ebell_nl.ogg diff --git a/infrastructure/sounds/infrastructure_ebell_safetrantype1.ogg b/infrastructure/sounds/infrastructure_ebell_safetrantype1.oggBinary files differ new file mode 100644 index 0000000..7aa4828 --- /dev/null +++ b/infrastructure/sounds/infrastructure_ebell_safetrantype1.ogg diff --git a/infrastructure/sounds/infrastructure_ebell_safetrantype3.ogg b/infrastructure/sounds/infrastructure_ebell_safetrantype3.oggBinary files differ new file mode 100644 index 0000000..86ba1cc --- /dev/null +++ b/infrastructure/sounds/infrastructure_ebell_safetrantype3.ogg diff --git a/infrastructure/sounds/infrastructure_ebell_uk.ogg b/infrastructure/sounds/infrastructure_ebell_uk.oggBinary files differ new file mode 100644 index 0000000..2063af9 --- /dev/null +++ b/infrastructure/sounds/infrastructure_ebell_uk.ogg diff --git a/infrastructure/sounds/infrastructure_ebell_wch.ogg b/infrastructure/sounds/infrastructure_ebell_wch.oggBinary files differ new file mode 100644 index 0000000..1423460 --- /dev/null +++ b/infrastructure/sounds/infrastructure_ebell_wch.ogg diff --git a/infrastructure/textures/infrastructure_ebell_sides.png b/infrastructure/textures/infrastructure_ebell_sides.pngBinary files differ new file mode 100644 index 0000000..7631fb6 --- /dev/null +++ b/infrastructure/textures/infrastructure_ebell_sides.png | 
