Thread: XML to Lua?
View Single Post
04-01-24, 12:08 AM   #1
Codger
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Mar 2021
Posts: 30
XML to Lua?

So... I'm not very good with xml (old brain doesn't like it)
but I see a lot of UI examples in XML and I'm wondering if there is an easy way to convert them to lua code.

As an example I found this page https://us.forums.blizzard.com/en/wo...-xml/1488298/2

Gello posted some XML code and I'm trying to convert it into lua code.

Code:
<Ui>
    <Frame name="SimpleFrame" parent="UIParent" inherits="DefaultPanelTemplate">
        <Size x="150" y="150"/>
        <Anchors>
            <Anchor point="CENTER"/>
        </Anchors>
        <Frames>
            <Button parentKey="CloseButton" inherits="UIPanelCloseButtonDefaultAnchors"/>
			<Frame parentKey="Inset" useParentLevel="true" inherits="InsetFrameTemplate">
				<Anchors>
					<Anchor point="TOPLEFT" x="10" y="-26" />
					<Anchor point="BOTTOMRIGHT" x="-6" y="26" />
				</Anchors>
			</Frame>
            <Button parentKey="OkButton" inherits="UIPanelButtonTemplate" text="Okay">
                <Size x="90" y="22"/>
                <Anchors>
                    <Anchor point="BOTTOMRIGHT" x="-6" y="4"/>
                </Anchors>
                <Scripts>
                    <OnClick>
                        self:GetParent():Hide()
                    </OnClick>
                </Scripts>
            </Button>
        </Frames>
        <Scripts>
            <OnLoad>
                self.TitleContainer.TitleText:SetText("Simple Frame")
            </OnLoad>
        </Scripts>
    </Frame>
</Ui>
```
[/quote]
The frame part is simple enough but the button xml code has me baffled?
What would the lua code look like for the two buttons?
  Reply With Quote