aboutsummaryrefslogtreecommitdiff
path: root/advtrains_train_track/textures/advtrains_track_swlcr.png
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2017-10-25 11:49:34 +0200
committerorwell96 <orwell@bleipb.de>2017-10-25 11:49:34 +0200
commitf1a8b4f505313f3b2c37ced2dd3402e2740889fb (patch)
tree8bf4bd99774ad7e7f5b48edcd3598bafe722ba57 /advtrains_train_track/textures/advtrains_track_swlcr.png
parent1f9a9062e022c401826155efd3cd45a479d50c15 (diff)
downloadadvtrains-f1a8b4f505313f3b2c37ced2dd3402e2740889fb.tar.gz
advtrains-f1a8b4f505313f3b2c37ced2dd3402e2740889fb.tar.bz2
advtrains-f1a8b4f505313f3b2c37ced2dd3402e2740889fb.zip
Implement multi-occupation in detector.on_node table to finally fix collisions
Diffstat (limited to 'advtrains_train_track/textures/advtrains_track_swlcr.png')
0 files changed, 0 insertions, 0 deletions
#n139'>139 140 141 142 143 144 145 146 147 148 149 150 151 152
-- route_ui.lua
-- User interface for showing and editing routes

local atil = advtrains.interlocking
local ildb = atil.db

-- TODO duplicate
local lntrans = { "A", "B" }
local function sigd_to_string(sigd)
	return minetest.pos_to_string(sigd.p).." / "..lntrans[sigd.s]
end



function atil.show_route_edit_form(pname, sigd, routeid)

	if not minetest.check_player_privs(pname, {train_operator=true, interlocking=true}) then
		minetest.chat_send_player(pname, "Insufficient privileges to use this!")
		return
	end
	
	local tcbs = atil.db.get_tcbs(sigd)
	if not tcbs then return end
	local route = tcbs.routes[routeid]
	if not route then return end
	
	local form = "size[9,10]label[0.5,0.2;Route overview]"
	form = form.."field[0.8,1.2;5.2,1;name;Route name;"..minetest.formspec_escape(route.name).."]"
	form = form.."button[5.5,0.9;1,1;setname;Set]"
	
	-- construct textlist for route information
	local tab = {}
	local function itab(t)
		tab[#tab+1] = minetest.formspec_escape(string.gsub(t, ",", " "))
	end
	itab("TCB "..sigd_to_string(sigd).." ("..tcbs.signal_name..") Route #"..routeid)
	
	-- this code is partially copy-pasted from routesetting.lua
	-- we start at the tc designated by signal
	local c_sigd = sigd
	local i = 1
	local c_tcbs, c_ts_id, c_ts, c_rseg, c_lckp
	while c_sigd and i<=#route do
		c_tcbs = ildb.get_tcbs(c_sigd)
		if not c_tcbs then
			itab("-!- No TCBS at "..sigd_to_string(c_sigd)..". Please reconfigure route!")
			break
		end
		c_ts_id = c_tcbs.ts_id
		if not c_ts_id then
			itab("-!- No track section adjacent to "..sigd_to_string(c_sigd)..". Please reconfigure route!")
			break
		end
		c_ts = ildb.get_ts(c_ts_id)
		
		c_rseg = route[i]
		c_lckp = {}
		
		itab(""..i.." Entry "..sigd_to_string(c_sigd).." -> Sec. "..(c_ts and c_ts.name or "-").." -> Exit "..(c_rseg.next and sigd_to_string(c_rseg.next) or "END"))
		
		if c_rseg.locks then
			for pts, state in pairs(c_rseg.locks) do
				
				local pos = minetest.string_to_pos(pts)
				itab("  Lock: "..pts.." -> "..state)
				if not advtrains.is_passive(pos) then
					itab("-!- No passive component at "..pts..". Please reconfigure route!")
					break
				end
			end
		end
		-- advance
		c_sigd = c_rseg.next
		i = i + 1
	end
	if c_sigd then
		local e_tcbs = ildb.get_tcbs(c_sigd)
		itab("Route end: "..sigd_to_string(c_sigd).." ("..(e_tcbs and e_tcbs.signal_name or "-")..")")
	else
		itab("Route ends on dead-end")
	end
	
	form = form.."textlist[0.5,2;7,4;rtelog;"..table.concat(tab, ",").."]"
	
	form = form.."button[0.5,6;2,1;back;<<< Back to signal]"
	form = form.."button[3.5,6;2,1;aspect;Signal Aspect]"