Since when is it possible to set signals at depots or stations?
Always possible via script, but when I put it on an asset it crashes since the assert doesn't have a name on it.
Wir begrüßen euch in der Fan-Community zu den Spielen Transport Fever und Train Fever, den Wirtschaftssimulatoren von Urban Games. Die Community steht euch kostenlos zur Verfügung damit ihr euch über das Spiel austauschen und informieren könnt. Wir pflegen hier einen freundlichen und sachlichen Umgang untereinander und unser Team steht euch in allen Fragen gerne beiseite.
Die Registrierung und Nutzung ist selbstverständlich kostenlos.
Wir wünschen euch viel Spaß und hoffen auf rege Beteiligung.
Das Team der Transport-Fever Community
Since when is it possible to set signals at depots or stations?
Always possible via script, but when I put it on an asset it crashes since the assert doesn't have a name on it.
I got lot's of ideas and it will still take some weeks to complete it.
The algorithm becomes very complicated when I want to construct complex switch groups.
Hope it being useful who like to construct depots
Does anyone know how to call this kind of track pattern in shunting yard?
In german it's called a "Gleisharfe". In this german Wikipedia article they even used the same picture as yours. Link: https://de.wikipedia.org/wiki/Gleisharfe
Work out
I will add quasi moving blocks in this mod, in general, the signals are invisible.
Can u show us the Params-Box to create those?
How big is it?
From the screenshots this looks like a really nice piece of work. Thank you for creating this mod.
I am allowed to ask some questions:
How do you calculated the track bezier curve outline to place the walls?
I didn't try to fit bezier, since the result from the game fit's well circular arc under approx. 60°, I just let all coordinates go with circular arcs. I make my arc generate two edges each time and it can support up to 90° without much errors.
Would you accept a small commonapi patch so all track types are possible? (I won't change anything when commonapi wouldn't be loaded)
Having seen you mod last night on Steam, I am also thinking of it. The selection of track file is done directly in updateFn like following:
if you want to patch them, how can you patch a single line in the function?
However I am interested in working with your api, do I need to expose this single line as a function or a callback to make the patching easier? I have yet looked into your api due to limited time.
The easiest way is with commonapi.uiparameter.modifyTrackCatenary, that does a lot of the stuff under the hood so you don't need to pass any objects around.
I did post an example here:
Common API - immer noch macOS Nutzer gesucht! -
Technical you simple pass the params array and an "array" of trackTypes (exact two entries) to it and it will modify your params and your trackTypes.
(LUA tables are passed pretty much as references, so this works generally quite well on all constructions).
So you need somewhere an array local to your data function in the con.
Then you access this array in your params and updateFn. The fastest way would be to add extra function parameters.
(Note: I did this without any testing, as you already have a params construction function it should technical pretty simple)
local function params(trackTypes)
local result = {
...
}
if (commonapi ~= nil and commonapi.uiparameter ~= nil) then
commonapi.uiparameter.modifyTrackCatenary(result, {selectionlist = trackTypes})
end
return result
end
local updateFn = function(models, trackTypes)
return function(params)
defaultParams(params)
local trackType = trackTypes[(params.trackType or 0)+ 1] or "standard.lua"
...
function data()
local trackTypes = {"standard.lua", "high_speed.lua"}
return {
type = "RAIL_DEPOT",
...
params = params(trackTypes)
updateFn = updateFn( .... , trackTypes)
But defaultParams could be a bit tricky to cheat, as it needs the trackTypes as well.
Technical I would only create the ui-params once and not run the params again when doing the defaultParams call.
Running modifyTrackCatenary with already patched trackTypes will surely fail, so this is not a final patch.
I think I will later make a "Patch" mod to patch most of my mods with your commonapi, I think it will be a better solution than to introduce dependency directly.
You don't have a direct dependency, the line ensures that the code will run only when commonapi is loaded:
if (commonapi ~= nil and commonapi.uiparameter ~= nil) then
end
CommonAPI works without require or hard dependency, so no worry
-edit-
Here a working tunnel_entry.con, again, there is no dependency on CommonAPI, if it's loaded, it will be used, otherwise nothing will be changed:
--- tunnel_entry.con_old Sat Oct 14 02:10:07 2017
+++ tunnel_entry.con Sat Oct 14 20:12:46 2017
@@ -20,9 +20,9 @@
"track_design_patterns/arch_wall.mdl",
}
-local function params()
+local function params(trackTypes)
local sp = "----------------------------\n"
- return {
+ local uiparams = {
paramsutil.makeTrackTypeParam(),
paramsutil.makeTrackCatenaryParam(),
{
@@ -104,22 +104,25 @@
defaultIndex = 10
}
}
-
+ if (commonapi ~= nil and commonapi.uiparameter ~= nil) then
+ commonapi.uiparameter.modifyTrackCatenary(uiparams, {selectionlist = trackTypes})
+ end
+ return uiparams
end
-local function defaultParams(param)
+local function defaultParams(param, uiparams)
local function limiter(d, u)
return function(v) return v and v < u and v or d end
end
- func.forEach(params(), function(i)param[i.key] = limiter(i.defaultIndex or 0, #i.values)(param[i.key]) end)
+ func.forEach(uiparams, function(i)param[i.key] = limiter(i.defaultIndex or 0, #i.values)(param[i.key]) end)
end
-local updateFn = function(models)
+local updateFn = function(models, uiparams, trackTypes)
return function(params)
- defaultParams(params)
+ defaultParams(params, uiparams)
- local trackType = ({"standard.lua", "high_speed.lua"})[params.trackType + 1]
+ local trackType = trackTypes[(params.trackType or 0) + 1] or "standard.lua"
local catenary = params.catenary == 1
local trackBuilder = trackEdge.builder(catenary, trackType)
local height = 8.5
@@ -331,6 +334,8 @@
function data()
+ local trackTypes = {"standard.lua", "high_speed.lua"}
+ local uiparams = params(trackTypes)
return {
type = "RAIL_DEPOT",
description = {
@@ -343,14 +348,16 @@
order = 27219,
skipCollision = false,
autoRemovable = false,
- params = params(),
+ params = uiparams,
updateFn = updateFn(
{
mRoofFenceF = "track_design_patterns/roof_fence_front.mdl",
mRoof = "track_design_patterns/roof.mdl",
- }
- )
+ },
+ uiparams,
+ trackTypes
+ )
}
end
Alles anzeigen
You don't have a direct dependency, the line ensures that the code will run only when commonapi is loaded:
Thank you for giving working code, yes I know it but reading global variables in lua is not free.
But I think patching mod follows a good logical separation rule and will be useful if someday maybe you want to make some changes to api, at least I don't need to upgrade my mod immediately if it comes, and the player will have choice, if he has installed 100 tracks and he doesn't want to see a heavy menu. I have been asked for many times if the tracks under the flying junction can be other tracks so I think working with your api will be very constructive.
I will look into this later, very tired by the mod for the moment, need to take a rest.
Nice work! So let me ask in short: Is it possible to change the used tracktype in some short way at the moment?
Not right now (only when u change code). I think he said that he adds the CommonAPI sometime later.
For the manual change follow the steps bellow:
Go in the modfolder ( in steam its steamapps/workshop/content/446800/1168068230 ; else its the Foldername u downloaded)
go to res/construction and open all of the files (for example with Notepad++ )
search this line: local trackType = ({"standard.lua", "high_speed.lua"})[params.trackType + 1]
should be arround the 100 - 150
and change it to
local trackType = ({"standard.lua", "high_speed.lua", "extra.lua"})[params.trackType + 1]
for extra u can add the .lua file of ur track u want to add.
If you do this for all of your Files yous should have the new track as possible option.
Thanks a lot! That is, what I asked for. I will give a try. But you told the actual line is {"standard.lua", "high_speed.lua"}, does it mean, that I can choose between both of them at the moment? Because I can´t.
Thanks!
I can't find this Option too. I think it's a missing Value thing.
function StationBuilder.trackTypeUiParam(config)
return {
key = "tom_trackType",
name = _("Track type"),
values = { _("Standard"), _("High-speed") },
yearFrom = 1925,
yearTo = 0
}
end
Something like this. I made some changes to Stations where this was in. Added the track Types in Config and added Values in Script Folder. Some Stations don't have this Lines and thats where im completly lost. By the way. I don't recommend this changes for saved Games. I had crazy behaviours.
Need to rewrite both paramsutil.makeTrackTypeParam() and that line if you want to add extra track types.