There are a lot of errors in this code.
Lua Code:
local i= GetQuestObjectInfo
This doesn't do anything, unless you created a global function called GetQuestObjectInfo. There is no such global function provided by Blizzard. Also, "i" is usually an abbreviation of "index", which is used in loops. You should not use that variable name in a case like this.
Lua Code:
MyFrame = CreateFrame("Quest Info") -- globally defined variable name, incorrect arguments
local MyFrame = CreateFrame("Frame", "QuestInfo", UIParent) -- localized, correct arguments
MyFrame is also not a good variable name and it should definitely not be globally defined. If you're going to keep using the same frame for multiple things, I suggest you create it in a higher scope and then refer to it directly in the functions.
Lua Code:
MyFrame.text:SetAllPoints() -- no argument
MyFrame.text:SetAllPoints(MyFrame) -- match the points of MyFrame
SetAllPoints takes a frame or region as an argument.
Lua Code:
MyFrame.text:SetText("i")
This will only put the letter "i" in the text box.
Lua Code:
MyFrame:SetMovable(enable) -- "enable" is nil, it doesn't exist
MyFrame:SetMovable(true) -- true to enable, false to disable
enable isn't mentioned anywhere else in your code, so it will be nil in this case since it will be treated as a global variable (which, again, doesn't exist).
Lua Code:
MyFrame = Frame("Quest Info") -- trying to grab the frame again?
local MyFrame = QuestInfo -- get the frame from global namespace
Unless you made it yourself, there is no global function called "Frame".
Lua Code:
MyFrame:Clear() -- attempting to clear text?
MyFrame.text:SetText() -- this will clear the text field
If MyFrame is an arbitrary frame, then there is no function called "Clear" mixed in.
Lua Code:
region = MyFrame:CreateTitleRegion() -- globally defined and pointless
local region = MyFrame:CreateTitleRegion() -- localized, but this is still pointless
You can't just copy & paste from wowprogramming. If you look at the argument listing for any function, you'll see that each argument has a data type and each return value has a label to let you know what's being returned. "region" just tells you that the function is returning a region (which could be a Frame, FontString, Texture, Button, etc). "enable" just tells you what the arugment you give the function will do. If you give it
true then it will enable. If you give it
false, then it will disable.
This code will still do nothing (since I'm not entirely sure what you're trying to do), but it's correctly written:
Lua Code:
local QuestInfo = CreateFrame("Frame", "QuestInfo", UIParent)
QuestInfo:SetHeight(300)
QuestInfo:SetWidth(300)
QuestInfo:SetPoint("CENTER", 0, 0)
QuestInfo:SetBackdrop(StaticPopup1:GetBackdrop())
QuestInfo:EnableMouse(true)
QuestInfo:SetMovable(true)
QuestInfo:RegisterForDrag("LeftButton")
QuestInfo:HookScript("OnDragStart", QuestInfo.StartMoving)
QuestInfo:HookScript("OnDragStop", QuestInfo.StopMovingOrSizing)
QuestInfo.Text = QuestInfo:CreateFontString("$parentText", "BACKGROUND", "GameFontNormal")
QuestInfo.Text:SetAllPoints(QuestInfo)
QuestInfo.Text:SetText("This is your frame")
function QuestInfo:Accepted(...)
local arg1, arg2, arg3 = ...
self.Text:SetText(arg1 or arg2 or arg3)
end
function QuestInfo:Complete(...)
local arg1, arg2, arg3 = ...
self.Text:SetText()
end