LabelList and labelText

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 everyone

    I'm trying a few different things, which are new to me and which I never tried to put into my mods before. Now I have been reading about labelText and labelList .

    To study how this works, I have copied a vanilla bus Aboag to a new one and made a change in the mdl file. I changed the type to "CUSTOM" and renderMode to EMISSIVE, because I want to send a custom selected text from a construction, but it shouldn't work directly when studying. :(

    I need some help to get a hint on how the code should look like.


    I attach here the two files that I use for my test.

  • Hmm, where do I start.


    Ok, first I reset, I grab a fresh aboag_v2.mdl as base, then I changed there

    filter = "NUMBER", to filter = "NONE",


    I removed the whole vehicle related stuff...



    Then please note:


    To improve performance, for simple constructions that do not contain ground faces, terrain alignments, edges or depot/station/industry/town building definitions, there is no construction placed in the game but just the seperate mdls. These can not be configured afterwards or be deleted all at once. Furthermore these types of assets do not support the labelText custom texts from constructions.


    Without construction, no LabelText. So the build thing has to be configurable (clickable) -> component construction exists.

    Therefore I had to add a groundtexture to the result.


    Then TPF2 code wants 0 based indexes, so

    result.labelText = { [index-1] = {"Hallo", "B", "C"} }


    Note: The preview from the build cursor won't show labels. So you have to actually build the construction... Hope that helps...



    For CommonAPI2 users and heavy construction scripts, CommonAPI2 can show the internal LabelData as seen from C++ side, this may help in debugging:


    commonapi._native.LabelSystem.dumpConstructionLabels( api.engine.getComponent(181798, api.type.ComponentType.CONSTRUCTION) )

  • I am wondering if I can update a LabelText directly from a gamescript. In the confile I have access to the index of result.models, but I do not have this in my script.

    I have found some other mods that update in script, but those functions are called from a .con file and so you can easily include the "result" table in the call.


    I do find information in the MODEL_INSTANCE_LIST in the construction, where I can retrieve the modelId. However, with the modelId of the model that holds the labelList, I am unable to get the text to appear.

    Is this the right way to get to the goal?

    My gamescript runs in "function update()"

  • There is no setText api call. (you only can change the name, and this will change ecs::component::Name

    The only technical way (arrival boards as example) is to use an updateConstruction passing new data as params into it. Then your updateFn creates a new "plan". The construction builder then generates new components like MODEL_INSTANCE_LIST (for models) and CONSTRUCTION and so on.


    Note: It's not possible to directly write into an ecs component. You always have to use a command. (so it is propagated and all stuff knows about updates)


    Technical the label texts are stored into the ecs::component::Construction (that's why my dumpConstructionLabels needs the actual ecs::component::Construction as read only sol element)


    As soon as UG has finished (no more feature updates) TPF2 I consider adding a new cmd for changing texts... (I could not extend setName for this without breaking savegame compatibility, nor can I add a new command as it could collide with new cmds )

    There is special phase TPF2 applies all commands and a phase to copy all modifications to the ui thread..

  • Now I have come up with a dynamic construction, which puts a desired number in my display. However, I have a little problem as the number disappears from the display when I zoom out.

    With other models and materials I can always choose Polygon Offset and forceDeepWrite. In the case of labelText there is no material, so my question is is there any trick?


    The only thing I can think of is to increase the distance between labelText and the display, but then the text risks floating in the air in front of the display if you stand close and look.


  • After I succeeded in my first project, I am using my experience in my next one. I have now suddenly lost the display of Labeltext in the game. However, I can see the sample number "123" in the new model in the Model-editor. The position is clearly above the base surface and I have tried removing the base (the yellow square completely) and still no text is visible in the game.

    I have cleared the shader and texture case and right now I don't understand why the Model-editor can show but not in the game. Is there something I should check? It has been working a few days ago...


    (There is no error in the log file)



  • Here is my code snippet that I am now using for testing in the con file. I have also configured a number of groundFaces in the confile (not viewed in the snippet below), so that the construction is clickable in the game.

    The print result will be as follows:

    The strange thing is if I delete one of the initial ‘lane.mdl’ then the result on the labelText table becomes corrupt.


    This code example has one less mdl in initial configuration. I expect the labelText table to start at one index number lower than the first.

    Print result from second test:


    Note that the labelText table is completely different from the initial


    If I remove both lane.mdl configurations and start directly with my .mdl, I get even more strange results on the labelText table.


    My interpretation of these results is that when LabelText is given index [1], things happen that you would not expect.

    Unfortunately, I haven't yet found the reason why I don't get any text in the game. :(

  • Now I've found the cause and it's so incredible I can hardly believe it's true.


    I started developing my design as a station, but a few days ago I changed it to an industry. After some more time, I happened to see that labelText was not visible on some of the objects.


    It is quite clear that labelText does not work on objects in a construction defined as industry.

    Reading on the TpF2 Wiki, I understand the description in a different way.

    Am I interpreting the text wrong, should it not be possible to use industry?


    I have redone a similar test as before but now with ‘type = “RAIL_STATION_CARGO”,’ and an extra object with labelText, so the three get index 0, 1 and 2. The table labelText looks strange to me, but the result works in the game.


    If I put two or more .mdl objects before the objects containing the labelText definition, the index number of each labelText appears on the left of all rows. It is for me somewhat confusing.