Beiträge von brunoais

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,

    Once I have an UI element that is used for coloring, for example:


    Code
    e:getName()
    "LineColorComp"

    How can I get its color? Maybe there's a background color? or maybe some painting of some sort? Maybe it's a style in the stylesheet?

    Assuming it's colored using a style class, is there a way to get the style class of the element? I can't find anything in the classutil.lua about that.


    If it's as the manual states:

    Zitat

    To find out the name or class of an ui element, you can use the ingame tools to pick elements. Then the name of the element that the cursor points on is visible in the console.

    But I want to know the class. Here states I can pick an element and know the name. I want to know the class and I don't just want to know through the console. I want to know programatically.

    Hum...

    Given a station (transfStation), I can:


    Code
    s2e = api.engine.system.catchmentAreaSystem.getStation2edgesMap()
    stationEntities = {}
    for j = 1,#s2e[transfStation] do stationEntities[s2e[transfStation][j].entity] = 1 end

    Then I get the entities related to a station as the keys. Some of them will be industries. In this case, I know only one is an industry.

    This connects from a station entity to an industry entity.

    However, after having an industry, I have no idea how to get the stock. maybe it's the STOCK_LIST which shows userdata. Maybe this means I need to use the old API with the "game" at the top level.

    If that's the situation, any idea where I can get the manual for that older API?

    I can also recommend the CommonAPI Inspector, it shows also all component contents

    Is that a mod?

    I see that there's this dummy mod that is here: https://steamcommunity.com/sha…iledetails/?id=1947572332

    Which has a link pointing to this website (does it do more than what's allowed in the workshop?)

    However, I can only find CommonAPI but not CommonAPI inspector. Because so much is in german, I can't find the way through it, even with the help of google translate...


    Edit: Found this one. I'll try to follow it: CommonAPI2 quickstart guide



    OK. I figured out and I was able to install successfully without crashing.


    This is what the inspector shows about STOCK_LIST in the refinery. I can't find anything about this in the modding manual. Is it a structure that is not implemented for LUA use yet?

    If you have the town id, you can get the NAME Component of that

    Oh! I get it now! There are multiple components for each thing... I see how I can get the names of things now.

    For others who just stumbled upon this, one can set the name using:

    Code
    api.cmd.sendCommand(api.cmd.make.setName(entityIf, "whateverNameI want"))


    Hmm you would need to find out if an industry is in the catchment area of your station. I don't know if thats possible.

    Look at system.catchmentAreaSystem or Transport Network Link System

    (Hint: Every Industry has 2 entities, one for the INDUSTRY and one for the CONSTRUCTION)

    Catchment area... I see, thank you. I see that's the system I should be looking for!

    Warning: Direkt indexing of getComponent results in low probability high impact errors!

    https://github.com/IncredibleH…TPF2-Timetables/issues/50

    I discovered this during exhaustive error search.

    Sadly, this is documented nowhere.

    No luck. Still nil...




    Any idea what can I do when I encounter a userdata response?

    How do I turn this into something I can use?


    Maybe I need to get a SimBuilding? However, I can only find getConstructionEntityForSimBuilding(), which only goes in the opposite way than how I want. I want the SimBuilding from the construction... Maybe I'm missing a component type I could use in a contruction id (such as the 3725 of previous code)?

    The problem:


    I want to make a mod that tries to guess what a line made by the user is used for.

    A cargo line may be used to grab oil and take to refinery to get refined oil. That same line or another line may take the refined oil and take to a fuel refinery which turns it into fuel which takes to nearby a town. In that station the cargo goes to another line until reaching a town that has the fuel need.

    I want to try to guess that, for those 2/3 lines, it's circuit of: "Oil -> refinedOil -> fuel -> townA"

    For the mod, I want to figure out through which lines the contents went to and through and then calculate from there.

    Finally, the mod would show some data to the user regarding that. So I will need to translate the Entities into names (still have no idea how) so the user doesn't just see numbers.


    I'm trying to follow the API manual: https://transportfever2.com/wiki/api/index.html

    Specially the engine part, which seems to contain most of these stuff: https://transportfever2.com/wi….html#getSimCargosForLine

    In detail:


    I know I can do:


    Code
    api.engine.system.lineSystem.getLines()

    Which gives me the lines that exist.

    That means I can execute:

    Code
    api.engine.getComponent(
        api.engine.system.lineSystem.getLines()[1], 
        api.type.ComponentType.LINE
    )

    Which will give me some of the information about the line (the name isn't here. Is it in api.gui?):



    That gives me the station group for each stop. That's useful.

    Now, with the station group, I can get the stations by getting the component


    Code
    api.engine.getComponent(
        api.engine.getComponent(
            api.engine.system.lineSystem.getLines()[1], 
            api.type.ComponentType.LINE
        ).stops[2].stationGroup
        , 
        api.type.ComponentType.STATION_GROUP)


    (with hardcoded knowledge), I can get the delivery station in the line (trucks deliver to town in this station):


    Code
    terminusDeliveryStation = api.engine.getComponent(api.engine.getComponent(api.engine.system.lineSystem.getLines()[1], api.type.ComponentType.LINE).stops[2].stationGroup, api.type.ComponentType.STATION_GROUP).stations[1]
    api.engine.getComponent(api.engine.system.stationSystem.getTown(terminusDeliveryStation), api.type.ComponentType.TOWN)

    This gives info about the town. Some info can be useful for me such as the cargo needs. However, where's the name of the town?


    Different part of the line now

    Now to choose a stop that has a factory that takes crude oil and transforms into refined oil. This is connected to a train line.

    Code
    transfStation = api.engine.getComponent(api.engine.getComponent(api.engine.system.lineSystem.getLines()[2], api.type.ComponentType.LINE).stops[2].stationGroup, api.type.ComponentType.STATION_GROUP).stations[1]
    api.engine.getComponent(api.engine.system.streetConnectorSystem.getConstructionEntityForStation(transfStation), api.type.ComponentType.CONSTRUCTION)


    This tells me a lot of information but nothing I can use to relate with the Refinery.

    In the manual, I find getConstructionEntityForSimBuilding(), which takes an industryEntity (https://transportfever2.com/wi…ctionEntityForSimBuilding). However, I can't find how to get the industry entity...


    How do I get the industryEntity in order to know what it takes as input and what it makes as output? Or is there another way to get that info?


    I've tried to investigate this way but nothing gained... I'm getting Nil


    What options am I missing?