Thread: XML to Lua?
View Single Post
04-01-24, 06:15 PM   #4
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,334
Originally Posted by Codger View Post
I went to ChatGPT https://chat.openai.com/ and asked them to convert the xml code to lua and the code below is the result.

...

Lua Code:
  1. frame:SetScript("OnLoad", function()
  2.     frame.TitleText:SetText("Simple Frame")
  3. end)
The problem with this is OnLoad runs when CreateFrame() is called. Registering a script to it through Lua does nothing as it's never called again.

It's still a good idea to proofread any code GhatGPT spits out as it still makes mistakes. It sees parentKey and just shoves it in a local instead of assigning the object to that key in the parent's table, as Fizzlemizz pointed out. It also doesn't handle useParentLevel, which is to set the child's framelevel equal to its parent where by default, it's +1.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 04-01-24 at 06:26 PM.
  Reply With Quote