Need of comments for example in WIKI construction_postRunFn.lua

Willkommen in der Transport Fever Community

Welcome to the fan community of Transport Fever and Train Fever, the economic simulators of Urban Games. The community is free for you to share and inform yourself about the game. We cultivate a friendly and objective interaction with each other and our team will be happy to answer any questions you may have.

 

Registration and use is of course free for you.

 

We wish you a lot of fun and hope for active participation.

The Team of the Transport-Fever Community

  • 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


    snippet from the mod.lua

  • Actually I'm not in the need of createTemplateFn in the script file for my mod to work, but if the game needs it, I don't know. I have tested to remove the lines including the functions in the mod.lua, and then I get following error.


    At the end of mod.lua I have placed a debugprint "hasBridge...." and this line isn't executed as the error above happens at the missing format.


    Letting the comments away and activate the functions in the scriptfile doesn't help. A new error, very informativeX/...:


    here is what I have written in the script file:

    stdout.txt

    Code
    1. adding archive res/models/models.zip
    2. ModelRep: 6387.35 ms
    3. hasBridge = true creek_bridge_street
    4. No resources are missing!
    5. texture load error: file not found: res/textures/.tga
    6. MinidumpCallback: dumpPath "I:/Steam/userdata/70790454/1066780/local/crash_dump/", minidumpId "4c92bced-9c21-422a-9f9f-c74c92b464c2", succeeded 1
    7. local time is Sun Sep 27 17:32:03 2020
    8. An error just occurred.
  • melectro You found a good part for the dynamic param puzzle. I don't have recongnized this script. Thanks for it
    I've testet the marked lines of code. They are working fine in my context.

    The problem is, that the whole code snipped doesn't make sence for me and will not help in your context.
    Here are the comments you requested:

    ```

    ```


    So far so good.

    What not makes sence to me is. In the lines above they create an asset object. The construction templates are good for modular construction, but does not help in case of asset (except they are modular, but in this snippet there are no modules created for it). This param will appear in the createTemplateFn() where you define where all the module should be placed. If you have no module you will have `return {}` and the parameter have no impact. You will need this parameter in the updateFn().


    I have tried to add a parameter to my existing params of my constructionTemplate. This does't change anytihing. Same with manipulating one of my params . No changes. When I clone my construction template, add a new parameter and override my old constructionTemplate it works.


    EDIT: only for my own interest. What does a `preProcessFn`? (Was assigned to the asset in this code snipped) I never heard of it before.


    EDIT: I've got the sulution.
    Adding params are have no effects on the constructionTemplate only does have no effect. When I add params to the normal construction param list it works fine.

    Here is the evidence

  • There has to be more info in the stdout

    No there is no more information than the normal lines at loading the game. Here is the full stdout.txt if you don't believe me.


    EISFEUER

    Thanks' for enlighten me.

    What not makes sence to me is. In the lines above they create an asset object.

    in my case it was the opposite, the second part didn't make any sense to me as I changed the definition in the first part to STREET_STATION and deleted my "mod".con in the construction folder.

    The first part is creating a complete con file in the repository. What I'm guessing is, if you want to omit the first part and instead have your own .con file in the construction folder, you could use the second paragraph. Unfortunately, it is not clear in the example and that is the comment I was looking for. I have tested to use only the second part (by reintroducing my .con file in the construction folder), but it also creates errors.

    I like to use the first part where the con is dynamically created, but I'm trying to find how to interpret following two lines:

    Code
    1. con.fileName = "myCon"

    Should the file name "myCon" include ".con" or not?

    Code
    1. con.updateScript.fileName = "construction/cons.updateFn"

    I have seen in other examples that "cons" is normally the name of myCon without ".con". Here it is only confusing me in following points.

    1. the "s" in "cons.updateFn". For me the s means plural of con (=constructions)
    2. Why not use the same name as the construction in the example?
    3. It would have been nice if the example pointed to the use of a script file. Even better if the script file is also presented.
  • I would exclude the .con in the name, as they do in the example.


    In my case I have a .con file defining the info and in mod.lua I am assigning the external script file.

    This is working and I would prefer this method.


    Code
    1. con.updateScript.fileName = "construction/cons.updateFn"

    I have no idea why they use cons. The filename refers to .script file. In this case this would be "res/construction/cons.script". Behind the . is the function name (updateFn) that is defined in the .script file.

    Also described here: https://www.transportfever2.co…ons#construction_updatefn

  • I have read the description three times and still I don't understand or get it working.

    If you have no module you will have `return {}` and the parameter have no impact.


    from the .script file

    I have placed the return {} in the xxxFn functions in the .script file, but still I get the message "An error just occured"


    here are the lines after the normal startup info in stdout.txt

    Code
    1. adding archive res/models/models.zip
    2. ModelRep: 6316.05 ms
    3. No resources are missing!
    4. texture load error: file not found: res/textures/.tga
    5. MinidumpCallback: dumpPath "I:/Steam/userdata/70790454/1066780/local/crash_dump/", minidumpId "ab5993b4-e9b5-477d-a110-9da05005243f", succeeded 1
    6. local time is Tue Sep 29 17:31:13 2020
    7. An error just occurred.
  • After i have studied the example in WIKI https://transportfever2.com/wi…uction_postRunFn.lua.html, I found that there is probably an undocumented function called api.type.StaticConstructionTemplate. The example uses Dynamic, but how to configure it as Static? Is there anyone of you that know something to explain how to set it up for Static?


    I can tell that when I only change the name into Static I get an error as the api.type.StaticConstructionTemplate.new() returns a NIL value

  • I have for the moment created two mods with DynamicConstruction and when enabling both, one of them doesn't work as the ParamsfromLua will only be read from the last activated mod. Though it works fine if I just enable it as stand alone.


    1)

    Is there a limit that the game can only handle one mod with dynamicConstruction?


    2)

    Regarding my question above. I have found inside the TpF2.exe file these modules, but I cant find any documentation about StaticConstruction. Experimenting isn't making any progress.


  • and when enabling both, one of them doesn't work as the ParamsfromLua will only be read from the last activated mod

    don't know what you are doing with params, but you should maybe know, there is a bug regarding modparams where keys from one mod might override other mods. So make sure, you are using unique keys.


    Isn't a static construction similar to a dynamic and differs only in the template modules? Maybe you don't need static?

  • there is a bug regarding modparams

    That I didn't know, Thank you it makes sense to what I have seen.


    About Static/Dynamic, actually I'm trying to find why the setting menu isn't showing up on the right side when I select "configure" on the dynamic construction after it has been built. I wish to make a change, but the menu does not appear as it is doing for a standard mod like my Autobahnkreuz.