Beiträge von EISFEUER

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


    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

    Angry_CJ  JoFi ein Kopfbahnhof geht wirklich noch nicht. Ist für die Version 1.2 geplant (Es kommt aber erstmal v1.1 noch raus).
    Es soll bei mir schon ordnentlich aussehen und kein um 90° gedrehter Bahnsteig sein. Da muss ich mir halt noch was einfallen lassen.

    Zur neuen Brücke: Die ist der Billhafenbrücke, die gerade von mir im Bau ist sehr ähnlich, kann ich die gleich mitmachen. Gleis und Straße auf einer wird es aber dann nur als Asset-Brücke geben, was bei dieser kein Problem sein sollte, weil sie sehr gerade aussieht.

    Zur alten Brücke: Gerade bei alten Brücken, die viele Ornamente, Metallverzierung und so'n Zeug haben, brauche ich Bilder und Nahaufnahmen fast von jedem Winkel der Brücke, was bei einer, die nicht mehr existiert, schwierig ist. DH-106 hat zwar schon viel Material geliefert jedoch hab ich noch keinerlei Vorstellung wie der Bogen exakt aussieht. Beton und Steinbrücken sind was Materiallage angeht meist simpler. Schiene auf Straße ist optisch kein Problem (Straßenbahn), funktional ist es auch theoretisch möglich, nur sehr kompiziert und am Ende recht unflexibel und bei Asset-Brücken möglich.


    Eine alte Brücke hab ich noch vor zu Bauen, jedoch nicht diese. Die meisten Kandidaten sind aber in der Nähe von dieser.

    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

    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

    Zu den Straßen: Es gibt Module für die Zugangsstraßen. Diese einfach kompieren und den Straßentyp in den ändern den du willst.
    Zu den Tram-Masten: Am besten lassen.
    Die Masten sind in gefühlt tausenden Modellen zusammen mit dem Gleisen und Lanes. Sind viele Teile, die wie bei einer Modelleisenbahn zusammengebaut werden.
    Alle müssten dupliziert und geändert werden. Desweiteren braucht es noch ein Fake-Modul was die Models ändert.


    Nach langem Gebastel, hab ich es entlich hinbekommen, dass man auch sehen kann, was für ein Theme man auswählt (Ist das Feld 'Aussehen / Corporate Identity' auf dem Screenshot).


    PeugeotRacer irgendwie habe ich deine Frage übersehen. Kleine Bushaltestellen lassen sich nicht modular beuen geschweige mit Parametern. Was irgendwann kommt ist, dass man die Wartehäuschen auf Bahnhöfen platzieren kann.
    ,

    Hab den Post erst jetzt gesehen.
    Eine halbe Lösung hab ich schon für das Problem. Ich habe es geschafft, Sachen aus dem Repo in die createTemplateFn() meiner .con zu bekommen (updateFn sollte genauso funktionieren).

    Du kannst diese in eine .script-Datei auslagern und diese in der postRunFn() deiner Konstruktion zuweisen. (Den Aufbau der .script-Datei kannst du dir im Spiel bei den Gleismodulen anschauen, eigentlich selbsterklärend).

    Scriptmäßig sieht es dann so aus

    Code
                local styleList = {'style1', 'style2'} -- Ist im meinem Script etwas komplexer .-)
    
                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}

    In der createTemplateFn oder updateFn kommst du so an den Parameter:

    Code
    createTemplateFn = function(params)
                local themes = params.capturedParams.themes
    ...
    end


    Was ich noch nicht rausgefunden habe, ist wie ich dann ein dynamische UI-Element hinkriege. Momentan hab ich eine Auswahl mit Mengen an Zahlen wo man Raten muss was man auswählen will.

    Hier eine weitere Idee, die ich gerade am umsetzen bin, aber momentan noch ganz an der Anfangsphase ist. Es handelt sich dabei um Themes. Themes sind ein Sammlung an Modulen, wie Bänke, Mülleimer, Zielanzeiger, Uhren, Bahnsteigs- / Infotageln etc. die die Identität eines Unternehmens wie z.B. die DB wiederspiegelt.

    Themes können als eigene Mod erstellt werden und werden automatisch zu bestehenden Bahnhöfen (die Themes unterstützen) hinzugefügt. Durch Themes können Bahnhöfe unabhängig vom Betreiber gemacht werden und man so mit einem Klick ein DB-Bahnhof zum ÖBB-Bahnhof machen.

    Hier mal ein Beispiel. Ich habe mein MOTRAS-Bahnhof, ein DB-Theme und ein ÖBB-Theme geladen (beide momentan in der Entwicklung). Auf dem Bilder habe ich eine Theme-Auswahl, die eine Uhr beeinflusst (wie gesagt befindet sich alles noch am Anfang)


    Ein Problem hab ich jedoch, ich kann zwar dynamisch Themen hinzufügen, jedoch weiß ich nicht wie ich die Theme-Auswahl dynamisch anpassen kann. Hat jemand damit schon erfahrung und weiß wie das geht?

    Wie ist denn `hasBus` definiert? Ich vermute das diese aus irgendein Grund `nil` ist.

    Wozu das elseif ? Wenn nur das Gegenteil (in diesem Fall `not hasBus`) gecheckt wird, ist ein normales else besser (lesbarer und performanter).


    Code
    if hasBus then
     right.lightModels = getLightModels(args, models, fromToR)
     right.poleModels = getPoleModels(args, models, fromToR, params.poleTrafficLight)
    else
     right.lightModels = getLightModels(args, bTR, fromToR)
     right.poleModels = getPoleModels(args, bTR, fromToR, params.poleTrafficLight)
    end

    Würde es auch eher so schreiben (weil das meiste gleich im if/else ist)


    Code
    lightModels = hasBus and models or bTR
    right.lightModels = getLightModels(args, lightModels , fromToR)
    right.poleModels = getPoleModels(args, lightModels , fromToR, params.poleTrafficLight)