Hello, everyone. I recently found out you can create your own mods for warzone. I have an idea for a mod where the neutral territories advance every turn. I figured out how I can edit the number of armies on a neutral square using the Wastelands mod code and configuring it. Here is what I came out with:
function RandomizeWastelands(game, standing)
for _, territory in pairs(standing.Territories) do
local numArmies = territory.NumArmies.NumArmies;
if (territory.OwnerPlayerID == WL.PlayerID.Neutral) then
local newArmies = math.random(2, 4);
if (newArmies < 0) then newArmies = 0 end;
if (newArmies > 100000) then newArmies = 100000 end;
territory.NumArmies = WL.Armies.Create(newArmies);
end
end
end
I use this in the RandomizeWastelands.lua however, I now want to make it so every go, one army is added onto all neutral squares. I tried using Server_AdvanceTurn.lua and making it like this:
function Server_AdvanceTurn_Order(game, order, result, skipThisOrder, addNewOrder)
--I think this needs to go here?
end
function Server_AdvanceTurn_End(game, standing)
for _, territory in pairs(standing.Territories) do
local numArmies = territory.NumArmies.NumArmies;
if (territory.OwnerPlayerID == WL.PlayerID.Neutral) then
local newArmies = math.random(0, 2);
if (newArmies < 0) then newArmies = 0 end;
if (newArmies > 100000) then newArmies = 100000 end;
territory.NumArmies = WL.Armies.Create(newArmies);
end
end
end
However, the mod crashes when I use this code. I get the following error from the mod console in Warzone when trying to advance a move:
250: ERROR: Server_AdvanceTurn.lua:(2,1-51): attempt to index a function value
GameID=123
Hook=Server_AdvanceTurn_End
I cannot figure out how to fix it. As I said, I want to add a number of armies to every neutral territory every go.
I hope someone can help me!
Many Thanks,
Angel