This site makes extensive use of JavaScript.
Please enable JavaScript in your browser.
Live
PTR
10.2.7
PTR
10.2.6
Beta
Lua help
Post Reply
Return to board index
Post by
janniie
local Kills = 0
local function OnLogEvent(Name,Event,GUID)
if <cond1> then
if <cond2> then
if <cond3> then
Kills = Kills + 1 <-- (Line 364)
if <cond4> then
PersonalRecord = Kills
newRecord = true
end
if <cond5> then
SendChatMessage("BattlegroundKS: "..UnitName("Player").." got a killing blow! They now have "..Kills.." kill without dying!","EMOTE")
elseif <cond6> then
SendChatMessage("BattlegroundKS: "..UnitName("Player").." got a killing blow! They now have "..Kills.." kills without dying!","EMOTE")
end
print("|cffF58CBAKilling Blow! You're on a "..Kills.." killstreak! (Personal Record: "..PersonalRecord..")|r")
if <cond7> then
UpdateLiveFrame(Kills)
end
end
end
end
end
(I replaced my very long conditions with <cond#> to make it fit and there's nothing wrong with them. :>)
This gives me:
...e\AddOns\BattlegroundKS\BattlegroundKS_Functions.lua line 364:
attempt to perform arithmetic on upvalue 'Kills' (a nil value)
Wai? :(
Post by
GTMistral
And what's found inside that "Kills" variable?
Post by
janniie
Kills is simply a number that I use to keep track of how many kills the player has done in a BG without dying. Kills is set to 0 on each death and is copied to PersonalRecord if it's a record. I used this method on a prior version of this addon, but now when I rewrote the addon it wont work anymore.
Post by
22686
This post was from a user who has deleted their account.
Post by
janniie
I triple checked my code and there's not one place where I assign it no nil...
However I did find a solution that seems to work (I've only done 1 bg with the fix so far).
Kills = Kills + 1 --> Kills = (Kills or 0) + 1
Even though this bypasses the problem it's not a perfect solution :/
Post by
Coldkil
Try to define "kills" inside the function. I think it's a visibility problem.
Post by
Farmbuyer
Try to define "kills" inside the function. I think it's a visibility problem.
Which means only "one kill" would ever be reported, over and over. The whole point is to maintain state across function calls...
@janniie: the code pasted here is fine, which means what's pasted isn't what's actually being executed. Can you put the code in a pastebin somewhere, and post a link to it? Many eyes makes all bugs shallow.
Post by
550132
This post was from a user who has deleted their account.
Post Reply
You are not logged in. Please
log in
to post a reply or
register
if you don't already have an account.