add on - World of Warcraft Lua - If statement flow -


i'm trying create addon world of warcraft. have created function checks whether buff has been added current player.

button:registerevent("unit_aura"); local function auragained(self, event, ...)     if (unitaura("player", "heating up"))              if (heatingupisactive ~= 1)              heatingupisactive = heatingupisactive + 1             print (heatingupisactive)              end      end button:setscript("onevent", auragained); 

this works great, how check if unitaura not "heating up"?

also, prefer if heatingupisactive boolean, seems not when that. correct way create boolean in lua?

your function isn't checking aura caused event. it's looking "heating up" time unit_aura event comes by. in fact, looks unit_aura event doesn't tell aura triggered it. can't "check if unitaura not "heating up"", because don't know aura caused event. perhaps several auras @ once.

however, event tell unit got aura. it's first vararg. should check make sure it's player before doing something

local unitid = ... if unitid ~= "player" return end 

also, didn't explain problems had booleans. should able like

if not heatingupisactive     heatingupisactive = true     -- whatever want end 

although never saw declaration of variable in code. it's bad idea use globals things this, should declare

local heatingupisactive 

before function declaration, e.g.

local heatingupisactive local function auragained(self, event, ...)     -- ... 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -