best method for detecting if another mod is installed

Willkommen in der Transport Fever Community

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


  • in my new model, I want to open a selection depending on whether another model is installed and has been loaded when this new model is to be built.

    Is there a good way to e.g. with a script look in a list for a .mdl without it having been used before in ongoing game?

    My first thought is to get a list of all installed mods by building a array of .mdls and then search in this array.

  • There is a way to get stuff from the mod.lua to the con-script.
    You have to outsource your createFn or updateFn to an .script-file (Look at the script-file of the track from UG to see closely how this file is structured).

    You can include this script file with params using code similar to this (themes is my param transfered from mod.lua to con)


    Code: mod.lua (postRunFn)
    local motrasStation = api.res.constructionRep.get(api.res.constructionRep.find('station/rail/motras.con'))
    motrasStation.createTemplateScript.fileName = "construction/station/rail/motras.createTemplateFn"
    motrasStation.createTemplateScript.params = {themes = stylelist:get()}

    You have access to all your params using `params.capturedParams` in the .script-file

  • (themes is my param transfered from mod.lua to con)

    I have downloaded the motras project to have a framed package of an example to follow as I have some difficulties to understand and find the stylelist:get or themes elsewhere. I'm not successful in this way as the motras project doesn't look like the example above. I have also tried to follow the thread in the UG example of track module, but that is even harder. I have the wish to see a complete example from mod-lua, .script and .con file


    My question: is the snap of an example above something from the motras project?

  • These lines are the last three lines in the postRunFn() of MOTRAS 1.1 which is currently WIP. You will find the files here:
    https://github.com/eisfeuer/tpf2-modular-train-station

    but here an example in the nutshell.

    I have two params ({cat = 'meow', dog = 'bow-wow'}) which I want to transfer from the mod.lua to my construction.

    For this I need theese files:
    construction/myCon.con: the construction file
    construction/myCon.script: file, that contrains the function I want to manipulate (In this case the updateFn())
    mode.lua: the mod settings file

    First the updateFn in myCon.con

    Code
    -- function will be overridden in mod.lua
    updateFn = function (params) 
    end



    The PostRunFn needs following three lines

    Code
    postRnFn = function (settings, params)
        -- gets the own construction from the repository
        local motrasStation = api.res.constructionRep.get(api.res.constructionRep.find('myCon.con'))
        -- overrides the updateFn() of the construction
        motrasStation.updateScript.fileName = "construction/myCon.updateFn"
        -- adds additional params to the updateFn()
        motrasStation.updateScript.params = {cat = 'meow', dog = 'bow-wow'}
    end


    At last, the .script-File

    That's it

BlueBrixx