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:
Codelocal building = game.interface.getEntity(8546); game.interface.upgradeConstruction(building.id, building.fileName, building.params)
I got this:
Code
Alles anzeigen..\..\src\Lib\lua\Value.cpp:38: class std::variant<struct lua::Nil,bool,double,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct lua::Table> &__cdecl lua::Table::Put(const class std::variant<struct lua::Nil,bool,double,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct lua::Table> &,class std::variant<struct lua::Nil,bool,double,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct lua::Table> &&): Assertion `pr.second' failed. Console::Execute: [string "local building = game.interface.getEntity(854..."]:1: internal error > Exception type: Fatal error > > Details: > > Error message: Assertion `pr.second' failed. > > Minidump: D:/Steam/userdata/189143849/1066780/local/crash_dump/e74c5161-d828-4fea-b0e2-d349b4cd7abf.dmp > > In file: ..\..\src\Lib\lua\Value.cpp:38 > > In function: class std::variant<struct lua::Nil,bool,double,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct lua::Table> &__cdecl lua::Table::Put(const class std::variant<struct lua::Nil,bool,double,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct lua::Table> &,class std::variant<struct lua::Nil,bool,double,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct lua::Table> &&) >
Second attempt:
Code
Alles anzeigenlocal building = game.interface.getEntity(8546); building.personCapacity = { }; game.interface.upgradeConstruction(building.id, building.fileName, building.params) ..\..\src\Lib\lua\Value.cpp:38: class std::variant<struct lua::Nil,bool,double,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct lua::Table> &__cdecl lua::Table::Put(const class std::variant<struct lua::Nil,bool,double,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct lua::Table> &,class std::variant<struct lua::Nil,bool,double,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct lua::Table> &&): Assertion `pr.second' failed. Console::Execute: [string "local building = game.interface.getEntity(854..."]:1: internal error > Exception type: Fatal error > > Details: > > Error message: Assertion `pr.second' failed. > > Minidump: D:/Steam/userdata/189143849/1066780/local/crash_dump/edb17fcf-31a0-44ef-a1ae-849fe62cabe9.dmp > > In file: ..\..\src\Lib\lua\Value.cpp:38 > > In function: class std::variant<struct lua::Nil,bool,double,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct lua::Table> &__cdecl lua::Table::Put(const class std::variant<struct lua::Nil,bool,double,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct lua::Table> &,class std::variant<struct lua::Nil,bool,double,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct lua::Table> &&)
-
If I run this code in the Script Thread, I get the information about a construction.
If i run this than i don't get any error:
But i can't read or print the "building" variable. I got this error when i try it:
I don't know that this varieble has values or not.
I tried this also but I got an error:
Codecommonapi.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.
-
Thanks for the Tipp! Unfortunately I also get bugs with commonApi. Maybe later there will be an api update or a mod that will help me.
-
I tried but got an error.
Code
Alles anzeigen>> building = game.interface.getEntity(415986) >> building { baseEdges = { }, baseNodes = { }, dateBuilt = { day = 1, month = 1, year = 2021, }, depots = { }, fileName = "placeholders/generic.con", id = 415986, name = "no name", params = { assetBrush_brush = 1, assetBrush_rotation = 0, assetBrush_size = 0, assetBrush_slope = 0, assetBrush_slopeInvert = 0, assetBrush_strength = 19, assets = 0, bbhf_depot_1 = 0, building = 17, capacity = 5, paramX = 0, paramY = 0, randomize = 1, road = 0, seed = 273, skipcollision = 0, snowball_fences_adjust = 1, snowball_fences_collision = 0, snowball_fences_face = 0, snowball_fences_mode = 0, snowball_fences_offset = 0, street_connection = 0, terrainPainter_brush = 1, terrainPainter_rotation = 0, terrainPainter_size = 8, terrainPainter_slope = 0, terrainPainter_slopeInvert = 0, terrainPainter_strength = 19, terrain_brush = 1, terrain_rotation = 0, terrain_size = 31, terrain_strength = 19, ["tree/azalea.mdl"] = 1, ["tree/common_hazel.mdl"] = 1, ["tree/elderberry.mdl"] = 1, ["tree/european_linden.mdl"] = 1, ["tree/red_delicious_apple.mdl"] = 1, ["tree/scots_pine.mdl"] = 1, ["tree/shingle_oak.mdl"] = 1, ["tree/sugar_maple.mdl"] = 1, type = 1, year = 2021, }, particleSystems = { 415987, }, personCapacity = { capacity = 5, type = "RESIDENTIAL", }, position = { 6945.9096679688, 5206.4521484375, 31.820449829102, }, simBuildings = { }, stations = { }, townBuildings = { }, transf = { 0.41147258877754, 0.91142213344574, 0, 0, -0.91142213344574, 0.41147258877754, 0, 0, 0, 0, 1, 0, 6945.9096679688, 5206.4521484375, 31.820449829102, 1, }, type = "CONSTRUCTION", } >> game.interface.upgradeConstruction(building.id, building.fileName, building.params) error: [string "game.interface.upgradeConstruction(building.i..."]:1: attempt to call field 'upgradeConstruction' (a nil value) stack traceback: =[C](-1): upgradeConstruction game.interface.upgradeConstruction(building.id, building.fileName, building.params)(1): ?
-
Wow thank you! Very useful !!!
-
All right! And how can I upgrade? Is there an example of that?
Should I read the constructs to an array and update them in a cycle?
I can read the constructions. But I'm not sure how I can update them.
-
Hi!
I built a lot of houses with an old mod. Many houses have a huge personCapacity without cars.
I plan to run a script that reduces the personCapacity to 1 or 0 if the BASE_EDGE property is empty.
Is there a way to change the property of a CONSTRUCTION entity?
Thank you in advance for your answer!
-
Yes. Thank You! Now I spend more time playing a game and not modifying. But i wanted to watch my trains come randomly, like in real life (mostly the freight trains).
-
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:
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.
-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 vehiclevehicle = 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.
-
Hi!
I tried to convert this mod:
T5-Einsatz- und Servicefahrzeuge aus Deutschland
I have not any errors but the cars have not wheels rendered.
But this:
https://www.transportfever.net/filebase/index.php?entry/3980
original mod works fine after the convertion.
I tried to convert this mod also:
https://www.transportfever.net/filebase/index.php?entry/2880
And i have same bug, the waggons have not wheels.
Can anybody help me?
-
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.
-
And... What Can I do ? Are there some solutions?