Beiträge von melectro

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


    Here are the results from the Swedish test....;)


    Following part of the code has been examined and measured. It will show the difference between of using CONSTRUCTION and SIM_BUILDING table to find CARGO at stock in a selected industry. In this example I have only placed one unique industry among many vanilla industries on my test map. I have removed the logic after the industry has been found, so this is showing the time it takes just to find the industry on a small map in the beginning of a new game. It will be worse as longer the game is running, as more buildings will increase the CONSTRUCTION table.


    In this experiment I got 69 items in the SIM_BUILDING table and 1584 items in the CONSTRUCTION table


    code used time (ms)
    game.interface.getEntities "CONSTRUCTION"3 to 4
    game.interface.getEntities "SIM_BUILDING"1 to 3
    for loop using SIM_BUILDING3 to 4
    for loop using CONSTRUCTION48 to 54


    The results I got confirms what I saw earlier as each game script loop is repeated about every 200ms. Using CONSTRUCTION table has a big impact on the performance as it takes about 25% to execute. The time will also vary depending on the computer system. This was tested on a computer based on, Intel(R) Core(TM) i9-9900KF CPU @ 3.60GHz, 32.0 GB, Geforce RTX 2080, CPU is running @ 4800 MHz and GPU @ 1965 MHz.

    Does your code work?

    Yes it works, but I'm not sure if it is the best efficient. I could see without any time measuring an enormous improvement after using SIM_BUILDING table instead of CONSTRUCTION. As I wrote the SIM_BUILDING table has less data.

    In the SimBuilding Data, the "stockList" Property is always the construction ID right?

    I hope it is so. All industries that I now have studied has the same value.



    melectro wrote (in removed post)

    Yes, true. I removed it as other parts in the text was wrong. I never came to rewrite it as you eis_os were so quick to answer:thumbup:

    You can get all industries with

    I can definitely see the benefit of using SIM_BUILDING as this table currently contains 69 entities against 1584 if CONSTRUCTION is used for the loop search.

    If I now use eis_os excellent API function Inspector and look at the entity value for SIM_BUILDING, I can not find a "fileName". The name shown to the right in the list above, is editable by the player and therefore it can not be used.

    If the stockList always contains the same value as CONSTRUCTION Entity as eis_os wrote "should"

    Yeah, the construction should have the stocklist.

    and I assume since previous post, then it's clear to me to use SIM_BUILING Entities followed by a second read in the CONSTRUCTION entity table and that will reduce the CPU load as it doesn't need a large search loop through all the data, but still I need the CONSTRUCTION Entites table to get "fileName", or am I wrong?


    Code
    local Constructions = game.interface.getEntities({ pos = {0,0}, radius = math.huge }, { type = "CONSTRUCTION" })


    VacuumTube I can not figure out what the continuation should be like to find the factory if my code below isn't what you have in your mind, The code gives me the Cargo @stock, but is it the most efficient and least system demanding? I read about "for _,id in pairs(IDs) do -- _ for unneeded variable", like Claude I have some difficulties to follow that type of setup. A question, will it do the loop more efficient? Please describe.

    FYI, I have studied the helpful thread: getEntities => type ? - Modding Allgemein - Transport Fever Community

    Here is what SIM_BUILDING reports: (the list was too long to fit in one screendump.)

    I can make you happy by telling: I have your API installed, and it is very versatile and advanced. For me this has been a huge step to pass. I and probably many others wishes some kind of manual or tutorial.


    In the post above you make it clear for me to follow this part of your API. I assume there are a lot of more functions that you have put into the package,


    Long time has passed and today I finally got the information on where to find all the names that can be used in the calls, thanks to your API !


    I can also see the data and I can see that the stocklist value in your print screen has the same value as the entity of the construction = 14088. In my game it is also the same 25237, is this a coincidence or is it always the same value?


    if I interpret the information I see in the Inspector, I do not find the file name anywhere (in SIM_BUILDING) other than under CONSTRUCTION.

    To find only the factories I am interested in, I currently see no other solution than to get this huge amount of data from CONSTRUCTION, if that is what you mean with "madness".


    I'll continue my experiments tomorrow, for now a big Thank you to you !

    I do not get any data from the script out from the factory. (The factory is producing goods and there are incoming goods in stock and products is leaving the factory to a nearby station)

    I have the Entity id (Entities[i] = 25237, #Entities = 1) and CompType= 27 ( = SIM_BUILDING)

    but after the call to local Comp = api.engine.getComponent(Entities[i], CompType)

    I get only a nil value on the Component.


    But when I test to set CompType = STOCK_LIST, I get different values for each program loop, last value was userdata = 000001C6DB72D188


    I guess that the userdata is a pointer address to a table. It doesn't feel right, that's why I write this to ask for more assistance.

    I have found in an old TpF1 code, this solution: (it seems to work even in TpF2)

    allConstructions = game.interface.getEntities({ pos = {0,0}, radius = 900000 }, { type = "CONSTRUCTION" })


    in this table I can get the EntityId for the needed factories , so the next step to find the cargo stored at these factories would be using something that you wrote.


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

    But as I'm not allowed to ask you how to get the "StockListId", I have to continue the guessing.

    By the way earlier this year I pointed on a strange info in the Wiki list. There are two SimEntityAtBuilding

    one for "entities waiting at industries".and the second for "entities waiting at buildings". After emailing UG I got the answer that the first one (for industry) is wrong it should be named: SimEntityAtStock.

    It is still not updated.

    Anyway, by using the right name this could probably be the way to get the stockListId, or am I totally wrong?

    Hi


    I have downloaded the demo clock script from the Wiki, and from this working example I add my own code to see what can be done. But the first few lines I add create a headache for me.

    Code
       -- search for new industries
            local allConstructions = api.res.constructionRep.getAll()
            print ("allConstructions =",#allConstructions ," /UG_melectro_demo_clock")
            for i = 0,    #allConstructions-1 do
                if allConstructions[i] == "industry/tools_factory.con" then
                    print ("Construction name =",allConstructions[i] ," /UG_melectro_demo_clock")
                end
            end    

    The code works so far that it can find one Tool factory and it is printed in the console.


    I was happy to see that in my new free game i got 538 constructions, but while adding more industries or f.eg. railway stations, it will not increase the number of "allConstructions".


    What is wrong?


    is this the result as the function is only run one time ?

    Hallo Nando


    In einem kommenden Mod habe ich die folgenden Zeilen (im mod.lua) verwendet, um eine Audiodatei (soundSet) vom Englischen ins Deutsche zu ersetzen. Dies sollte teilweise für den Sound der Trucks funktionieren.


    Hallo Nando


    Ich weiß nicht ob ich diesen Wunsch bekomme, deine Trucks sind so schön, aber ich finde sie haben einen zu aggressiven Sound. Es wird ein bisschen zu viele Lastwagen geben, die mit einer störenden Auspuffanlage herumfahren. Könnten Sie erwägen, den Sound zu ersetzen oder in einem Menü auswählbar zu machen, damit Sie Vanilla oder Ihr Original auswählen können?

    I'm looking for a function to be used in the mod.lua (runFn). It should read the language setting.

    After testing the api.util that I found in the Wiki

    getLanguage()Returns the current language settings

    I get only errors. .... "attempt to index field 'util' (a nil value)"



    How do I use it right?

    local language = api.util.getLanguage()

    Here is my latest test result on soundSet


    soundsetutil.addEventParam01(data, "random32", {"test.wav"}, 30.0,

    { { 1.2, 1.2 } }, { { 1.05, 1.05 } }, "crowd01")


    Valid values for the random event in soundset is working when values are selected binary, 1, 2, 4, 8, 16, 32, 64.

    I get no sound on other values.


    When valid value is selected it will not be a randomly selected time on individual sounds. If two construction placed nearby have "random" soundsets with same value they will end up almost synchronized. Every time the sounds are triggered it will be heard from the other construction in same time difference.