Transport Fever 2

Transport Fever 2

War Express
This topic has been locked
Pumpkin 26 Dec, 2020 @ 5:34am
Crash
I like idea of war in TF but i got crash everytime i try start new game with your mod + reguired one :( im not using anything else
Please help



This error is usually caused by modding. Some game resources contain incorrect data.

Details:

Error message: error: [string "C:/Users/Owner/AppData/Roaming/Transport Feve..."]:439: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
=[C](-1): ?
=[C](-1): pairs
C:/Users/Owner/AppData/Roaming/Transport Fever 2/mods/2329762188_mod_for_the_war_express_3_0/res/config/game_script/war_express.lua(439): ?


File name: C:/Users/Owner/AppData/Roaming/Transport Fever 2/mods/2329762188_mod_for_the_war_express_3_0/res/config/game_script/war_express.lua

Key: game/res/gameScript/war_express.lua_guiUpdate

Minidump: C:/Users/Owner/AppData/Roaming/Transport Fever 2/crash_dump/7e7df027-e100-48a9-b535-0b3761cd3dfc.dmp

Mod: "Mod for the 'War Express' map" (consider removing this mod and contacting the mod author)

In file: c:\build\tpf2_gog\src\lib\lua\state.cpp:586

In function: void __cdecl lua::State::Call(int,int)


__CRASHDB_CRASH__ struct lua::LuaException: c:\build\tpf2_gog\src\lib\lua\state.cpp:586: void __cdecl lua::State::Call(int,int): error: [string "C:/Users/Owner/AppData/Roaming/Transport Feve..."]:439: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
=[C](-1): ?
=[C](-1): pairs
C:/Users/Owner/AppData/Roaming/Transport Fever 2/mods/2329762188_mod_for_the_war_express_3_0/res/config/game_script/war_express.lua(439): ?

Exception type: Lua exception

This error is usually caused by modding. Some game resources contain incorrect data.

Details:

Error message: error: [string "C:/Users/Owner/AppData/Roaming/Transport Feve..."]:439: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
=[C](-1): ?
=[C](-1): pairs
C:/Users/Owner/AppData/Roaming/Transport Fever 2/mods/2329762188_mod_for_the_war_express_3_0/res/config/game_script/war_express.lua(439): ?


File name: C:/Users/Owner/AppData/Roaming/Transport Fever 2/mods/2329762188_mod_for_the_war_express_3_0/res/config/game_script/war_express.lua

Key: game/res/gameScript/war_express.lua_guiUpdate

Minidump: C:/Users/Owner/AppData/Roaming/Transport Fever 2/crash_dump/7e7df027-e100-48a9-b535-0b3761cd3dfc.dmp

Mod: "Mod for the 'War Express' map" (consider removing this mod and contacting the mod author)

In file: c:\build\tpf2_gog\src\lib\lua\state.cpp:586

In function: void __cdecl lua::State::Call(int,int)
Last edited by Pumpkin; 26 Dec, 2020 @ 5:46am
< >
Showing 1-13 of 13 comments
Mats  [developer] 26 Dec, 2020 @ 9:34am 
Hi pumpkinworld1986

Maybe it works after you reinstall both mods; the map and the mod...?
And then:
- Start Transport Fever 2
- Click FREE GAME
- Click PLAY MAP
- Select War Express. Make sure there is only 1 mod listed in the mod list (the war express mod).
- Click START.

Does it still crash?
Cavalier Roy 30 Dec, 2020 @ 7:16am 
I get the same crash, reinstalled both mods multiple times and still crashes. I have not got experimental map size set to true just in case that was behind the crash. I will try checking the games file integrity now to make sure nothing happened during some update or something as i haven't played TF2 for a long time and there have been updates since i last played.

After checking file integrity and again reinstalling the map and the mod, the game still uploading into the map crashes before the map loads in.
Last edited by Cavalier Roy; 30 Dec, 2020 @ 7:35am
Mats  [developer] 30 Dec, 2020 @ 12:02pm 
Thanks. What is your TPF2 build?

This is hard for me to fix because I don't have this problem on my pc. Could you change the following code in the war_express.lua file, which is situated in C:/Users/Owner/AppData/Roaming/Transport Fever 2/mods/2329762188_mod_for_the_war_express_3_0/res/config/game_script/war_express.lua or "C:\Program Files (x86)\Steam\steamapps\workshop\content\1066780\2329762188\res\config\game_script\war_express.lua" or something similar:

OLD:

for _,quest in pairs(gui_info.quests) do
battles[quest.entity] = true
end

NEW:

if gui_info.quests ~= nil then
for _,quest in pairs(gui_info.quests) do
battles[quest.entity] = true
end
end

Does it still crash? And if so, could you post the error message?
Mats  [developer] 30 Dec, 2020 @ 5:39pm 
Thanks. That is promising. Now let's do the same trick again:

OLD:

-- Post news in popup
if #gui_info.news_for_gui > last_popup and gui_info.news_for_gui then

NEW:

-- Post news in popup
if gui_info.news_for_gui ~= nil then
if #gui_info.news_for_gui > last_popup and gui_info.news_for_gui then

OLD:

gui_info.news_for_gui = {}

end
end

-- Time and speed

NEW:

gui_info.news_for_gui = {}

end
end
end

-- Time and speed




Let me know :)
Cavalier Roy 30 Dec, 2020 @ 5:49pm 
Nope sadly it still crashes

https://imgur.com/12UUPYE
Mats  [developer] 30 Dec, 2020 @ 6:12pm 
Ok. Hopefully this is the last one:

OLD
if data_to_save ~= nil then
-- Check quest progress: if battle is won or lost
NEW
if data_to_save ~= nil then
if data_to_save.quests ~= nil then
-- Check quest progress: if battle is won or lost

OLD

end
end
end
end
end,

save = function()

NEW

end
end
end
end
end
end,

save = function()
Cavalier Roy 31 Dec, 2020 @ 2:56am 
Sorry it was late but sadly it still crashed https://imgur.com/YNTAaeY
Mats  [developer] 31 Dec, 2020 @ 3:29am 
That's a syntax error, so I think something went wrong replacing the code. It should look like this:


if data_to_save ~= nil then
if data_to_save.quests ~= nil then
-- Check quest progress: if battle is won or lost
local quests_completed = {}
for quest_no,quest in pairs(data_to_save.quests) do
if current_date.day == quest.day and current_date.month == quest.month and current_date.year == quest.year then
-- Battle lost
api.cmd.sendCommand(api.cmd.make.setName(game.interface.getEntity(quest.entity).simBuildings[1], 'Battlefront '..quest.from_city..'-'..quest.to_city))
city_surrenders(quest.from_city, data_to_save.opposite_side)
city_surrenders(quest.to_city, data_to_save.opposite_side)
quests_completed[quest_no] = true
elseif os.time({day=current_date.day, month=current_date.month, year=current_date.year+100}) < os.time({day=quest.day, month=quest.month, year=quest.year+100}) and game.interface.getEntity(quest.entity).params.productionLevel >= quest.level then
-- Battle won
api.cmd.sendCommand(api.cmd.make.setName(game.interface.getEntity(quest.entity).simBuildings[1], 'Battlefront '..quest.from_city..'-'..quest.to_city))
city_surrenders(quest.from_city, data_to_save.side)
city_surrenders(quest.to_city, data_to_save.side)
quests_completed[quest_no] = true
end
end
for quest_no,_ in pairs(quests_completed) do
data_to_save.quests[quest_no] = nil
end

-- Make new quests (being attacked)
math.randomseed(os.time())
if current_date.day == 1 and params.quest_months[current_date.month] == true then
local yearmonth = tostring(current_date.year).."-"..tostring(current_date.month)
if data_to_save.quest_months_done[yearmonth] == nil then
local warfronts = {}
for from_city,cities in pairs(params.industries.battlefront) do
for to_city,entity in pairs(cities) do
if data_to_save.side_per_city[from_city] ~= data_to_save.side_per_city[to_city] then
local entity_found = false
for _,quest in pairs(data_to_save.quests) do
if quest.entity == entity then
entity_found = true
end
end
if entity_found == false then
warfronts[#warfronts+1] = {entity=entity, from_city=from_city, to_city=to_city}
end
end
end
end
if #warfronts > 0 then
local warfront = warfronts[math.random(1,#warfronts)]
new_quest(warfront, false)
end
end
data_to_save.quest_months_done[yearmonth] = true
end

-- Make new quests (attacking)
for from_city,cities in pairs(params.industries.battlefront) do
for to_city,entity in pairs(cities) do
if data_to_save.side_per_city[from_city] ~= data_to_save.side_per_city[to_city] then
if #api.engine.system.simCargoSystem.getSimCargosForTarget(entity) > 0 then
local entity_found = false
for _,quest in pairs(data_to_save.quests) do
if quest.entity == entity then
entity_found = true
end
end
if entity_found == false then
warfront = {entity=entity, from_city=from_city, to_city=to_city}
-- Attacked city found
new_quest(warfront, true)
end
end
end
end
end

-- Check for vehicles in opponents area
local cost = 0
local model_id = nil
local cond = 1
local price = 0
local vehicles_to_destroy = {}
for _,vehicle in pairs(game.interface.getVehicles()) do
for zone,area in pairs(params.zones) do
if data_to_save.side_per_city[zone] ~= data_to_save.side then
if polygonutil.contains(area,game.interface.getEntity(vehicle).position) then
cost = 0
-- Get costs
for _,vehicle_table in pairs(game.interface.getEntity(vehicle).vehicles) do
if vehicle_table then
model_id = api.res.modelRep.find(vehicle_table.fileName)
if model_id then
price = api.res.modelRep.get(model_id).metadata.cost.price or 0
cond = vehicle_table.condition or 1
cost = cost + cond * price
end
end
end
vehicles_to_destroy[vehicle] = cost
end
end
end
end
local vehicles_destroyed = 0
for vehicle,cost in pairs(vehicles_to_destroy) do
-- Sell vehicle
api.cmd.sendCommand(api.cmd.make.sellVehicle(vehicle))
-- Book costs
game.interface.book(-cost, false)
vehicles_destroyed = vehicles_destroyed + 1
end
if vehicles_destroyed == 1 then
data_to_save.news_for_gui[#data_to_save.news_for_gui+1] = {entity = nil, text = tostring(vehicles_destroyed)..' of your vehicles was destroyed by the '
..data_to_save.opposite_side..' forces! Do not operate vehicles in their territory.', music='missionFailure'}
elseif vehicles_destroyed > 1 then
data_to_save.news_for_gui[#data_to_save.news_for_gui+1] = {entity = nil, text = tostring(vehicles_destroyed)..' of your vehicles were destroyed by the '
..data_to_save.opposite_side..' forces! Do not operate vehicles in their territory.', music='missionFailure'}
end

-- Check of the player has won or lost the war
if current_date.year > params.start_date.year then
if data_to_save.war_over == false then
local war_lost = true
local war_won = true
for city,side in pairs(data_to_save.side_per_city) do
if side == data_to_save.side then
war_lost = false
else
war_won = false
end
end
local number_of_days = math.floor(os.difftime(
os.time({day=current_date.day, month=current_date.month, year=current_date.year+100,}),
os.time({day=params.start_date.day, month=params.start_date.month, year=params.start_date.year+100,})
) / (24*60*60))
if war_lost == true then
data_to_save.news_for_gui[#data_to_save.news_for_gui+1] = {entity = nil, text = 'You lost the war after '..tostring(number_of_days)..
' days! Europe is now ruled by the '..data_to_save.opposite_side..' forces... Try again another time. Thanks for playing War Express.', music='missionFailure'}
data_to_save.war_over = true
end
if war_won == true then
data_to_save.news_for_gui[#data_to_save.news_for_gui+1] = {entity = nil, text = 'Congratulations, you won the war after '..tostring(number_of_days)..
' days! Thanks to you, the '..data_to_save.side..' forces emerged victorious. Peace has returned to Europe: from now on, it is free play. '..
'Thanks for playing War Express!', music='missionSuccess'}
data_to_save.war_over = true
end
end
end
end
end
end,

save = function()
-- Send news to GUI
return data_to_save
end,
Cavalier Roy 31 Dec, 2020 @ 3:47am 
Sadly still not working and to make sure i hadn't made a mistake i used pasted the coding above replacing the original coding https://imgur.com/AIJEzCK
Mats  [developer] 31 Dec, 2020 @ 4:07am 
Cavalier Roy 31 Dec, 2020 @ 5:09am 
Yay that worked thank you for your dedicated work fixing this so i can enjoy your work been looking forward to playing this so much.
Mats  [developer] 31 Dec, 2020 @ 5:37am 
That is great to hear, and thanks to you too. I will update the mod. Enjoy playing the game and happy new year.
< >
Showing 1-13 of 13 comments
Per page: 1530 50