View Single Post
11-06-20, 04:00 PM   #4
DahkCeles
A Cliff Giant
 
DahkCeles's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2020
Posts: 73
In certain narrow cases, XML is 'mandatory' if you need to absolutely need to create an XML template. Examples would be pins on the 8.0.1 world map; I don't think that can be done without an XML file (that is just three lines long).

Otherwise... you just have to go from this paradigm:

Code:
<Frame name="MyTemplate" virtual="true" hidden="true">
    <Scripts>
        <OnShow>
            print("see me now?")
        </OnShow>
    </Script>
    <!-- insert other stuff here to control its appearance -->
</Frame>
<Frame name="MyFrame1" implements="MyTemplate" id="1"></Frame>
<Frame name="MyFrame2" implements="MyTemplate" id="2"></Frame>
<Frame name="MyFrame3" implements="MyTemplate" id="3"></Frame>

To this one:

Lua Code:
  1. local function createMyFrame(id)
  2.   local frame = CreateFrame("Frame")
  3.   local frame:Hide()
  4.   frame:SetID(id)
  5.   frame:SetScript("OnShow", function()
  6.     print("see me now?")
  7.   end)
  8.   -- insert other stuff here to control its appearance
  9.   return frame
  10. end
  11.  
  12. local myFrame1 = createMyFrame(1)
  13. local myFrame2 = createMyFrame(2)
  14. local myFrame3 = createMyFrame(3)


But I would echo Fizzlemizz's remarks... there's nothing wrong with leaving something in XML if its already done.

Therefore, I would only advise converting it to Lua if you were making a more substantial change in the process.
  Reply With Quote