View Single Post
11-29-12, 02:46 PM   #3
sodra
A Murloc Raider
Join Date: Nov 2012
Posts: 5
Originally Posted by Phanx View Post
Well, you're loading your Lua twice, you're using XML, everything is global, your buttons are not parented to your frame, and you're trying to set scripts to functions that you didn't define anywhere, so there are a lot of problems... just get rid of the whole XML file and replace your Lua file with this:

Code:
local frame = CreateFrame("Frame", "FinalFrame", UIParent)
-- you may want to actually position the frame somewhere, give it visible regions, etc.

local button =CreateFrame("Button", "$parentButton", frame, "UIPanelButtonTemplate")
button:SetPoint("BOTTOMRIGHT", UIParent, 0, 66)
button:SetWidth(80)
button:SetHeight(22)
button:SetText("Twelve")
button:SetScript("OnClick", function(self, mouseButton)
    -- do something here when clicked
end)

local chanbutton = CreateFrame("Button", "$parentChannelButton", UIParent, "UIPanelButtonTemplate")
chanbutton:SetPoint("BOTTOMRIGHT", UIParent, 0, 88)
chanbutton:SetWidth(160)
chanbutton:SetHeight(22)
chanbutton:SetText("Fav. Channel")
chanbutton:SetScript("OnClick", function(self, mouseButton)
    -- do something here when clicked
end)
The reason nothing is defined is because I didn't post the whole script.

The only error when I post the whole lua script is that final() is a nil value.

I NEED to use XML to call the function, its part of the project.

Could you just tell me why its saying Final is a nil value?

Heres the whole lua script
Lua Code:
  1. function finalproj()
  2.     print("So I guess this works");
  3.     mybutton = CreateFrame("Button","mybutton",UIParent,"UIPanelButtonTemplate")
  4.     mybutton:SetPoint("BOTTOMRIGHT",0,66)
  5.     mybutton:SetWidth(80)
  6.     mybutton:SetHeight(22)
  7.     mybutton:SetText("Twelve")
  8.     mybutton:SetScript("OnClick", buttontest)
  9.    
  10.     chanbutton = CreateFrame("Button","chanbutton",UIParent,"UIPanelButtonTemplate")
  11.     chanbutton:SetPoint("BOTTOMRIGHT",0,88)
  12.     chanbutton:SetWidth(160)
  13.     chanbutton:SetHeight(22)
  14.     chanbutton:SetText("Fav. Channel")
  15.     chanbutton:SetScript("OnClick", channeljoin)
  16. end
  17. --[[function partybutton()
  18.     print("Would you like to add them to your party?");
  19.     accbutton = CreateFrame("Button","accbutton",UIParent,"UIPanelButtonTemplate")
  20.     accbutton:SetPoint("BOTTOMRIGHT",0,22)
  21.     accbutton:SetWidth(80)
  22.     accbutton:SetHeight(22)
  23.     accbutton:SetText("Accept")
  24.     accbutton:SetScript("OnClick", InviteUnit("target"))
  25.    
  26.     decbutton = CreateFrame("Button","decbutton",UIParent,"UIPanelButtonTemplate")
  27.     decbutton:SetPoint("BOTTOMRIGHT",0,44)
  28.     decbutton:SetWidth(80)
  29.     decbutton:SetHeight(22)
  30.     decbutton:SetText("Decline")
  31.     decbutton:SetScript("OnClick", break)
  32.    
  33.     trdbutton = CreateFrame("Button","trdbutton",UIParent,"UIPanelButtonTemplate")
  34.     trdbutton:SetPoint("BOTTOMRIGHT",0,66)
  35.     trdbutton:SetWidth(80)
  36.     trdbutton:SetHeight(22)
  37.     trdbutton:SetText("Trading Request")
  38.     trdbutton:SetScript("OnClick", InitiateTrade("target"))
  39. end--]]
  40.  
  41. function buttontest()
  42.     print("AW DUDE THIS BUTTON ROCKS!");
  43.     if UnitIsUnit("player", "target") then
  44.         print("This players name is " .. UnitName);
  45.         print("They are a " .. UnitClass("target") .. " " .. UnitRace("target"));
  46.         print("They currently have " .. UnitHealth("target") .. " health, out of " .. UnitMaxHealth("target") .. " health.");
  47.         partybutton();
  48.     end
  49. end--]]
  50.  
  51. --[[function dpshealth()
  52.     if(UnitHealthMax("target") / UnitHealth("target") <=50% then
  53.         if(GetLFGRoles() == isDPS) then
  54.             print("DONT FORGET THE DPS!")
  55.         end
  56.     end
  57. end
  58.  
  59. function otherenddps()
  60.     print("Please target the Healer. If you do not target the healer, this will not work")
  61.     if UnitGroupRolesAssigned("target") == DAMAGER then
  62.         print("That is not the healer, please target the healer")
  63.     end
  64.    
  65.     if UnitGroupRolesAssigned("target") == TANK then
  66.         print("That is not the healer, please target the healer")
  67.     end
  68.    
  69.     if UnitGroupRolesAssigned("target") == HEALER then
  70.         messagedman == "target"
  71.         print("That is the healer. When you are at 50% or lower health, this addon will automatically send a message to the healer")
  72.     end
  73.    
  74.     if(UnitHealthMax("player") / UnitHealth("player") <=50% then
  75.             SendChatMessage("HEAL ME!","WHISPER","nil",messagedman);
  76.     end
  77. end--]]
  78.  
  79. function questions()
  80.     question = CreateFrame("Frame","question",UIParent,"UIFrameTemplate")
  81.     question:SetPoint("BOTTONLEFT",0,0)
  82.     question:SetWidth(800)
  83.     question:SetHeight(100)
  84.     --[[question:SetScript("OnLoad", questionone)--]]
  85. end
  86.  
  87. SLASH_TWELVE1 = '/12'
  88. function SlashCmdList.TWELVE(msg, editbox)
  89.  
  90.     print("TWELVE. That Unit is a " .. UnitIsPlayer("target"));
  91. end
  92.  
  93. --[[function channeljoin()
  94.     AddChatWindowChannel;(chatwindow1, "TWELVE");
  95. end--]]

This used to work yesterday, barely anything has changed.
I used comments so I could try and debug it.
  Reply With Quote