Beiträge von brunna

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


    First of all thank you for your help!

    I tried this in the commonApi Script Thread:

    Code
    local building = game.interface.getEntity(8546); game.interface.upgradeConstruction(building.id, building.fileName, building.params)

    I got this:

    Second attempt:

    If I run this code in the Script Thread, I get the information about a construction.

    Code
    commonapi.dmp (game.interface.getEntity(8546))

    If i run this than i don't get any error:

    Code
    local building = commonapi.dmp (game.interface.getEntity(8546))

    But i can't read or print the "building" variable. I got this error when i try it:

    Code
    [string "building"]:1: syntax error near <eof>

    I don't know that this varieble has values or not.

    I tried this also but I got an error:

    Code
    commonapi.dmp (game.interface.upgradeConstruction(building.id, building.fileName, building.params))
    
    Console::Execute: [string "commonapi.dmp (game.interface.upgradeConstruc..."]:1: attempt to index global 'building' (a nil value)

    I don't know that how should i use the commonApi.

    Could anyone write an example of a code that upgrades a construction? Please!

    I think after that I can finished it.

    I tried but got an error. :(

    Hi!


    Me as an "Schönbau" creator i like when a line has a huge of variations of trains, many kinds of trains pass through.

    Previously, i solved this by creating one train storage station:

    Speciel Stations


    My problem was with this solution that the game had to simulate too much trains. This had an effect on performance. And the trains came continuously (not randomly).

    So I created a mode for my save game that can replace the trains randomly from an array, on the selected stations.

    I use my script with my save game with about 50 lines and the arrays have more than 100 vehicles.

    I made an simple save game to show how it works.

    SaveGame


    -It read the train arrays.

    -Checks the trains and their last stops in the update function.

    -If a train has departed from the "replacer" station, then the train got the id of next stop as "stopIndex".

    -The program will realise it and replace the train for another one from the correct array.

    More details in the: random_train_generator.lua


    -- Attention!!!!!!!!!!!!

    -- This mod works with only one save game! You have to copy it as a new one to reuse it for another save!

    -- If you want to delete a train or a line than you must delete first must it here and then in the game!

    -- The mod can be disabled in any time!

    -- Some modded vehicles does not work with this version. But most of them works correctly!

    -- If you have a dump than you can see the last replaced vehicle in the stdout.txt (Line name, array index, train id).

    -- If a vehicle cause a dump then you have to delete the line from the array (array index)!


    I am not a professional mod creator. I am a programmer for the business sector. I created it as a hobby.

    It's not a complete mod. It's an alpha version concept without error handling.

    It can be more dynamic and better.


    I just let it here. Maybe it's a good example for future mods.

    Ich hab es gemacht. Beispiel:


    vehicle1 = game.interface.getEntity (9333)

    config = api.type.TransportVehicleConfig.new()

    tpart = api.type.TransportVehiclePart.new()

    vpart = api.type.VehiclePart.new()


    modelid = api.res.modelRep.find ("vehicle/train/nohab.mdl")


    vpart.modelId = modelid

    vpart.loadConfig = { 0 }

    tpart.part = vpart

    tpart.purchaseTime = 4399000

    tpart.autoLoadConfig = { 0 }

    config.vehicles[1] = tpart

    config.vehicleGroups = {1}


    cmd = api.cmd.make.replaceVehicle (vehicle1.id, config)

    api.cmd.sendCommand(cmd, callback)

    Ich habe die TransportVehicleConfig mit der CommonAPI2- 20200630 überprüft. Vielen Dank für diese API! ;)


    {

    vehicles = {

    <metatable> = {

    __index = <function 1>,

    __ipairs = <function 2>,

    __len = <function 3>,

    __name = "sol.std::vector<TransportVehiclePart,std::allocator<TransportVehiclePart> >*", --Hier ist das TransportVehiclePart.

    __newindex = <function 4>,

    __pairs = <function 2>,

    add = <function 5>,

    at = <function 6>,

    clear = <function 7>,

    empty = <function 8>,

    erase = <function 9>,

    find = <function 10>,

    get = <function 11>,

    insert = <function 12>,

    next = <function 13>,

    pairs = <function 2>,

    set = <function 4>,

    size = <function 3>

    }

    },

    vehicleGroups = {

    <metatable> = {

    __index = <function 14>,

    __ipairs = <function 15>,

    __len = <function 16>,

    __name = "sol.std::vector<int,std::allocator<int> >*", -- Aber ich weiß das nicht.

    __newindex = <function 17>,

    __pairs = <function 15>,

    add = <function 18>,

    at = <function 19>,

    clear = <function 20>,

    empty = <function 21>,

    erase = <function 22>,

    find = <function 23>,

    get = <function 24>,

    insert = <function 25>,

    next = <function 26>,

    pairs = <function 15>,

    set = <function 17>,

    size = <function 16>

    }

    },

    Ich fand, dass die config.vehicles damit kompatibel ist: api.type.TransportVehiclePart.new ()


    z.B.:


    config = api.type.TransportVehicleConfig.new()

    part = api.type.TransportVehiclePart.new()

    config.vehicles[1] = part


    >> part

    {

    part = {

    modelId = -1,

    reversed = false,

    loadConfig = {

    },

    color = {

    x = -1,

    y = -1,

    z = -1,

    },

    logo = "",

    },

    purchaseTime = 0,

    maintenanceState = 1,

    targetMaintenanceState = 0,

    }

    Aber ich habe einen Dump bekommen, als ich diesen benutzt habe. Ich bin mir nicht sicher mit der "modelId". Und ich weiß nicht, welcher Typ mit den config.vehicleGroups kompatibel ist. :(

    Zuerst habe ich das gemacht:


    >> game.interface.getVehicles()

    { 9333, 10452, }


    config = api.type.TransportVehicleConfig.new()

    vehicle = game.interface.getEntity (9333)


    >> config

    {

    vehicles = {

    },

    vehicleGroups = {

    },

    }


    >> vehicle

    {

    allCapacities = {

    PASSENGERS = 66,

    },

    capacities = {

    PASSENGERS = 66,

    },

    cargoLoad = { },

    carrier = "RAIL",

    depot = -1,

    id = 9333,

    line = 2038,

    name = "Train 1",

    position = { 832.64373779297, 604.01354980469, 28.684226989746, },

    speed = 19.335018157959,

    state = "EN_ROUTE",

    stopIndex = 1,

    type = "VEHICLE",

    vehicles = {

    {

    color = { -1, -1, -1, },

    condition = 1,

    fileName = "vehicle/train/br_185_traxx.mdl",

    loadConfig = { -1, },

    logo = "",

    purchaseTime = 59600,

    reversed = false,

    },

    {

    color = { -1, -1, -1, },

    condition = 1,

    fileName = "vehicle/waggon/ew_iv.mdl",

    loadConfig = { -1, },

    logo = "",

    purchaseTime = 59600,

    reversed = false,

    },

    {

    color = { -1, -1, -1, },

    condition = 1,

    fileName = "vehicle/waggon/ew_iv.mdl",

    loadConfig = { -1, },

    logo = "",

    purchaseTime = 59600,

    reversed = false,

    },

    {

    color = { -1, -1, -1, },

    condition = 1,

    fileName = "vehicle/waggon/ew_iv.mdl",

    loadConfig = { -1, },

    logo = "",

    purchaseTime = 59600,

    reversed = false,

    },

    },

    }


    >> config.vehicles = vehicle.vehicles

    error: [string "config.vehicles = vehicle.vehicles"]:1: stack index -1, expected userdata, received table: value is not a valid userdata

    stack traceback:

    =[C](-1): ?

    =[C](-1): __newindex

    config.vehicles = vehicle.vehicles(1): ?


    Leider bleibt die config.vehicles leer. :(

    Ich brauche Hilfe.

    Ich möchte einen Mod schreiben, der Fahrzeuge zufällig aus einem Array ersetzt. (Züge)

    Ich habe die richtige Funktion gefunden:

    >> game.interface.getVehicles()

    { 10452, 10453, }

    vehicle1 = game.interface.getEntity (10452)

    vehicle2 = game.interface.getEntity (10453)

    config = api.type.TransportVehicleConfig.new()

    cmd = api.cmd.make.replaceVehicle (vehicle1.id, config)

    api.cmd.sendCommand(cmd, callback)

    Aber ich kann die "TransportVehicleConfig" nicht richtig mit Daten laden.

    >> config

    {

    vehicles = {

    },

    vehicleGroups = {

    },

    }


    https://transportfever2.com/wi…ml#TransportVehicleConfig

    Könnte mir jemand ein Beispiel dafür schreiben?

    Kann mir jemand ein Beispiel für diese Funktion schreiben "replaceVehicle"? Ich habe es mit die Console getestet, aber ich konnte die Parameter nicht richtig angeben.


    sol.CmdData::ReplaceVehicle.


    >> api.cmd.make.replaceVehicle

    {

    __doc__ = "(Entity vehicleEntity, TransportVehicleConfig config) -> Command",

    }


    Ich habe das versucht:


    game.interface.getVehicles ()

    { 9333, 10452, }


    local vehicle


    vehicle = game.interface.getEntity (10452)


    api.cmd.make.replaceVehicle ( 9333, vehicle.vehicles )

    It's works for me now!!!


    First: I copied every files (EXCEPT THE: .mdl files) from the original mods folder to the emergency mod folder also! AFTER THIS I made the conversion.

    An idea:
    A vehicle replacement list for the lines would be cool. If
    we could add more, different vehicles for replacement. The auto
    replacement could select an vehicle randomly or sequentially.
    I like to use multiple trains on the lines. And it's a horror to replace them one by one.



    I hope someone will make it or will be available in the Transport Fever 2. 8|