Beiträge von eis_os

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


    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):


    This is because a game_script is heavily running thread. As UG didn't want me to tell how to sync to it, it's not possible to reliable know the current state this lua is. maybe it's somewhere in a deep nested function (Note: the summer update made things more async, so it's even worse)


    game.interface.getEntity(<entityid sim building>) (using SIM BUILDING Entity of a construction) shows a lot of data.


    Technical internally it will use the same entity components.

    The problem with UGs api.* functions is, they really aren't finished. Every time you see userdata, UG missed a part of the puzzle.

    However, sometimes it is easier to use the old game apis, maybe the needed info is already in there.

    game.interface.getEntity and api.system.* are completely different beasts. The first does a lot of data computing to get meaningful data and are made for TPF1/2 campaigns. The api.* are more interfaces to the direct internals of the game.


    The data you get via game.interface.getEntity are the past performance of an industry.


    Internally the game normally subscribes to state changes to know if something happens via the Enity Systems, but that isn't doable from the lua side.
    So while TPF2 is a lot faster and open, the CommonAPI TPF1 was a lot more flexible because there was only one thread and the interfaces was a lot more clearer.


    The question really is. What do you want to do? What is your goal in the end. Then you can select the right "tools"


    PS: Renaming shouldn't be necessary. game_script gui* is run in "GUI Thread", the other updates are run in "Script Thread". Renaming should be only done once, otherwise you fill your log with debug info...

    The proper API way, if you have a sim building entity, at least from API description as mentioned earlier.

    industryEntity is a SIM_BUILDING

    streetConnectorSystem.getConstructionEntityForSimBuilding(industryEntityId) => should give you a construction entityid


    You should ask UG for a complete guide how to do it properly.

    And if you have an answer, please post them so others can learn too.

    Yeah, the construction should have the stocklist. At least my inspector shows there is a stocklist.


    But as api.engine.getComponent(<constructionentityid>, api.type.ComponentType.STOCK_LIST) returns userdata.


    Damn. So still you have to use some api.system.* functions to get meaningfull data or old game.* interfaces

    See here, I am using my API left bottom Button -> Inspector Window. Second Tab has a "Get Entities" function, we see a Construction and SIM_BUILDING



    You want the whole UG API Madness, let's do it. You have a construction entity.

    1. Get the construction component,

    2. Use the simBuilding(s) EntityId to get component SIM_BUILDING

    3. we have a list Entity Ids of Stocks => stockList

    4. use simEntityAtStockSystem to get count.


    Dump of UG Console:



    Easy? Yeah... There are tons other apis the api.engine.systems ,so it's likely there is an easier way... but with the good documentation...


    There are some industry mods out there, maybe look what apis they use to get to a easier code path...




    -edit- More madness while we are at whole thing. Let's say, we have a SIM_BUILDING and want a construction?


    api.system.streetConnectorSystem.getConstructionEntityForSimBuilding

    https://transportfever2.com/wi…ctionEntityForSimBuilding



    ConstructionRep -> Industry types (Not build constructions, the blueprint con file data)


    Any Repository => something loaded from Model or Construction.con -> these are definition of something. Not an instance of some game element.

    Any game element is represented by some entity (referenced by entityid) and it's component. All the entities are run by the systems, they get component data from entities to run the game.


    If you have an entityid you can use api.engine.getComponent(entityId, componentTypeId)


    The componentTypeId is something from api.type.ComponentType, example: api.type.ComponentType.SIM_BUILDING


    There is a stockList,

    api.engine.system.simEntityAtStockSystem.getStockEntities(<stockListId>, <num unknown to me>) -> list of cargo entities.

    api.engine.system.simEntityAtStockSystem.getStockEntities(<stockListId>, 0) (first stock, don't ask me where to get the number)


    api.engine.system.simCargoSystem.getSimCargosForSource(<stockListId>)


    Otherwise try to see if you can get the info via Advanced Statistics


    However, sometimes it is easier to use the old game apis, maybe the needed info is already in there.



    There is api.system.stockListSystem.getCargoType2stockList2sourceAndCount too..

    Kann ich gerade nicht nachvollziehen.:/


    Ich bräuchte da dann mal einen vollen Screenshot, in meine Linux Build kann ich alles groß und klein machen, verschieben, auswählen und co.


    Werde es bei Gelegenheit auf einer Windows Gurke testen. Wenn jemand das selbe Problem hat, so bitte mit Screenshot (komplettes Spiel) und stdout.txt ...

    (Und wie immer, ich kann nur etwas reparieren was kaputt ist oder ich genügend Informationen zum Debuggen bekomme)

    1.7.20211204


    CommonAPI2


    Intern wird nur noch die veränderbare UI::ModDataProvider (Quelle der UG UI Mod Listen) genutzt,

    dieses sollte bei sehr vielen Mods die Berechnungszeit halbieren, da nur noch eine Liste anstatt zwei berechnet werden müssen.


    Dies kann dazu führen, das Fehlermeldungen bezüglich Abhängigkeiten nur noch bei erweiterten Einstellungen

    (da wo man die Mod Reihenfolge ändern kann) auftauchen.


    Chill_LP und FriendlyX hatten Probleme das die Fehlermeldung zum Buildoverwrite nicht im Hauptmenü erscheint,

    nun sollte es auch mit VSync off bzw. sehr hohen Bildwiederholraten funktionieren.



    Zum Thema LINE_DESTINATION funktioniert nicht, hab ich keine weiteren Infos, dann kann ich halt auch nichts machen...

    Debugger an srandom aus libc6 gehängt via breakpoint, es wird ständig aufgerufen mit 0 als seed Parameter.


    Irgendwas in UGs Script und GUI Thread ruft math.randomseed aus lua ständig mit 0 auf:

    Das Problem hierbei, es gibt keinen Stacktrace.


    Code
    math.randomseed = function() print(debug.traceback(nil, 2)) end

    Versucht das mal via CommonAPI2 Console im CommonAPI2 Thread. Wenn ihr dort dann math.randomseed(123) aufruft, bekommt ihr main chunk ( also C code ruft einen string auf) als Ergebnis.


    In UGs Console ausgeführt und dann:

    >> math.randomseed(123)

    stack traceback:

    [string "require "serialize" print(toString(math.rando..."]:1: in main chunk


    Wenn ihr dieses num UGs GUI Thread oder Script Thread macht, läuft eure stdout.txt über ohne stacktrace...


    -> Ergebnis:

    Irgendwas stellt den seed der libc via math.randomseed immer auf 0. Da beide Threads nicht im Hauptmenü laufen bzw. noch nicht erstellt sind, gibt es mit math.random dort auch noch keine Probleme...



    -edit 2-


    PS: Dafür wäre eigentlich ein Entwickler zuständig das zu klären und nicht ich als "Endnutzer" guertlms

    Da math.random in Konstruktionen zu sehr problematischen Ereignissen führen kann,

    kann es sein das UG das Problem durch einen „statischen“ Wert ersetzt hat


    Beispiel:
    1. Konstruktionsbauplan mit math.random wird getriggert für die Vorschau.
    2. Konstruktionsbauplan mit math.random wird getriggert für den Bau.
    3. Ergebnis passt nicht mehr zusammen => Spieler unglücklich


    Noch zur Info

    This function is an interface to the simple
    pseudo-random generator function rand provided by Standard C.
    (No guarantees can be given for its statistical properties.)


    -edit-

    Man nutzt einen seed einmal, und holt sich dann mehrere Pseudo-Zufallszahlen aus dem Algorithmus.


    -edit2-

    Nur so ein Hinweis, da CommonAPI2 seine eigene LUA Runtime nutzt, kann es sein das die Nutzung meiner Konsole etwas andere Ergebnisse produzieren kann...

    Es gab da mal Probleme mit der libc Version, daher zusätzlich die Steam libc Version im LD_LIBRARY_PATH via Shellscript.


    Das kann ggf. andere Probleme nach sich ziehen, aber Steam macht das intern auch, bzw. machte es immer noch? Keine Ahnung.


    valgrind & gdb werden bei so aber auch gestartet. Damit habe ich nen Vulkan Renderoverlay für CommonAPI2 geschrieben, das sollte in der Regel so laufen...


    CommonAPI2 mach ein Reset bei einer Subshell sonst funktioniert curl nicht richtig bei Ubuntu 20.04 mit Steam wegen libc mismatch.


    Kernel selber kompilieren kann man machen, mir reichte es aber ne ganze Zeit Mesa anzupassen. Mit ner 3200G APU hab ich alles mögliche schon anstellen müssen, Kernel, Mesa und Firmware für ein Bild. Irgendwann will man halt das alles mit so wenig Mühe funktioniert wie nur möglich :)


    Zurück zu TPF2, wenn es wegen fehlender Extensions meckert, dann stimmt was nicht.

    Starte mal mit:


    CommonAPI2 Endhaltestellen Anzeige (LINE_DESTINATION)


    - CommonAPI2 Nativ geladen und funktioniert (sprich CommonAPI Menü oben links im Hauptmenü?

    - CommonAPI2 im Spielstand aktiv geladen (Links unten runder Knopf?)

    - eis_os_linedestinationpatcher geladen und aktiv?

    - Im Linenfenster kann eine Endhaltestelle gesetzt werden?

    (Siehe Screenshot aus dem Lexikon Eintrag)


    Wenn alles richtig ist und es immer noch nicht geht:

    Dann bitte ein frisches Spiel starten, einen neuen Spielstand nur mit aktiver CommonAPI2 + Line Destination Patcher starten und testen.


    Wenn es nicht geht, davon dann bitte die stdout,txt...

    Punkt 2: Du kannst TPF2 nur via Steam starten, sonst stimmen die libc Abhängigkeiten nicht

    Alternativ, Shellscript nutzen (Pfade ggf. anpassen):

    Bash
    #!/bin/sh
    export LD_LIBRARY_PATH=.:~/.steam/ubuntu12_32/steam-runtime/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH
    
    ./TransportFever2


    Wenn irgendwelche extensions fehlen, scheint es einen Software Render Failback zu geben. Ergo nvidia Treiber neu installieren mit der passenden Kernel Version.


    Suspend via Nvidia binär funktioniert nicht wirklich.

    (Wenn es auf einmal doch funktioniert, scheint das System wohl mit nouveau/vesa kms oder ähnliches zu laufen)


    AMDs Kernel"Treiber" sind auch ne Sache für sich... und ab mehr als einem Monitor auch ziemlich zickig...