Austindud518
Chieftain
- Joined
- Apr 4, 2011
- Messages
- 18
I have a cold war scenario that I am working on. I am making a LUA script that fires when ever a West or East German city is captured. What the script is supposed to do is to check and see who owns the city and who is capturing it. If the conqueror is a NATO member capturing an East German city, the script needs to transfer the city to West German ownership after it has been captured by the NATO ally. The opposite needs to happen when the Warsaw Pact captures a West German city; that city must be transferred to East Germany ownership. I have a basic script implemented, but it crashes when I try to locally define East and West Germany.
Ignore the print() functions, they are there for testing purposes. There is a UI popup that I intend to use to inform the player about city ownership changes, but I have commented it out for testing purposes. If successful, I plan to use the things I learned with this script to change city ownership when events fire (ex. Breakup of Yugoslavia) or when certain conditions are met (ex. the Soviet Union loses certain cities if they become a Capitalist nation)
The crash happens on this line:
print(eGermany:GetCivilizationDescription());
I have also commented on the error in the following code:
Here is my most recent Lua.log:
Ignore the print() functions, they are there for testing purposes. There is a UI popup that I intend to use to inform the player about city ownership changes, but I have commented it out for testing purposes. If successful, I plan to use the things I learned with this script to change city ownership when events fire (ex. Breakup of Yugoslavia) or when certain conditions are met (ex. the Soviet Union loses certain cities if they become a Capitalist nation)
The crash happens on this line:
print(eGermany:GetCivilizationDescription());
I have also commented on the error in the following code:
Code:
function OnCityCaptured (hexPos, playerID, cityID, newPlayerID)
local pPlayer = Players[newPlayerID];
print("Got aggressor!");
print(pPlayer);
local iPlayer = Players[playerID];
print("Got defender!");
print(iPlayer);
local civTypeAggressor = pPlayer:GetCivilizationDescription();
print("Got aggressor civ type!");
print(civTypeAggressor);
local civTypeDefender = iPlayer:GetCivilizationDescription();
print("Got defender civ type!");
print(civTypeDefender);
local iTeam;
iTeam = Teams[pPlayer:GetTeam()];
print("Got aggressor team!");
print(iTeam:GetName());
local pTeam
pTeam = Teams[iPlayer:GetTeam()];
print("Got defender team!");
print(pTeam:GetName());
local pCity = pPlayer:GetCityByID(cityID);
print("Got city ID!");
print(pCity);
local pCityName = pCity:GetName();
print("Got City Name!");
print(pCityName);
local wid = GameInfo.Civilizations{Type="CIVILIZATION_WGERMANY"}().ID
local eid = GameInfo.Civilizations{Type="CIVILIZATION_EGERMANY"}().ID
local eGermany = Players[eid];
print("East Germany has been defined locally!");
-Error occurs on the line below this one
print(eGermany:GetCivilizationDescription());
local wGermany = Players[wid];
print("West Germany has been defined locally!");
print(wGermany:GetCivilizationDescription());
local pAct = Teams[eGermany:GetTeam()];
local nAto = Teams[wGermany:GetTeam()];
--local popupInfo = {
--Data1 = 500,
--Type = ButtonPopupTypes.BUTTONPOPUP_TEXT,
--}
print("Checking who captured the city...");
print("NATO Team ID:")
print(nAto:GetID())
print("PACT Team ID:")
print(pAct:GetID())
print("Aggressor Team ID:")
print(pTeam:GetID())
print("Defender Team ID:")
print(iTeam:GetID())
print("West Germany ID:");
print(GameInfo.Civilizations["CIVILIZATION_WGERMANY"].ID);
print("East Germany ID:");
print(GameInfo.Civilizations["CIVILIZATION_EGERMANY"].ID);
-- Who Captured?
if (pTeam:GetID() == pAct:GetID()) then
if (iPlayer:GetID() == eGermany:GetID()) then
eGermany:AcquireCity(pCity, false, true);
print("East Germany acquires" + pCity:GetName() + "!");
end
end
if (pTeam:GetID() == nAto:GetID()) then
if (iPlayer:GetID() == wGermany:GetID()) then
wGermany:AcquireCity(pCity, false, true);
print("West Germany acquires" + pCity:GetName() + "!");
end
end
--UI.AddPopup(popupInfo);
end
Events.SerialEventCityCaptured.Add( OnCityCaptured );
Here is my most recent Lua.log:
Code:
[794422.065] Initializing Lua 5.1.4
[794503.825] InstalledPanel: Refreshing Mods
[794503.825] InstalledPanel: GetModBrowserListings()
[794504.012] InstalledPanel: Refreshing Mods
[794504.012] InstalledPanel: GetModBrowserListings()
[794544.183] InstalledPanel: Refreshing Mods
[794544.183] InstalledPanel: GetModBrowserListings()
[794554.323] InstalledPanel: Refreshing Mods
[794554.323] InstalledPanel: GetModBrowserListings()
[794614.040] SelectCivilization: table: 16D2A2F0
[794620.951] SelectCivilization: select civ
[794630.311] CivilopediaScreen: SetSelectedCategory(12)
[794630.311] CivilopediaScreen: CivilopediaCategory[CategoryTerrain].DisplayList
[794630.389] CivilopediaScreen: SetSelectedCategory(1)
[794630.389] CivilopediaScreen: CivilopediaCategory[CategoryHomePage].DisplayList
[794632.354] Tutorial: Loaded Additional Tutorial checks - Assets\DLC\Expansion2\Tutorial\Lua\TutorialInclude_Expansion2.lua
[794632.354] Tutorial: Loaded Additional Tutorial checks - Assets\DLC\Expansion\Tutorial\lua\TutorialInclude_Expansion1.lua
[794634.242] GenericPopup: Loaded Popup - Assets\DLC\Expansion2\UI\InGame\PopupsGeneric\ConfirmImprovementRebuildPopup.lua
[794634.242] GenericPopup: Loaded Popup - Assets\DLC\Expansion2\UI\InGame\PopupsGeneric\DeclareWarMovePopup.lua
[794634.242] GenericPopup: Loaded Popup - Assets\DLC\Expansion2\UI\InGame\PopupsGeneric\PuppetCityPopup.lua
[794634.242] GenericPopup: Loaded Popup - Assets\DLC\Expansion2\UI\InGame\PopupsGeneric\DeclareWarPlunderTradeRoutePopup.lua
[794634.242] GenericPopup: Loaded Popup - Assets\DLC\Expansion2\UI\InGame\PopupsGeneric\DeclareWarRangeStrikePopup.lua
[794634.242] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\ConfirmImprovementRebuildPopup.lua
[794634.242] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\NetworkKickedPopup.lua
[794634.242] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\CityPlotManagementPopup.lua
[794634.242] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\ConfirmCommandPopup.lua
[794634.242] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\MinorCivEnterTerritoryPopup.lua
[794634.242] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\LiberateMinorPopup.lua
[794634.242] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\ReturnCivilianPopup.lua
[794634.242] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\AnnexCityPopup.lua
[794634.242] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\DeclareWarMovePopup.lua
[794634.242] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\BarbarianRansomPopup.lua
[794634.242] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\ConfirmGiftPopup.lua
[794634.242] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\ConfirmCityTaskPopup.lua
[794634.242] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\PuppetCityPopup.lua
[794634.242] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\DeclareWarRangeStrikePopup.lua
[794634.242] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\ConfirmPolicyBranchPopup.lua
[794634.242] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\MinorCivGoldPopup.lua
[794635.474] EconomicGeneralInfo: Total Units - 9
[794635.474] EconomicGeneralInfo: Maint Free Units - 1
[794635.474] EconomicGeneralInfo: Paid Units - 8
[794635.490] EconomicGeneralInfo: Total Units - 9
[794635.490] EconomicGeneralInfo: Maint Free Units - 1
[794635.490] EconomicGeneralInfo: Paid Units - 8
[794636.925] ChoosePantheonPopup: 4
[794636.925] ChoosePantheonPopup: 963
[794636.925] ChoosePantheonPopup: 967
[794637.253] EspionageOverview: Refreshing My Cities
[794637.877] ChooseIdeologyPopup: 4
[794637.877] ChooseIdeologyPopup: 963
[794637.877] ChooseIdeologyPopup: 967
[794639.312] AdvisorInfoPopup: Closing Advisor Info
[794639.312] Demographics: Dequeuing demographics
[794639.312] Demographics: Dequeuing demographics
[794688.359] InGame: OnInterfaceModeChanged
[794688.359] InGame: oldInterfaceMode: 1
[794688.359] InGame: newInterfaceMode: 3
[794689.357] InGame: OnInterfaceModeChanged
[794689.357] InGame: oldInterfaceMode: 3
[794689.357] InGame: newInterfaceMode: 1
[794692.851] InGame: OnInterfaceModeChanged
[794692.851] InGame: oldInterfaceMode: 1
[794692.851] InGame: newInterfaceMode: 11
[794693.928] InGame: OnInterfaceModeChanged
[794693.928] InGame: oldInterfaceMode: 11
[794693.928] InGame: newInterfaceMode: 1
[794703.444] DiscussionDialog: DiploUIStateTypes.DIPLO_UI_STATE_WAR_DECLARED_BY_HUMAN
[794703.444] DiscussionDialog: DiploUIStateTypes.DIPLO_UI_STATE_WAR_DECLARED_BY_HUMAN NOT activated in DiscussionDialog
[794703.460] LeaderHeadRoot: Handling LeaderMessage: 1, You fool. You have made a terrible mistake.
[794703.460] CityBannerManager: CityBanner CombatBegin
[794707.282] InGame: OnInterfaceModeChanged
[794707.282] InGame: oldInterfaceMode: 1
[794707.282] InGame: newInterfaceMode: 11
[794708.108] InGame: OnInterfaceModeChanged
[794708.108] InGame: oldInterfaceMode: 11
[794708.108] InGame: newInterfaceMode: 1
[794709.715] CityBannerManager: CityBanner CombatEnd
[794709.731] CityBannerManager: CityBanner CombatBegin
[794714.364] CityBannerManager: CityBanner CombatEnd
[794730.916] CityBannerManager: CityBanner CombatBegin
[794735.939] CityBannerManager: CityBanner CombatEnd
[794738.981] CityBannerManager: CityBanner CombatBegin
[794740.806] CityBannerManager: CityBanner CombatEnd
[794742.850] CityBannerManager: CityBanner CombatBegin
[794747.343] CityBannerManager: CityBanner CombatEnd
[794747.358] CityBannerManager: CityBanner CombatBegin
[794751.991] CityBannerManager: CityBanner CombatEnd
[794760.634] CityBannerManager: CityBanner CombatBegin
[794764.004] CityBannerManager: CityBanner CombatEnd
[794774.471] CityBannerManager: CityBanner CombatBegin
[794776.858] CityBannerManager: CityBanner CombatEnd
[794783.972] CityBannerManager: CityBanner CombatBegin
[794786.967] CityBannerManager: CityBanner CombatEnd
[794789.166] CityBannerManager: CityBanner CombatBegin
[794792.552] CityBannerManager: CityBanner CombatEnd
[794797.310] CityBannerManager: CityBanner CombatBegin
[794800.586] CityBannerManager: CityBanner CombatEnd
[794802.754] CityBannerManager: CityBanner CombatBegin
[794804.330] CityBannerManager: CityBanner CombatEnd
[794808.620] CityBannerManager: CityBanner CombatBegin
[794809.759] CityBannerManager: CityBanner CombatEnd
[794818.323] NotificationPanel: Unknown Notification, Adding generic 53
[794819.337] TurnProcessing: Hiding TurnProcessing
[794824.048] InGame: OnInterfaceModeChanged
[794824.048] InGame: oldInterfaceMode: 1
[794824.048] InGame: newInterfaceMode: 11
[794824.875] InGame: OnInterfaceModeChanged
[794824.875] InGame: oldInterfaceMode: 11
[794824.875] InGame: newInterfaceMode: 1
[794824.891] CityBannerManager: CityBanner CombatBegin
[794826.654] InGame: OnInterfaceModeChanged
[794826.654] InGame: oldInterfaceMode: 1
[794826.654] InGame: newInterfaceMode: 11
[794827.558] InGame: OnInterfaceModeChanged
[794827.558] InGame: oldInterfaceMode: 11
[794827.558] InGame: newInterfaceMode: 1
[794827.668] CityBannerManager: CityBanner CombatEnd
[794827.683] CityBannerManager: CityBanner CombatBegin
[794830.491] CityBannerManager: CityBanner CombatEnd
[794832.316] CityBannerManager: CityBanner CombatBegin
[794836.887] CityBannerManager: CityBanner CombatEnd
[794837.886] CityBannerManager: CityBanner CombatBegin
[794843.112] CityBannerManager: CityBanner CombatEnd
[794843.158] CorrectCityCapture: Got aggressor!
[794843.158] CorrectCityCapture: table: 1712EAF8
[794843.158] CorrectCityCapture: Got defender!
[794843.158] CorrectCityCapture: table: 1712FF70
[794843.158] CorrectCityCapture: Got aggressor civ type!
[794843.158] CorrectCityCapture: Czechoslovak Socialist Republic
[794843.158] CorrectCityCapture: Got defender civ type!
[794843.158] CorrectCityCapture: Federal Republic of Germany
[794843.158] CorrectCityCapture: Got aggressor team!
[794843.158] CorrectCityCapture: Gustav Husak/Leonid Brezhnev/Edward Gierek/Walter Ulbricht/Nicolae Ceausescu/Janos Kadar/Todor Zhivkov
[794843.158] CorrectCityCapture: Got defender team!
[794843.158] CorrectCityCapture: Ronald Reagan/Margaret Thatcher/Willy Brandt/Charles de Gaulle/Einar Gerhardsen/Urho Kekkonen/Sandro Pertini
[794843.158] CorrectCityCapture: Got city ID!
[794843.158] CorrectCityCapture: table: 5D4B6298
[794843.158] CorrectCityCapture: Got City Name!
[794843.158] CorrectCityCapture: West Berlin
[794843.158] CorrectCityCapture: East Germany has been defined locally!