Wichilie
Chieftain
- Joined
- Nov 9, 2017
- Messages
- 6
Hey!
I've been trying to get a custom unit for a mod I'm making to have attack based on the current era. This is what I've got so far for the script:
However, running it gives this error:
I don't really see what would cause this to happen. As far as I know this only happens for assignments but it gives the error on the event hook. Any idea's?
I've been trying to get a custom unit for a mod I'm making to have attack based on the current era. This is what I've got so far for the script:
Code:
print("Loading AssignEraStrength.lua...")
local iRequiredUnit = GameInfoTypes.UNIT_SHURIMAN_ASCENDED
local iStrengthPerEra = 15
function AssignEraStrength(iPlayer, iPlayerEra)
local pPlayer = Players[iPlayer]
for pUnit in pPlayer:Units() do
if (pUnit:GetUnitType() == iRequiredUnit) then
local iStrengthMultiplier = iPlayerEra + 1
pUnit:SetBaseCombatStrength(iStrengthMultiplier * iStrengthPerEra)
end
end
end
Events.PlayerEraChanged.Add(AssignEraStrength)
print("Loaded AssignEraStrength.lua.")
However, running it gives this error:
Code:
AssignEraStrength: Loading AssignEraStrength.lua...
Runtime Error: (path)/AssignEraStrength.lua:16: attempt to index field 'PlayerEraChanged' (a nil value)
I don't really see what would cause this to happen. As far as I know this only happens for assignments but it gives the error on the event hook. Any idea's?