-- Route programming system
--[[
Progamming routes:
1. Select "program new route" in the signalling dialog
-> route_start marker will appear to designate route-program mode
2. Do those actions in any order:
A. punch a TCB marker node to proceed route along this TCB. This will only work if
this is actually a TCB bordering the current TS, and will place a
route_set marker and shift to the next TS
B. right-click a turnout to switch it (no impact to route programming
C. punch a turnout (or some other passive component) to fix its state (toggle)
for the route. A sprite telling "Route Fix" will show that fact.
3. To complete route setting, use the chat command '/at_program_route <route name>'.
The last punched TCB will get a 'route end' marker
The end of a route should be at another signal facing the same direction as the entrance signal,
however this is not enforced and left up to the signal engineer (the programmer)
The route visualization will also be used to visualize routes after they have been programmed.
]]--
-- table with objectRefs
local markerent = {}
minetest.register_entity("advtrains_interlocking:routemarker", {
visual = "mesh",
mesh = "trackplane.b3d",
textures = {"at_il_route_set.png"},
collisionbox = {-1,-0.5,-1, 1,-0.4,1},
visual_size = {x=10, y=10},
on_punch = function(self)
self.object:remove()
end,
get_staticdata = function() return "STATIC" end,
on_activate = function(self, sdata) if sdata=="STATIC" then self.object:remove() end end,
static_save = false,
})
-- Spawn or update a route marker entity
-- pos: position where this is going to be
-- key: something unique to determine which entity to remove if this was set before
-- img: texture
local function routemarker(context, pos, key, img, yaw, itex)
if not markerent[context] then
markerent[context] = {}
end
if markerent[context][key] then
markerent[context][key]:remove()
end
local obj = minetest.add_entity(vector.add(pos, {x=0, y=0.3, z=0}), "advtrains_interlocking:routemarker")
|