aboutsummaryrefslogtreecommitdiff
path: root/assets/modern_japan_lockomotive.blend
diff options
context:
space:
mode:
authorBlockhead <jbis1337@hotmail.com>2020-03-03 20:53:25 +1100
committerBlockhead <jbis1337@hotmail.com>2020-03-03 23:00:20 +1100
commit378d8625721ac24401c772531ed348ecae4e4fb3 (patch)
treefa1e2fb5122b3cc1a431e34c4e6036b0612cacd7 /assets/modern_japan_lockomotive.blend
parent9d7b21c451ac5ae9475236814f33e5627061ece1 (diff)
downloadadvtrains-378d8625721ac24401c772531ed348ecae4e4fb3.tar.gz
advtrains-378d8625721ac24401c772531ed348ecae4e4fb3.tar.bz2
advtrains-378d8625721ac24401c772531ed348ecae4e4fb3.zip
Draft copy tool
The copy tool copies a train to a global clipboard. It copies the Line number, Routing code, inside text and outside text. It copies the kinds of wagons in the train and whether they are flipped around. Pasting with the copy tool will conditionally flip the train such that 'your front' of the train, rather than the absolute front of the train, is what is output. The new train is oriented to travel forward with the placing player's view. Conditons are: - Multi-unit/push-pull train (= has locomotives on both ends): Never flipped - Locomotive-hauled train (= has one end with a locomotive): Flipped so that the locomotive is always at the front. If the locomotive points long hood forward, it will still point long hood forward. - Rake of wagons (= has no locomotives on ends): Flipped according to which end of the train the p-- 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)
is 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) if t=="" then return nil elseif t=="*" then return {default=true} end local arstab = {} for line in string.gmatch(t, "[^\r\n]+") do if line=="*" then arstab.default = true else local c, v = string.match(line, "^(..)%s(.*)$") if c and v then local tt=string.upper(c) if tt=="LN" then