Yes I think I see the problem now... With scriptbaren transportNetworkProvidern nothing would possible though, which do not now even (theoretically) would be possible, but it makes everything much easier.
It's possible to script transportNetworkProvider in some ways
The way I used in sloped station is taking the the path of mdl as parameters input
like this:
local slopedstation = require "slopedstation"
local currentPath = debug.getinfo(1).source
local modelPath, slope = slopedstation.extractModel(currentPath)
local buildingFile = assert(loadfile(modelPath))
buildingFile()
local originalData = data
function data()
return slopedstation.treatBuilding(slope)(originalData())
end
Alles anzeigen
then the treating is tike following
local mockPathPattern = [==[^@(.+)/sloped_station/(-?%d%d)/(.+%.mdl)$]==]
function slopedstation.extractModel(mockPath)
local r = {}
string.gsub(mockPath, mockPathPattern, function(m, s, b) r.path, r.slope = m .. "/station/train/" .. b, tonumber(s) end)
return r.path, r.slope
end
function slopedstation.generalTreat(m, nodeMatch)
return function(result)
local function treat(keep, rotate)
local kepPoint = coor.vec2Tuple(keep)
local rotPoint = coor.vec2Tuple(coor.apply(rotate, m))
local vec = {rotPoint[1] - kepPoint[1], 0, 0}
return table.unpack(laneutil.makeLanes({{kepPoint, rotPoint, vec, vec, 1.5}}))
end
laneModifier = function(lane)
local mode = table.unpack(lane.transportModes)
if (mode == "PERSON" or mode == "CARGO") then
for i = 1, #lane.nodes, 2 do
local bgnNode = coor.edge2Vec(lane.nodes[i])
local endNode = coor.edge2Vec(lane.nodes[i + 1])
if (nodeMatch(endNode)) then
lane.nodes[i], lane.nodes[i + 1] = treat(bgnNode, endNode)
elseif (nodeMatch(bgnNode)) then
lane.nodes[i], lane.nodes[i + 1] = treat(endNode, bgnNode)
end
end
end
return lane
end
result.metadata.transportNetworkProvider.laneLists =
func.map(result.metadata.transportNetworkProvider.laneLists, laneModifier)
return result
end
end
function slopedstation.treatBuilding(slope)
local m = slopeMRotY[slope]
local nodeMatch = function(pt) return (pt.x == 4.5 or pt.x == -4.5) and pt.y == -10.0 end
return slopedstation.generalTreat(m, nodeMatch)
end
function slopedstation.treatStairs(slope)
local m = slopeMRotX[-slope]
local nodeMatch = function(pt) return (pt.y == 4.5 or pt.y == -4.5) and pt.x == 3.5 end
return slopedstation.generalTreat(m, nodeMatch)
end
Alles anzeigen
In this, I only need one copy of prototype mdl, then lot's of mock mdls to generate the data() function in runtime.
Seems crazy? Using debug info perhaps seems dirty, but I find it runs not so slow.