I'm interested to understand the last part of the example in the WIKI https://transportfever2.com/wi…ction_postRunFn.lua.html#
Here is the part:
I have so far found that this is overwriting the first params created above this section. Why make an example so complicated for "newbies" and no comments in the code?
Anyway, I have in my tests run without this part and got it to start, but I get an error when trying to build the construction. "No mod"
in the construction directory there is only the .script file, but no con file (the name of the con is same as the script file) as it is built dynamically in the mod.lua:
The settings are updated and that can be seen when selecting the construction in the game. I get the feeling that the script file isn't started and I can't find my fault.
(The script file worked earlier before I rewrote the mod.lua to make the dynamic construction.)
transportfever.net/wsc/index.php?attachment/159633/
stdout.txt
- Exception type: Lua exception
- This error is usually caused by modding. Some game resources contain incorrect data.
- Details:
- Error message: error: attempt to call a nil value
- stack traceback:
- =[C](-1): ?
- File name: res/construction/creek_bridge_street
- Key: game/res/script/construction/creek_bridge_street/createTemplateFn
- Minidump: I:/Steam/userdata/70790454/1066780/local/crash_dump/55a0df86-df6e-4163-b47f-593d45c7c3e3.dmp
- Mod: no mod
- In file: c:\build\tpf2_steam\src\lib\lua\state.cpp:586
- In function: void __cdecl lua::State::Call(int,int)
- Exception type: Lua exception
- This error is usually caused by modding. Some game resources contain incorrect data.
- Details:
- Error message: error: attempt to call a nil value
- stack traceback:
- =[C](-1): ?
- File name: res/construction/creek_bridge_street
- Key: game/res/script/construction/creek_bridge_street/createTemplateFn
- Minidump: I:/Steam/userdata/70790454/1066780/local/crash_dump/c5a343eb-f341-46f9-a16a-dde4c23fac19.dmp
- Mod: no mod
- In file: c:\build\tpf2_steam\src\lib\lua\state.cpp:586
- In function: void __cdecl lua::State::Call(int,int)
snippet from the mod.lua
- local con = api.type.ConstructionDesc.new()
- con.fileName = "creek_bridge_street.con"
- con.type = api.type.enum.ConstructionType.STREET_STATION
- con.description.name = _("Small street bridge")
- con.description.description = _("small bridge").
- .
- .
- .
- local myCon = string.gsub(con.fileName, '.con', '')
- con.updateScript.fileName = "construction/"..myCon..".updateFn"
- con.updateScript.params = {
- -- param1 = "param1",
- autobahn_mod = hasAutobahnMod,
- }
- con.preProcessScript.fileName = "construction/"..myCon..".preProcessFn"
- con.preProcessScript.params = {
- -- param1 = "param1",
- autobahn_mod = hasAutobahnMod,
- }
- con.upgradeScript.fileName = "construction/"..myCon..".upgradeFn"
- con.upgradeScript.params = {
- -- param1 = "param1",
- autobahn_mod = hasAutobahnMod,
- }
- con.createTemplateScript.fileName = "construction/"..myCon..".createTemplateFn"
- con.createTemplateScript.params = {
- -- param1 = "param1",
- autobahn_mod = hasAutobahnMod,
- }
- api.res.constructionRep.add(myCon, con, true)