Hiya,
I'm pretty new to the LUA coding language, and am wanting to restructure my addon so that it doesn't use as much repetition and a lot less lines.
I am using XML framing for my addon instead of LUA frames.
The XML frames have the structure similar to this:
Lua Code:
<frame name="1Keyf" hidden="true" inherits="whatever">
<Scripts>
<OnMouseDown>
presskey(_,"1",1Keyf)
</OnMouseDown>
</Scripts>
</frame>
<frame name="1Key" inherits="whatever">
<Scripts>
<OnMouseDown>
presskey(_,"1",1Keyf)
</OnMouseDown>
</Scripts>
Basically, there's a hidden frame on top of another frame. What it does is when I click the frame, it calls the function
presskey with arguments of the key it's referring to, and the frame that's hidden.
presskey then sends an argument to
push with the values
key and
frameval given from the click event.
What I'm wanting to do is be able to press a key to show the frame with the UIFrameFlash function.
Lua Code:
VMainWindow:EnableKeyboard(true)
VMainWindow:SetScript("OnKeyDown", presskey)
function presskey(self, key, frameval)
--Since pressing a key does not refer to any frame, I need to make an if statement to see if it's nil
if frameval == nil then
frameval = key.."Keyf" --problem line here
end
push(key,frameval)
play(key)
end
If I were to add a debug print(frameval) line after the if statement to see if
frameval is nil, then:
If I press a key, I'd get the string "1Keyf"
If I press the frame with my mouse, I'd get "table: (table id)"
Lua Code:
function push(key,frameval)
--UIFrameFlash requires a frame value and not a string.
if UIFrameIsFlashing(frameval) then
UIFrameFlashStop(frameval)
end
if ((key == 1 or key == 2) and not IsShiftKeyDown()) then
UIFrameFlash(frameval, fIT, fOT, fD, false, fIHT, fOHT)
end
end
Since using the UIFrameFlash function requires a frame and not a string, how would I go around implementing this?