I am currently working on a Unique Unit that requires it to stack with another unit (specifically Great People) in order for it to receive a unique promotion. I attempted to modify a bit of code I'd had help with earlier to achieve this effect, but it gives me an error message:
This is the code I worked up below:
All of the proper promotions are programmed in, it's just the code that executes this particular one seems to be the problem. I should take it from the feedback of the .Lua log that GetPromotionType isn't recognized by the game data? Is there something along that line that will work for this purpose, or do I need a completely new .Lua code to achieve the desired effect?
Code:
[113107.713] Runtime Error: C:\...\Sid Meier's Civilization 5\MODS\Harkodos' Venture Industries (BNW)\Lua/Venture_Promotions.lua:16: attempt to call method 'GetPromotionType' (a nil value)
This is the code I worked up below:
Code:
local iVentureIndustries = GameInfoTypes.CIVILIZATION_AMERICA
local iPromotion = GameInfoTypes.PROMOTION_OPERATION_RUSTYS_BLANKET
local iDummyPromotion = GameInfoTypes.PROMOTION_SECRET_INTELLIGENCE
local iCivilianPromotion = GameInfoTypes.PROMOTION_O_R_B
function VentureIndustriesUnitHeal(iPlayer, iUnitID)
if iPlayer < GameDefines.MAX_MAJOR_CIVS then
local pPlayer = Players[iPlayer]
local pUnit = pPlayer:GetUnitByID(iUnitID)
if pPlayer:GetCivilizationType() == iVentureIndustries then
local pPlot = pUnit:GetPlot()
if (pPlot:GetPromotionType() == iCivilianPromotion) and pUnit:IsHasPromotion(iDummyPromotion) then
pUnit:SetHasPromotion(iPromotion, true)
return
end
end
pUnit:SetHasPromotion(iPromotion, false)
end
end
GameEvents.UnitSetXY.Add(VentureIndustriesUnitHeal)