Is randomized object possible in Transport Fever?

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


  • Hello folks!


    I am a newbie programmer, just learned some Python and then the basics of Lua.


    I have been thinking for a while about having random elements in my train carriage mod for which I am currently making internal model. The idea is to randomize the id value in children in a mdl or grp file in order to call different mesh that displays different texture. For example, mesh 0 to 9 that contains different number, and when I randomly call different mesh for different car, each carriage gets a different registration number written on the body, so that I can avoid a sense of repetition.


    I tested my thought with the curtain, for which I made 8 mesh files that call different curtain textures; and put "id = Randomize.Curtain("25T_Large_Window_Curtain")," in the children list.


    The problem is I do get curtain looking randomized each time I load the game, but inside the same scenery, all carriages have the same order of curtain looking, like in the screenshots.



    I guess the game only loads the parameters once so the script is only executed once. Seems it will make my idea impossible to realize.


    I would like to seek for idea what might be other ways to realize it? Does anyone have some insights? Thanks.

  • As far as I know,

    is the current state of knowledge.

    Right, I was expecting this result; just the code is easy to write so I still tired to make it.


    I am also thinking about how people make customized train stations mods. Looks like they allow users to decide some parameters though the UI and apply only to one instance of the train station each time it gets built. Still trying to understand the logic; I don't know can the same method be used for making wagons?

  • Stations are a "bundle" of different mdl's. There is a con(struction) file that manages all of them. There you can set UI parameters and the final station gets build from those different mdl's. But a wagon/vehicle in general is only a mdl.


    Hm perhaps its comparable to PHP and HTML. HTML is static and with PHP you can create a static HTML page dynamically. But once build... ^^

  • TPF does this:


    LoadConstrunction, LoadModel, LoadSomething-> Setup Language Routine -> Parse and Run Lua File to get a LuaTable -> Run Filters/Modifer on LuaTable -> Read LuaTable into Ingame Memory Structure.
    It stores the memory structure into a repository object by id and name.


    Later in game TPF uses the memory structure to access the known data of an object.
    As example, if you select a tracktype, TPF converts this to it's internal trackid. With the trackid it ask the track type repository for Information, like speed and or models.


    The updateFn and the sound functions are special, as the called again if something happens.


    This means, at runtime it's not (yet) possible to change the behaviour of an object (object being anything, like vehicles, tracks, tunnels, buildings and so on). Animations are called from the C++ Code.

  • ...The updateFn and the sound functions are special, as the called again if something happens...



    ...runtime it's not (yet) possible to change the behaviour of an object

    Interesting, any chance to have undateFn work in a wagon mdl? or perhaps in a multiple_unit lua?


    I don't need to change the behavior of an existing object in the scenery, I want to call different objects upon creating a instance of something. i.e, make a series of mdls, each of them contains different window curtain looking, multiple_unit lua calls different mdls each time just like like how a station is built each time. Or if mdl can do that, then just call different msh each time which makes the whole thing much easier to do. Point out please if I have the wrong logic.

    4 Mal editiert, zuletzt von mdbyyc ()

  • Technical there is no interface or storage room for the updateFn, without patching the game. With CommonAPI I currently try to open TPF for such new stuff..
    It would be so much easier if UG could provide me debug symbols. I have to decode each an every function call myself and guess the memory structure, calling convention (the compilers do code inling and optimization)


    Even better would be source access, but that's a different story.


    For tracks and streets I am quite confident my assumptions are right.
    While my highest priority is still finding ways to create more flexible UIs for Constructions I could take a look at vehicles.
    The Models need to be loaded, tracked and switched. That's not something you can add simply to an C++ compiled application, so while I may find a way, it still a long road to get such support.

  • Thank you guys for insights!!


    I can see why officially UG doesn't consider more flexibility for wagons, just by experiencing how much lag each action creates when I configure a station in the game. It's a nightmare, spending about 10 seconds to wait for the PC become alive after each click. I can also feel the simple "Randomize.Curtain" noticeably increases the loading time.


    Seems like Lua in TPF is extremely inefficient. don't know why.

    Einmal editiert, zuletzt von mdbyyc ()

BlueBrixx