diff options
| author | webdesigner97 <Christian_D_97@gmx.de> | 2014-05-30 17:09:29 +0200 | 
|---|---|---|
| committer | webdesigner97 <Christian_D_97@gmx.de> | 2014-05-30 17:09:29 +0200 | 
| commit | 18418ff0a83cde5ccbc96b403ddbc4482328efd0 (patch) | |
| tree | 68c803bed34c4f3c17f76f6b0d69968f980c5faa | |
| parent | d0b3089d946cc1ed1fcdd0beb840aa9c2ae4fbdd (diff) | |
| download | roads-18418ff0a83cde5ccbc96b403ddbc4482328efd0.tar roads-18418ff0a83cde5ccbc96b403ddbc4482328efd0.tar.gz roads-18418ff0a83cde5ccbc96b403ddbc4482328efd0.tar.bz2 roads-18418ff0a83cde5ccbc96b403ddbc4482328efd0.tar.xz roads-18418ff0a83cde5ccbc96b403ddbc4482328efd0.zip | |
Fix trafficlight conversion
| -rw-r--r-- | trafficlight/init.lua | 1 | ||||
| -rw-r--r-- | trafficlight/old2new.lua | 48 | 
2 files changed, 34 insertions, 15 deletions
| diff --git a/trafficlight/init.lua b/trafficlight/init.lua index d594e75..1257f2c 100644 --- a/trafficlight/init.lua +++ b/trafficlight/init.lua @@ -1,6 +1,7 @@  --[[  	StreetsMod: inDev Trafficlights  ]] +dofile(streets.modpath .. "/../trafficlight/old2new.lua")  streets.tlBox =	{  	--[[ Thank you, rubenwardy, for your awesome NodeboxEditor! Not perfect, but still great! ]] diff --git a/trafficlight/old2new.lua b/trafficlight/old2new.lua index 665e4b9..04e111f 100644 --- a/trafficlight/old2new.lua +++ b/trafficlight/old2new.lua @@ -1,16 +1,23 @@  --[[  	StreetsMod: Convert old trafficlights  ]] +minetest.register_node(":streets:trafficlight_bottom", { +	diggable = false, +	pointable = false, +	drawtype = "airlike", +	description = "I'm an old node, please drop me" +})  minetest.register_abm({ -	nodenames = {"streets:traficlight_bottom"}, -	interval = 2, -	chance = 1 +	nodenames = {"streets:trafficlight_bottom"}, +	interval = 1, +	chance = 1,  	action = function(pos, node) +		minetest.log("action", "Converting trafficlight at position " .. minetest.pos_to_string(pos))  		-- Replace controller with distributor -		pos.y = pos.y - 1 +		pos.y = pos.y - 2  		minetest.set_node(pos, {name = "streets:digiline_distributor"})  		-- Change bottom pole -		pos.y = pos.y + 1 +		pos.y = pos.y + 2  		minetest.set_node(pos, {name = "streets:bigpole", param2 = 2})  		-- Change middle pole  		pos.y = pos.y + 1 @@ -18,22 +25,33 @@ minetest.register_abm({  		-- Change the top  		pos.y = pos.y + 1  		local fd = minetest.get_node(pos).param2 -		local nn = minetest.get_node(pos).name  		local ch = minetest.get_meta(pos):get_string("channel")  		minetest.set_node(pos, {name = "streets:bigpole", param2 = 2})  		-- Place new top  		if fd == 1 then -			minetest.set_node({x = pos.x, y = pos.y, z = pos.z + 1}, {name = nn, param2 = fd}) -			minetest.get_meta(pos):set_string("channel", ch) +			minetest.set_node({x = pos.x - 1, y = pos.y, z = pos.z}, {name = "streets:trafficlight_top_warn", param2 = fd}) +			local meta = minetest.get_meta({x = pos.x - 1, y = pos.y, z = pos.z}) +			meta:set_string("channel", ch) +			meta:set_string("state", "warn") +			meta:set_string("formspec", "field[channel;Channel;${channel}]")  		elseif fd == 2 then -			minetest.set_node({x = pos.x, y = pos.y, z = pos.z - 1}, {name = nn, param2 = fd}) -			minetest.get_meta(pos):set_string("channel", ch) +			minetest.set_node({x = pos.x, y = pos.y, z = pos.z + 1}, {name = "streets:trafficlight_top_warn", param2 = fd}) +			local meta = minetest.get_meta({x = pos.x, y = pos.y, z = pos.z + 1}) +			meta:set_string("channel", ch) +			meta:set_string("state", "warn") +			meta:set_string("formspec", "field[channel;Channel;${channel}]")  		elseif fd == 3 then -			minetest.set_node({x = pos.x + 1, y = pos.y, z = pos.z}, {name = nn, param2 = fd}) -			minetest.get_meta(pos):set_string("channel", ch) -		elseif fd == 4 then -			minetest.set_node({x = pos.x - 1, y = pos.y, z = pos.z}, {name = nn, param2 = fd}) -			minetest.get_meta(pos):set_string("channel", ch) +			minetest.set_node({x = pos.x + 1, y = pos.y, z = pos.z}, {name = "streets:trafficlight_top_warn", param2 = fd}) +			local meta = minetest.get_meta({x = pos.x + 1, y = pos.y, z = pos.z}) +			meta:set_string("channel", ch) +			meta:set_string("state", "warn") +			meta:set_string("formspec", "field[channel;Channel;${channel}]") +		elseif fd == 0 then +			minetest.set_node({x = pos.x, y = pos.y, z = pos.z - 1}, {name = "streets:trafficlight_top_warn", param2 = fd}) +			local meta = minetest.get_meta({x = pos.x, y = pos.y, z = pos.z - 1}) +			meta:set_string("channel", ch) +			meta:set_string("state", "warn") +			meta:set_string("formspec", "field[channel;Channel;${channel}]")  		end  	end  })
\ No newline at end of file | 
