Originally Posted by Dargen
One thing to remember is that you can't change the unit attribute if you are in combat when you get into or out of the vehicle.
|
Doh. Completely forgot about the secure restrictions.... Is it possible to change the unit attribute with secure code or should I just make a double and show/hide with a secure on-state handler (or whatever they're called)
Edit: Tried to test this in combat but not sure if I left as I was dismounted, any way to shorten this?
Code:
local sechan = CreateFrame("Frame", nil, nil, "SecureHandlerStateTemplate")
sechan:SetAttribute("_onstate-aurastate", [[
local buffs = self:GetFrameRef("auraframe1")
local debuffs = self:GetFrameRef("auraframe2")
if newstate == "invehicle" then
buffs:SetAttribute("unit", "vehicle")
debuffs:SetAttribute("unit", "vehicle")
elseif newstate == "notinvehicle" then
buffs:SetAttribute("unit", "player")
debuffs:SetAttribute("unit", "player")
end
]])
sechan:SetFrameRef("auraframe1", buffs)
sechan:SetFrameRef("auraframe2", debuffs)
RegisterStateDriver(sechan, "aurastate", "[vehicleui] invehicle; notinvehicle")