aboutsummaryrefslogtreecommitdiff
path: root/src/objdef.h
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2018-03-29 21:44:13 +0200
committerSmallJoker <mk939@ymail.com>2018-06-03 17:32:00 +0200
commitfe41725e5027e90787f18088be82839760cccbb5 (patch)
treebca04b46d4e17759fd9757e5a06244e1d5ad94d3 /src/objdef.h
parent5624cf750f0c9de872dfff51eefd86575fa9c764 (diff)
downloadminetest-fe41725e5027e90787f18088be82839760cccbb5.tar.gz
minetest-fe41725e5027e90787f18088be82839760cccbb5.tar.bz2
minetest-fe41725e5027e90787f18088be82839760cccbb5.zip
core.rotate_node: Do not trigger after_place_node (#6900)
Diffstat (limited to 'src/objdef.h')
0 files changed, 0 insertions, 0 deletions
/a> 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
-- ars.lua
-- automatic routesetting

--[[
	The "ARS table" and its effects:
	Every route has (or can have) an associated ARS table. This can either be
	ars = { [n] = {ln="<line>"}/{rc="<routingcode>"}/{c="<a comment>"} }
	a list of rules involving either line or routingcode matchers (or comments, those are ignored)
	The first matching rule determines the route to set.
	- or -
	ars = {default = true}
	this means that all trains that no other rule matches on should use this route
	
	Compound ("and") conjunctions are not supported (--TODO should they?)
	
	For editing, those tables are transformed into lines in a text area:
	{ln=...} -> LN ...
	{rc=...} -> RC ...
	{c=...}  -> #...
	{default=true} -> *
	See also route_ui.lua
]]

local il = advtrains.interlocking

-- The ARS data are saved in a table format, but are entered in text format. Utility functions to transform between both.
function il.ars_to_text(arstab)
	if not arstab then
		return ""
	end
	
	local txt = {}
	
	for i, arsent in ipairs(arstab) do
		if arsent.ln then
			txt[#txt+1] = "LN "..arsent.ln
		elseif arsent.rc then
			txt[#txt+1] = "RC "..arsent.rc
		elseif arsent.c then
			txt[#txt+1] = "#"..arsent.c
		end
	end
	
	if arstab.default then
		return "*\n" .. table.concat(txt, "\n")
	end
	return table.concat(txt, "\n")
end

function il.text_to_ars(t)