This site makes extensive use of JavaScript.
Please enable JavaScript in your browser.
Classic Theme
Thottbot Theme
Stumped by Lua again...gak!
Post Reply
Return to board index
Post by
RedwoodElf
OK...in preparation for adding an interface with clickable controls, I encapsulated the code from my primary slash command options into functions, as you can see in
this pastey
However, for some reason it's not working. The elseif statements are functioning correctly (I pasted some chatframe prints inside them just to be sure, and they print when the slash command options are present)
But the function calls aren't being called.
When I put the same chatframe prints INSIDE the functions (above the slash command definition at the bottom) they don't print out.
Could some lua wizard tell me what I'm doing wrong with the function calls? Calls to the functions Lagbuster:Applysettings() and Lagbuster:SetBuster() work just fine, but calls to NONE of the other functions from the slash command function are working.
I don't see any errors in the lua code, I'm not getting any errors in the XML log, and the empty settings option prints out just fine.
/em yankshairout
Post by
4466
This post was from a user who has deleted their account.
Post by
RedwoodElf
I suspect the problem is that the argument passed to your slash command handler is larger than you think it is. You want to look at only a piece of it. For example...
SlashCmdList = function(setting)
if setting == "" then
if Lagbuster.NewLag ~= Lagbuster.ActiveSettings then Lagbuster.ActiveSettings = Lagbuster.NewLag end
if Lagbuster.ActiveSettings ~= Lagbuster.LastApplied then
Lagbuster:ApplySettings()
end
--output usage here
elseif string.sub(setting, 1, 2) == "up" then
Lagbuster:Up()
elseif string.sub(setting, 1, 4) == "down" then
Lagbuster:Down()
elseif string.sub(setting, 1, 4) == "zone" then
Lagbuster:Zone()
....
end
end
Except that I know it isn't...I checked the elseifs already, as I said, putting printout statements to the chat window in each of them, and it's executing the code within each of the elseifs at the appropriate times...so if I typed:
/lbust up
then the printout in the
elseif setting == "up" then
block printed in the chat window, but when it tried to call the function "Lagbuster:Up()" it got no further. (I also put a print statement AFTER the call, and it never reached it) so somehow, it's locking up on the function call.
To be more precise, the elseif block read as follows when I was testing it:
elseif setting == "up" then
ChatFrame1:AddMessage("Entering 'up' Block")
Lagbuster:Up()
ChatFrame1:AddMessage("Exiting 'up' Block")
and when I typed the slash command it printed out only
Entering 'up' Block
in the chat window.
Post by
4466
This post was from a user who has deleted their account.
Post by
RedwoodElf
So close and yet so far...while that does appear to be AN error, it doesn't appear to be THE error...I fixed that, and the behavior hasn't changed...and it isn't just the "up" function that isn't working, ALL of them weren't working...
and I found out why!
I was trying to save all of the Lagbuster variables between sessions by simply putting:
##SavedVariables: Lagbuster
in the TOC file. But what that was doing was simply saving
Lagbuster = nil
since Lagbuster was a global.
So, I split out each of the variables and saved them individually, and the slash commands are working, now that the saved variable load wasn't wiping out all of the Lagbuster:<methodname> functions by nilling out the entire addon's data structure (I'm amazed that this wasn't causing even more errors) Now all I have to do is make sure the functions are working right...
Which, of course, they aren't...but the problem now is, the savedvariables file is coming up empty. Here's my TOC file, if someone can tell what I'm doing wrong saving all the variables?
## Interface: 30100
## Title: Lagbuster 1.00
## Notes: Sets graphics options with slash command, based on zone settings.
## SavedVariables: Lagbuster.Wide
## SavedVariables: Lagbuster.MSR
## SavedVariables: Lagbuster.MSQ
## SavedVariables: Lagbuster.REZ
## SavedVariables: Lagbuster.FL
## SavedVariables: Lagbuster.HWC
## SavedVariables: Lagbuster.MFPS
## SavedVariables: Lagbuster.FPSMN
## SavedVariables: Lagbuster.PIXSD
## SavedVariables: Lagbuster.SEL
## SavedVariables: Lagbuster.WS
## SavedVariables: Lagbuster.WEF
## SavedVariables: Lagbuster.ED
## SavedVariables: Lagbuster.TFM
## SavedVariables: Lagbuster.BMP
## SavedVariables: Lagbuster.MS
## SavedVariables: Lagbuster.SLOD
## SavedVariables: Lagbuster.GED
## SavedVariables: Lagbuster.GEVD
## SavedVariables: Lagbuster.FCLIP
## SavedVariables: Lagbuster.HFCLIP
## SavedVariables: Lagbuster.PDL
## SavedVariables: Lagbuster.PRINTS
## SavedVariables: Lagbuster.DEATH
## SavedVariables: Lagbuster.GLOW
## SavedVariables: Lagbuster.PTEXT
## SavedVariables: Lagbuster.SQUAL
## SavedVariables: Lagbuster.WideResolutions
## SavedVariables: Lagbuster.NarrowResolutions
## SavedVariables: Lagbuster.Zones
## Dependencies:
Lagbuster.lua
Lagbuster_Globals.lua
Lagbuster_Frames.lua
Post by
RedwoodElf
Tried a number of variations, including just putting all the variables in one big line like so:
## Interface: 30100
## Title: Lagbuster 1.00
## Notes: Sets graphics options with slash command, based on zone settings.
## SavedVariables: Lagbuster.Wide Lagbuster.MSR Lagbuster.MSQ Lagbuster.REZ Lagbuster.FL Lagbuster.HWC Lagbuster.MFPS Lagbuster.FPSMN Lagbuster.PIXSD Lagbuster.SEL Lagbuster.WS Lagbuster.WEF Lagbuster.ED Lagbuster.TFM Lagbuster.BMP Lagbuster.MS Lagbuster.SLOD Lagbuster.GED Lagbuster.GEVD Lagbuster.FCLIP Lagbuster.HFCLIP Lagbuster.PDL Lagbuster.PRINTS Lagbuster.DEATH Lagbuster.GLOW Lagbuster.PTEXT Lagbuster.SQUAL Lagbuster.WideResolutions Lagbuster.NarrowResolutions Lagbuster.Zones
## Dependencies:
Lagbuster.lua
Lagbuster_Globals.lua
Lagbuster_Frames.lua
but the dang saved variable file still winds up blank...maybe High Five or someone with some Saved Variable experience can tell me what's going on? According to the resources I've seen, just putting the variable in the TOC file like that should save the value in the WTF/SavedVariables/Lagbuster file....
Post by
4466
This post was from a user who has deleted their account.
Post by
RedwoodElf
Well each of those variables is itself a table...So I'll need to make a table of those tables, and make a read-in function for use on "PLAYER_LOGIN" or somesuch that copies the elements of the readin table to the addon's variables? The documentation I've read says that should be handled automatically by the WOW UI (Says that at load time it first reads the actual addon file values, and THEN overwrites them with the saved values)
Is that not correct then?
Post by
4466
This post was from a user who has deleted their account.
Post by
RedwoodElf
Hmn...assuming that tables are referenced (I.E. Use pointers rather than values) then you should be able to simply access the saved variable directly, making any changes directly to the saved variable, shouldn't you?
I presume that the SavedVariable needs to be defined as local, since my attempt to simply save the entire Addon structure as a SavedVariable didn't work...
(In other words, when I used:
##SavedVariables: Lagbuster
It just saved
Lagbuster = Nil
in the WTF file, which is what was causing the whole thing to stop working when that was loaded back in as the main wrapper table....)
What I'm really wondering is, Why won't it save the tables As-is? I was perfectly willing to save the tables individually, but it's not working, and apparently no-one knows why. According to WOWWiki, it should have worked, but for some reason it doesn't...
Post by
4466
This post was from a user who has deleted their account.
Post by
RedwoodElf
Well it USES pointers, backend...but like Java, you can't access or manipulate pointers directly. Tables and their subset of Arrays, for example, are clearly implemented backend as linked lists, rather than actual memory arrays (If they weren't, you couldn't just add an element to an array dynamically on-the-fly like you can in lua.) And the values are what are saved, and then re-loaded into tables at runtime.
The tricky part is, figuring out why the first attempt to implement the "wrapper table" as a saved variable won't work...probably it tossed an error because of the imbedded methods, so moving all the variables I want to save to a separate table will (Hopefully) make it work correctly.
I'll check it out when I get home tonight.
Post Reply
You are not logged in. Please
log in
to post a reply or
register
if you don't already have an account.