Robotron wrote: ↑Sat Sep 08, 2018 5:05 pm
Phew...this is getting complicated. Let me explain.
There is a special function called StartExperience(), which is part of the event list in PotzBlitz.
This function makes sure all units on the map at game start are being assigned a value for experience.
That function is triggered, like all the other events by another function called TriggerTurnEvents, which is also part of game_events.lua.
Copy the whole function called "StartExperience()" found in game_events.lua in PotzBlitz into YOUR MOD's game_events.lua
Then insert a function call for the StartExperience() function into the TriggerTurnEvents() function in YOUR MOD's game_events.lua so that it reads (for example):
Code: Select all
function TriggerTurnEvents()
StartExperience()
ChrismasTruce()
..etc...
Then report back.
Thanks again for your patience!
Made the changes. Still have an error. Probably must change something else. This is the first time that I touch the file game_events.lua, so no previous problems there.
New Ctgw.log:
Log date: 2018-09-08 18:59:36
[18:59:36][6932]Running Steam build
[18:59:40][6932]Unable to read game settings. Using defaults.
[18:59:41][6932]Renderer: AMD Radeon HD 7800 Series version: 4.5.13521 Compatibility Profile Context 24.20.11016.4
[18:59:41][6932]Commander: The Great War(v 1.6.6)
[18:59:41][6932]Audio device used: OpenAL Soft
[18:59:41][6932]Loading main script
[18:59:41][6932]Loading app script
[18:59:41][6932]App version:1.6.6
[18:59:41][6932]Today is: 8.9.2018
[18:59:47][10216]Invalid railroad from: KRISTIANA
[18:59:52][6932]Staring game turn 1
[18:59:52][6932]game/game_events.lua:203(global StartExperience) game/game_events.lua:203: attempt to compare nil with number
[18:59:52][6932][C]:-1(method Start) std::exception: 'Lua Error:game/game_events.lua:203(global StartExperience) game/game_events.lua:203: attempt to compare nil with number'
Side note: that Invalid railroad from Kristiana puzzles me!!! I suppose that is a vanilla thing.
And the part that I added to the game_events.lua:
------------------------------- NEW EVENT FROM POTZBLITZ MOD ---------------------------------------
function StartExperience()
local france = game:GetFactionById(0)
local britain = game:GetFactionById(1)
local russia = game:GetFactionById(4)
local germany = game:GetFactionById(2)
local austria = game:GetFactionById(3)
local turkey = game:GetFactionById(5)
local italy = game:GetFactionById(8)
local serbia = game:GetFactionById(7)
local belgium = game:GetFactionById(6)
local romania = game:GetFactionById(18)
local bulgaria = game:GetFactionById(19)
local neutrals = game:GetAllianceById(0)
if game.turn == 1 then
for unit in austria.units do
if unit.type == Unit.NAVAL or unit.prototype.name == "fighter" or unit.prototype.name == "smallgarrison" then
GetUnitExperience(unit)
unit.luaData.experience = 0
elseif unit.prototype.name == "cavalry" then
GetUnitExperience(unit)
unit.luaData.experience = math.random(300,350)
else
GetUnitExperience(unit)
--unit.luaData.experience = 100
unit.luaData.experience = math.random(40,140)
end
end
for unit in serbia.units do
GetUnitExperience(unit)
--unit.luaData.experience = 100
unit.luaData.experience = math.random(150,285)
end
for unit in belgium.units do
GetUnitExperience(unit)
unit.luaData.experience = math.random(10,120)
end
for unit in bulgaria.units do
GetUnitExperience(unit)
unit.luaData.experience = math.random(70,130)
end
for unit in romania.units do
GetUnitExperience(unit)
unit.luaData.experience = math.random(20,120)
end
for unit in turkey.units do
GetUnitExperience(unit)
unit.luaData.experience = math.random(30,120)
end
for unit in france.units do
if unit.prototype.name ~= "submarine" and unit.prototype.name ~= "fighter" and unit.prototype.name ~= "smallgarrison" then
GetUnitExperience(unit)
unit.luaData.experience = math.random(130,150)
end
end
for unit in britain.units do
if unit.type == Unit.NAVAL and unit.prototype.name ~= "submarine" then
GetUnitExperience(unit)
unit.luaData.experience = math.random(180,280)
elseif unit.prototype.name ~= "submarine" and unit.prototype.name ~= "fighter" and unit.prototype.name ~= "smallgarrison" then
GetUnitExperience(unit)
unit.luaData.experience = math.random(250,350)
end
end
for unit in germany.units do
if unit.prototype.name ~= "submarine" and unit.prototype.name ~= "zeppelin" and unit.prototype.name ~= "fighter" and unit.prototype.name ~= "smallgarrison" then
GetUnitExperience(unit)
unit.luaData.experience = math.random(140,170)
end
end
for unit in russia.units do
if unit.prototype.name ~= "submarine" and unit.prototype.name ~= "zeppelin" and unit.prototype.name ~= "fighter" and unit.prototype.name ~= "smallgarrison" then
GetUnitExperience(unit)
unit.luaData.experience = math.random(50,150)
end
end
end
--- exp per round
for faction in game.factions do
if faction.alliance.id ~= 0 then
if faction.luaData.collaps ~= 0 then
if faction.luaData.collaps < 10 then
for unit in faction.units do
if unit.luaData.experience == nil then
unit.luaData.experience = 0
end
if unit.luaData.experience ~= nil and unit.prototype.name ~= "smallgarrison" then
unit.luaData.experience = unit.luaData.experience + math.random(1, (10 - faction.luaData.collaps))
end
end
end
end
end
if faction.alliance.id ~= player.alliance.id and faction.alliance.id ~= 0 then
if faction.luaData.collaps ~= 0 then
if faction.luaData.collaps < 10 then ---------------------- THIS IS THE LINE 203 in the File
for unit in faction.units do
if unit.luaData.experience == nil then
unit.luaData.experience = 0
end
if unit.luaData.experience ~= nil and unit.prototype.name ~= "smallgarrison" then
if unit.commander == nil and (GetUnitExperienceLevel(unit) <= 1) then
unit.luaData.experience = unit.luaData.experience + math.random(1, 10)
elseif unit.commander ~= nil and (GetUnitExperienceLevel(unit) <= 2) then
unit.luaData.experience = unit.luaData.experience + math.random(1, 10)
end
end
end
end
end
end
end
--neutrals start training
if game.turn >= 8 then
for faction in neutrals.factions do
if faction.luaData.alignment > 95 or faction.luaData.alignment < 10 then
for unit in faction.units do
if unit.type == Unit.LAND then
GetUnitExperience(unit)
unit.luaData.experience = unit.luaData.experience + math.random(1,6)
end
end
else
for unit in faction.units do
if faction.id == 9 then
GetUnitExperience(unit)
unit.luaData.experience = unit.luaData.experience + math.random(1,6)
end
if unit.type == Unit.LAND then
if math.random(1,100) < game.turn then
GetUnitExperience(unit)
unit.luaData.experience = unit.luaData.experience + math.random(1,10)
end
end
end
end
end
end
end
-------------------------
I made a note in line 203.
Now the game crashes as soon as a push the button start, after (or during) the introduction about Serbia.
EDIT: Probably I should mod your mod and not vanila.