08-22-08, 10:38 PM | #1 |
need some code advise
Hi all.
This is my first post on this forum. I lately got interessed in lua scripting, and since i play WoW and have many nice ideas for some addons i would like to make.. I bought a book called; "World Of Warcraft Programming:A Guide and Reference for Creating WoW addons" and i already runned alot of tutorials i found on the net and in my book... Yesterday i wanted to try makeing something my self, and i made a frame and a FontString.. i called the the FontString TextDisplayer. After that i wanted to make a table witch i already had tryed out in wowLua.. (An InterPreter that i can easyer try codes out ingame. and its a nice tool to use with many of the tuorial i see in the book) My table look like this in wow lua ; Code:
local SpellIdent = { [1] = "Lightning Bolt(Rank 12) Nature", [2] = "Chain Lightning(Rank 6) Nature", } for i=1,#SpellIdent do print(SpellIdent[i]) end But now i wanted the text to show in the FontString i met problems.. I wrote the code like this: Code:
local SpellIdent = { [1] = "Lightning Bolt(Rank 12) Nature", [2] = "Chain Lightning(Rank 6) Nature", } for i=1,#SpellIdent do TextDisplayer:SetText(SpellIdent[i]); end However the text still gets displayed in my FontString, but only 1 line.. even tho i set the MaxLines to 25.. Moolgar Last edited by moolgar : 08-22-08 at 11:07 PM. |
|
08-22-08, 10:52 PM | #2 |
You have to set where you want the FontString to display. Do you want it in a new frame? In the chat window? Use the parent value to do this.
For example (for a custom frame): Code:
local SpellID = { [1] = "Lightning Bolt(Rank 12) Nature", [2] = "Chain Lightning(Rank 6) Nature", } local TextDisplayer = FRAMENAME:CreateFontString(nil, "OVERLAY", "GameFontNormalHuge") TextDisplayer:SetPoint("TOPLEFT", FRAMENAME, "TOPLEFT", 10, -10) TextDisplayer:SetText(SpellID[i]) Code:
>local SpellID = { >> [1] = "Lightning Bolt(Rank 12) Nature", >> [2] = "Chain Lightning(Rank 6) Nature", >} >for i=1,#SpellID do >> DEFAULT_CHAT_FRAME:AddMessage(SpellID[i]); >end
__________________
Never be satisfied with satisfactory. |
|
08-23-08, 12:07 AM | #3 |
thx alot for fast reply Cralor
the Code u gave me: Code:
local SpellIdent = { [1] = "Lightning Bolt(Rank 12) Nature", [2] = "Chain Lightning(Rank 6) Nature", } local TextDisplayer = chatbox1:CreateFontString(nil, "OVERLAY", "GameFontNormalHuge") TextDisplayer:SetPoint("TOPLEFT", chatbox1, "TOPLEFT", 10, -10) TextDisplayer:SetText(SpellIdent[i]) - - attempt to index global 'SpellList1' (a nil value) - - HoweverI want it to be displayed in the FontString i already created if possibe. The fontstring is at the top of my already created frame. so why shouldnt this code work ? Code:
for i=1,#SpellIdent do TextDisplayer:SetText(SpellIdent[i]); end local TextDisplayer = FRAMENAME:CreateFontString(nil, "OVERLAY", "GameFontNormalHuge") TextDisplayer:SetPoint("TOPLEFT", FRAMENAME, "TOPLEFT", 10, -10) already be sorted, if i have it on the apperiance properties ? at least i can choose the same things there.. I cant see why i have to tell lua to create a new fontstring when i already have one. But could you please explane me why ? Last edited by moolgar : 08-23-08 at 01:37 AM. |
|
08-23-08, 08:52 AM | #4 |
When you get the error "Attempt to index Blah (a nil value)", it means it could not find Blah. Blah was not yet created or has a nil value.
Do you have in your full code anywhere the name SpellList1 or SpellList? Also, if there is more to the error message, please post it. The way the error message is provided is that it starts with the error, then it shows a stack of function calls that lead to the error in reverse order. The error that you have provided could be in another part of the code or it could exist in another addon. It may show a route that starts from your code sending a bad parameter. And about the CreatFontString message. TextDisplayer is a local variable that holds the direct address to the font string created in FRAMENAME. If you lose the address in TextDisplayer, you will have to locate it before you can use it again. It is not much creating a new FontString, but you need a way to keep their location. If you are creating the FontString inside a function, it might be useful to create a local variable outside of your function to hold it. Then you can reuse it through that variable. Last edited by LBXZero : 08-23-08 at 09:02 AM. |
|
08-23-08, 05:44 PM | #5 | ||
Hi LBXZero and thx for pointing me to right directions..
yes, i have a text msg to the default chat box , so i can have some sort of OnLoad function for it ... and i have a slash cmd for Show/Hide SpellList frame.. Code:
function SpellList_OnLoad() DEFAULT_CHAT_FRAME:AddMessage("type spelllist or sl and hide/show to toggle"); end the only error msg i got is Attempt to index TextDisplayer (a nil value) in this code : Code:
local SpellID = { [1] = "Lightning Bolt(Rank 12) Nature", [2] = "Chain Lightning(Rank 6) Nature", } for i=1,#SpellID do TextDisplayer:SetText(SpellID[i]); end if i delete the last code, my addon runs with no error msg, so it would be strange..
it is defently not another addon, i made backup for all other addons, so its only WOWLUA , BUGGRABBER and my addon that runs.. and i cant see where it would be problems other places in my code... ------------------------------------------------------------------------------------------------------------- Here is the Compleate code and a ingame pic and a pic in addonstudeo for wow , so u can see all info i got : Code:
-- Author : Moolgar -- Create Date : 8/23/2008 11:25:58 PM function SpellList_OnLoad() DEFAULT_CHAT_FRAME:AddMessage("type spelllist or sl and hide/show to toggle"); end function CloseFrame_OnClick() SpellList:Hide(); end function ReloadButton_OnClick() ReloadUI(); end function Display1_OnLoad() Display1:AddMessage("This frame name is Display1", 1.0, 0.0, 0.0, 53); Display1:AddMessage("Collors works", 1.0, 1.0, 0.0, 53); Display1:AddMessage("to see if Diferent", 0.0, 0.0, 1.0, 53); Display1:AddMessage("this is a test", 0.0, 1.0, 0.0, 53); Display1:AddMessage("wellcome to SpellList", 1.0, 0.0, 0.0, 53); end --Slash cmd's SLASH_ADDSPELLLIST1 = "/spelllist"; SLASH_ADDSPELLLIST2 = "/sl"; -- A shortcut or alias SlashCmdList["ADDSPELLLIST"] = AddSpelllist_Command; function AddSpelllist_Command(cmd) DEFAULT_CHAT_FRAME:AddMessage("Command: " .. cmd); if cmd == "hide" then SpellList:Hide(); elseif cmd == "show" then SpellList:Show(); elseif cmd == "rl" then ReloadUI(); end end function Button3_OnClick() SendChatMessage(TextEditer:GetText("" ,"WHISPER" ,"COMMON" ,"")); end local SpellID = { [1] = "Lightning Bolt(Rank 12) Nature", [2] = "Chain Lightning(Rank 6) Nature", } for i=1,#SpellID do TextDisplayer:SetText(SpellID[i]); end If u want me too , i can upload mod.. i suspect i might have some wrong properties on the fontstring.. here is a pic of it Last edited by moolgar : 08-23-08 at 06:05 PM. |
|||
WoWInterface » Developer Discussions » Lua/XML Help » need some code advise |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|