Error: attempt to index local 'state' (a nil value)
eltreum0 opened this issue ยท 5 comments
Describe the bug
Error on the Weakaura, expected no errors
Do you have an error log of what happened?
The error states its the weakaura, but the mentioned error if read says its in <WeakAuras\Conditions.lua:664> according to Translit on Discord, asakawa also asked it to be submitted.
2x [string "--[==[ Error in 'Shadow Word: Death':'condi..."]:14: attempt to index local 'state' (a nil value)
[string "--[==[ Error in 'Shadow Word: Death':'condition checks' ]==] local newActiveConditions = {};
local propertyChanges = {};
local nextTime;
local uid = ")xNbYZBNsDu"
return function(region, hideRegion)
local id = region.id
local cloneId = region.cloneId or ''
local state = region.states
local activatedConditions = WeakAuras.GetActiveConditions(id, cloneId)
wipe(newActiveConditions)
local recheckTime;
local now = GetTime();
if (not hideRegion) then
if (state[1] and state[1].show and state[1]["percenthealth"]~= nil and state[1]["percenthealth"]>21) then
newActiveConditions[1] = true;
end
if (state[1] and state[1].show and state[1]["percenthealth"]~= nil and state[1]["percenthealth"]<20) then
newActiveConditions[2] = true;
end
if (state and WeakAuras.CallCustomConditionTest(")xNbYZBNsDu", 1, state)) then
newActiveConditions[3] = true;
end
end
if (recheckTime) then
WeakAuras.scheduleConditionCheck(recheckTime, uid, cloneId);
end
wipe(propertyChanges)
if (activatedConditions[1] and not newActiveConditions[1]) then
propertyChanges['desaturate'] = false
propertyChanges['sub.1.glow'] = true
end
if (activatedConditions[2] and not newActiveConditions[2]) then
propertyChanges['desaturate'] = false
propertyChanges['sub.1.glow'] = true
end
if (activatedConditions[3] and not newActiveConditions[3]) then
propertyChanges['alpha'] = 0
end
if (newActiveConditions[1]) then
if (not activatedConditions[1]) then
propertyChanges['desaturate'] = true
propertyChanges['sub.1.glow'] = false
else
if(propertyChanges['desaturate'] ~= nil) then
propertyChanges['desaturate'] = true
end
if(propertyChanges['sub.1.glow'] ~= nil) then
propertyChanges['sub.1.glow'] = false
end
end
end
activatedConditions[1] = newActiveConditions[1]
if (newActiveConditions[2]) then
if (not activatedConditions[2]) then
propertyChanges['desaturate'] = false
propertyChanges['sub.1.glow'] = true
else
if(propertyChanges['desaturate'] ~= nil) then
propertyChanges['desaturate'] = false
end
if(propertyChanges['sub.1.glow'] ~= nil) then
propertyChanges['sub.1.glow'] = true
end
end
end
activatedConditions[2] = newActiveConditions[2]
if (newActiveConditions[3]) then
if (not activatedConditions[3]) then
propertyChanges['alpha'] = 1
else
if(propertyChanges['alpha'] ~= nil) then
propertyChanges['alpha'] = 1
end
end
end
activatedConditions[3] = newActiveConditions[3]
if(propertyChanges['sub.1.glow'] ~= nil) then
region.subRegions[1]:SetVisible(propertyChanges['sub.1.glow'])
end
if(propertyChanges['alpha'] ~= nil) then
region:SetRegionAlpha(propertyChanges['alpha'])
end
if(propertyChanges['desaturate'] ~= nil) then
region:SetDesaturated(propertyChanges['desaturate'])
end
end
"]:14: in function `?'
[string "@WeakAuras\Conditions.lua"]:671: in function <WeakAuras\Conditions.lua:664>
[string "@WeakAuras\Conditions.lua"]:684: in function <WeakAuras\Conditions.lua:677>
[string "=[C]"]: in function `TargetNearestEnemy'
[string "TARGETNEARESTENEMY"]:2: in function <[string "TARGETNEARESTENEMY"]:1>
Locals:
region = <unnamed> {
0 = <userdata>
iconSource = 0
AnchorSubRegion = <function> defined @WeakAuras\RegionTypes\Icon.lua:140
subRegionEvents = <table> {
}
Expand = <function> defined @WeakAuras\RegionTypes\RegionPrototype.lua:852
yOffset = 0
GetColor = <function> defined @WeakAuras\RegionTypes\Icon.lua:410
icon = <unnamed> {
}
SetOffset = <function> defined @WeakAuras\RegionTypes\RegionPrototype.lua:331
keepAspectRatio = true
SendChat = <function> defined @WeakAuras\RegionTypes\RegionPrototype.lua:278
SetInverse = <function> defined @WeakAuras\RegionTypes\Icon.lua:474
SetRegionHeight = <function> defined @WeakAuras\RegionTypes\Icon.lua:469
UpdateIcon = <function> defined @WeakAuras\RegionTypes\Icon.lua:434
PixelSnapDisabled = true
cloneId = "nameplate2"
Update = <function> defined @WeakAuras\RegionTypes\Icon.lua:537
regionType = "icon"
GetRegionAlpha = <function> defined @WeakAuras\RegionTypes\RegionPrototype.lua:400
SoundPlay = <function> defined @WeakAuras\RegionTypes\RegionPrototype.lua:260
windStyle = true
zoom = 0
color_b = 1
UpdateTexCoords = <function> defined @WeakAuras\RegionTypes\Icon.lua:310
alpha = 0
color_r = 1
SetXOffset = <function> defined @WeakAuras\RegionTypes\RegionPrototype.lua:340
SetGlow = <function> defined @WeakAuras\RegionTypes\Icon.lua:588
SetRegionWidth = <function> defined @WeakAuras\RegionTypes\Icon.lua:464
RealClearAllPoints = <function> defined =[C]:-1
displayIcon = "136149"
RunCode = <function> defined @WeakAuras\RegionTypes\RegionPrototype.lua:286
justCreated = true
GetYOffset = <function> defined @WeakAuras\RegionTypes\RegionPrototype.lua:352
values = <table> {
}
Collapse = <function> defined @WeakAuras\RegionTypes\RegionPrototype.lua:830
ClickToPick = <function> defined @WeakAuras\RegionTypes\RegionPrototype.lua:746
OptionsClosed = <function> defined @WeakAuras\RegionTypes\RegionPrototype.lua:741
SetYOffsetRelative = <function> defined @WeakAuras\RegionTypes\RegionPrototype.lua:369
ColorAnim = <function> defined @WeakAuras\RegionTypes\Icon.lua:396
SetIcon = <function> defined @WeakAuras\RegionTypes\Icon.lua:417
UpdateSize = <function> defined @WeakAuras\RegionTypes\Icon.lua:297
cooldownSwipe = true
SetDesaturated = <function> defined @WeakAuras\RegionTypes\Icon.lua:460
GetXOffset = <function> defined @WeakAuras\RegionTypes\RegionPrototype.lua:348
SetYOffset = <function> defined @WeakAuras\RegionTypes\RegionPrototype.lua:344
SetCooldownEdge = <function> defined @WeakAuras\RegionTypes\Icon.lua:488
color_g = 1
PreShow = <function> defined @WeakAuras\RegionTypes\Icon.lua:529
SetTime = <function> defined @WeakAuras\RegionTypes\Icon.lua:516
GetYOffsetRelative = <function> defined @WeakAuras\RegionTypes\RegionPrototype.lua:377
SetAnchor = <function> defined @WeakAuras\RegionTypes\RegionPrototype.lua:319
GlowExternal = <function> defined @WeakAuras\RegionTypes\RegionPrototype.lua:294
yOffsetRelative = 0
SetRegionAlpha = <function> defined @WeakAuras\RegionTypes\RegionPrototype.lua:390
finishFormatters = <table> {
}
SetZoom = <function> defined @WeakAuras\RegionTypes\Icon.lua:496
cooldownEdge = false
regionHasTimer = false
subRegions = <table> {
}
height = 30
startFormatters = <table> {
}
Scale = <function> defined @WeakAuras\RegionTypes\Icon.lua:451
SetOffsetAnim = <function> defined @WeakAuras\RegionTypes\RegionPrototype.lua:381
backdrop = <unnamed> {
}
generatedSetDurationInfo = true
color_a = 1
frameI
To Reproduce
Import this weakaura: https://wago.io/afJKwFwAX
OR
Create a new weakaura like asakawa mentioned in discord:
[status - unit characteristics - nameplates] then use a Custom Check in Conditions, running on the Additional Event PLAYER_TARGET_CHANGED with
function(states)
return states[1].unit and UnitIsUnit(states[1].unit, "target")
end
And use this Conditions to set the Alpha to full.
Then in Display, set the alpha to zero and set Anchor To to Nameplate
I changed it [status - health - nameplate], added a certain health % (for example 22), then in conditions i added 2 extra conditions that are similar:
Condition 1 - If trigger 1 health % > 21, then desaturate (check) and glow visibility uncheck
Condition 2 - If trigger 1 health % < 20, then desaturate (unchecked), and glow visibility checked.
Condition 3 - The one mentioned above by asakawa, with PLAYER_TARGET_CHANGED and the function
Then enter combat with a class that as an execute and kill some enemies, sometimes it wont trigger but sometimes it does. This happens more frequently around target dummies.
You should get an error eventually
Screenshots
Screenshots would only show the error because otherwise the weakaura works as expected, showing the icon for the execute near the nameplate when could be used, the error happens but doesnt affect the functionality.
Did you try having WeakAuras as the only enabled addon and everything else (especially something like ElvUI) disabled?
Yes, with only weakauras the error still shows, with only weakauras and buggrabber/bugsack it shows up too.
Which version of WeakAuras are you using?
3.1.9
Are you on World of Warcraft Classic or Retail?
- Classic
- Retail
Was it working in a previous version? If yes, which was the last good one?
No it was made in the current version of Weakauras
Additional Info
I cannot reproduce this. I'm afraid, you have to be more specific in your description on how to reproduce it.
I would suggest uploading your entire SavedVariables file.
WTF\Account\<Account #>\SavedVariables\WeakAuras.lua
I don't think that would improve. I'd prefer a good description or video that uses the linked aura.
Hey i've uploaded a video to youtube showing the error.
I've disabled every addon save for weakauras and bugsack/buggrabber.
I've also only imported the weakaura i mentioned (made a backup of weakauras.lua, deleted the original one and entered game, then imported the weakaura as shown on the video).
The error still happens, it not always as you can see on the video, but more when the enemy is likely casting or you change targets.
and here is the savedvariables weakaura.lua
WeakAuras.zip