Game script, api.res.constructionRep.getAll

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


  • To your performance test: Does this run every time step? You want to find an industry and the id remains same, so it could just be saved. Except if it is bulldozed but only then something would change. Also, are there many warehouses or always just 1?


    The values from industries are the numbers that are shown in the window:

    -Production/ProductionLimit

    -Shipping

    -TransportRating (0-1)

    See also here what I read out in Adv Stats

    https://github.com/Vacuum-Tube…/script/data/industry.lua

    https://www.transportfever.net…achment/178791-12ind-png/


    I wish to learn how to look into a table to get the names of the data to be read.

    You can also use print(toString(mytable)) or just use the console

  • it could just be saved

    In my SweDen mod for TpF1: I divided the search into several parts because it is not in a hurry to find a new industry. It is actually so that a newly placed industry does not have to start its production in the first few seconds. I have thought of this to just distribute the job so that it does not become too high a momentary load. Now that the starting point is to use SIM_BUILDING, the final result with a distributed job will be even better. As you wrote bulldozing is the only situation where something is changing fast. This has to be handled in the script.


    The player (sandbox mode) or game start can place warehouses all over the map, so there may be more than one "warehouse industry".



    use print(toString(mytable))

    I have also initiated an area in the GUI, so I can see the values in game.


    This is the problem that I often get. Printing the variable in the console or directly in the code givs me only an info that it is a table, but how to get into the table, what names are hiding inside it besides "_sum"? I have tested to index the table [1] ... ,but that results only in a nil value.


    The code I found in the UG campaign was:

    game.interface.getEntity(game.interface.getEntity(params.glasgow_steelmill).simBuildings[1]).itemsConsumed

    I changed the params.glasgow_steelmill into the Entity id for the industry I have and the result (table) is seen in the screendump.


    A table that includes something, but what?


    After I installed your Adv. Stat mod I found that you are using the same type of code, but you have "._sum" at the end .... So I placed the ._sum behind "itemsConsumed" in my code and it resulted in this:

    local Consumed= game.interface.getEntity(game.interface.getEntity(ConId).simBuildings[1]).itemsConsumed._sum


    The Consumed value (258) is not the same as the consumed value for the industry = 165, but it show at least something!

    (The ConId 27553 is the entity id for the Industry from which I have to get the data)


    In this industry there are two input items and each have a consumption value, I think the ._sum is the sum of both. How to get consumption value separately for each item ( in the example above it should result in 0 and 165)?

    2 Mal editiert, zuletzt von melectro ()

  • Why not use UGs Console and let it simple output the entity data, then you can see the structure? (Actuall it uses the same toString system)


    78928 is a SIM_BUILDING of a steelmill (as shown on my last screenshot. You get stats by Cargo type (past data only):


  • I'm now trying to trigger some animations. Based on the vanilla steel mill, which has two animation event types "productionHalf" and "productionFull", my idea is to make something happen when production start in what I am working on now.
    Unfortunately, the animation does not start. What I see is a difference in the .mdl file, for the steel mill from UG type = "KEYFRAME", and I use type = "FILE_REF",


    According to Wiki, it should not matter. However, the animation works very well in the model editor and if I change the trigger to "forever", it also works in the game. It really interests me to understand why the animation does not start with eg. "productionHalf".
    Is there anything else I need to think about?


    Einmal editiert, zuletzt von melectro ()

  • I am sorry I did want to answer earlier.


    According to my binary analysis producing is a referenced string in a Transformator

    I cannot find production connected to a Transformator and/or productionHalf and productionFull .


    That doesn't mean I say these are not working at all, but I simply find no traces in the binary code.

    Different example: The animal movement types aren't hardcoded in the exe either, but seems to run randomly from defined movement types)


    A Transformator grabs readonly ECS Entity Data and selects actually the desired Animation to Render a Construction, Vehicle, Animal, Bridge and so on. It's called heavily in the Render Thread.


    Actually that is the reason (Design) you can't really fire an specific Animation as in TPF1 via Script Interface.


    The desired animation was passed as string mostly in TPF1 and stored in the entity system.

    Now in TPF2 you only have some flags, like isDoorOpen and doorTime. The used animation name from Modeldata is calculated every rendering...



    UG really could create a Wiki overview page with a list of all triggers, event names for animations and sound...

  • UG really could create a Wiki overview page with a list of all triggers, event names for animations and sound...

    I'll write them an e-mail...


    productionHalf and productionFull

    I now see that I have not been clear in my first writing. I think you have been able to figure out where I found these event names. For the reader who wants to know, I write here that you can easily get these names if you open various models in the model editor.


BlueBrixx