Hey guys, Ive been meaning to get into Lua modding for a while and figured the best way is to jump right in and start making stuff. Thing is, Im just smashing rocks together; would anyone be willing to offer me some pointers here and there?
Have a look at this code and let me know what Im doing wrong.
Im trying to create a promotion that gives said unit XP at the start of every turn.
I need feedback. Reading reference material just isn't cutting it for me and I'm left feeling more confused than when I started, so I really appreciate any help you guys have to offer.
Have a look at this code and let me know what Im doing wrong.
Im trying to create a promotion that gives said unit XP at the start of every turn.
Spoiler :
Code:
-- Morbid Strength
-- Author: Titan
-- DateCreated: 8/27/2016 1:04:47 PM
--------------------------------------------------------------
function MorbidStrength(iPlayer) -- Create a function to call at the end of the turn
local pPlayer = Players[iPlayer] -- Create a local variable to state that the 'pointer Player' is the same as the 'index Player'
if pPlayer:IsAlive() then -- Check to see if the indexed player is alive, and if he is then...
for pUnit in pPlayer:Units() do -- for all 'pointer Units' in 'pointer Player's units do this action!
if (pUnit:IsHasPromotion(GameInfoTypes["PROMOTION_MORBID_STRENGTH"])) then -- First check to see if the 'pointer Units' have the required promotion, and if they do then
pUnit:GiveExperience(15) -- give said unit 15 experience.
end
end
end
GameEvents.PlayerDoTurn.Add(MorbidStrength) -- Do this at the end of every turn.
I need feedback. Reading reference material just isn't cutting it for me and I'm left feeling more confused than when I started, so I really appreciate any help you guys have to offer.