ww2commander
Emperor
Here is snippet.
defines file contains following global table declaration:
main lua file executes the following process (this is based on R.E.D WWII mod):
Which in turn fires the InitializeSupplySystem function.
defines file contains following global table declaration:
Code:
----------------------------------------------------------------------------------------------------------------------------
-- Global Data Tables
----------------------------------------------------------------------------------------------------------------------------
g_GlobalSupplyCounters = {
-- Counter is current total amount
-- Output is per turn output from required buildings
-- Cap is the total capacity/limit
-- Penalty is any production or loss penatly applied on current turn (i.e. lack of resource, weather)
-- Bonus is any freebies/bonuses applied on current turn (i.e. lend lease)
-- Healed is the number of personnel healed and returned back into pool
-- Structure: [PlayerID] = {}
}
main lua file executes the following process (this is based on R.E.D WWII mod):
Code:
-- functions to call after game initialization (DoM screen button "Begin your journey" appears)
function OnGameInit ()
local savedData = Modding.OpenSaveData()
local iValue = savedData.GetValue("EF_FinalInitDone")
if (iValue ~= 1) then
Dprint ("Game is initialized, calling OnGameInit() for new game ...")
LoadAllTable() -- before any change on tables...
CreateTerritoryMap()
SetInitialCityBuilds()
[B][COLOR="Red"] InitializeSupplySystem()[/COLOR][/B]
InitExistingUnitSupplyData()
Events.SerialEventUnitCreated.Add( InitNewUnitSupplyData )
Events.SerialEventCityCaptured.Add( VictoryCheck )
Events.SerialEventCityCaptured.Add( HandleCityCapture )
GameEvents.UnitSetXY.Add( UnitCaptureTile )
savedData.SetValue("EF_FinalInitDone", 1)
else
Dprint ("Game is initialized, calling OnGameInit() for loaded game ...")
end
end
Which in turn fires the InitializeSupplySystem function.
Code:
function InitializeSupplySystem()
Dprint("Initalizing supply system counters...")
for playerID = 0, GameDefines.MAX_CIV_PLAYERS - 1 do
local player = Players[playerID]
if ( player:IsAlive() ) and (player:IsMinorCiv() == false) then
Dprint(" - Supply system initialized for player: ".. player:GetName())
g_GlobalSupplyCounters[playerID] = {}
-- Test counters - reset once testing is complete
g_GlobalSupplyCounters[playerID].Counter_FG = 2500
g_GlobalSupplyCounters[playerID].Counter_V = 2500
g_GlobalSupplyCounters[playerID].Counter_R = 2500
g_GlobalSupplyCounters[playerID].Counter_LT = 2500
g_GlobalSupplyCounters[playerID].Counter_LSP = 2500
g_GlobalSupplyCounters[playerID].Counter_LSP2 = 2500
g_GlobalSupplyCounters[playerID].Counter_LTD = 2500
g_GlobalSupplyCounters[playerID].Counter_MT = 2500
g_GlobalSupplyCounters[playerID].Counter_MT2 = 2500
g_GlobalSupplyCounters[playerID].Counter_MSP = 2500
g_GlobalSupplyCounters[playerID].Counter_MTD = 2500
g_GlobalSupplyCounters[playerID].Counter_HT = 2500
g_GlobalSupplyCounters[playerID].Counter_HSP = 2500
g_GlobalSupplyCounters[playerID].Counter_HTD = 2500
g_GlobalSupplyCounters[playerID].Counter_F = 2500
g_GlobalSupplyCounters[playerID].Counter_JF = 2500
g_GlobalSupplyCounters[playerID].Counter_GA = 2500
g_GlobalSupplyCounters[playerID].Counter_FB = 2500
g_GlobalSupplyCounters[playerID].Counter_MB = 2500
end
end
end