PDA

View Full Version : Making my mod use Cosmos options and checkboxes... or not


Jerek
03-06-2005, 11:38 PM
I have a mod that's practically complete, and I'm trying to get it to use Cosmos to save and manage the options, but for some reason I get stack overflow errors when I try to load the mod. I commented out most of the options, and have just enabled this one checkbox. Can someone tell me what I'm doing wrong?

Cosmos_RegisterConfiguration(
"COS_JDHP_ShowMaxes", -- CVar
"CHECKBOX", -- Type
TEXT(JDHP_MAXES), -- Short description
TEXT(JDHP_MAXESL), -- Long description
JDHP_ShowMaxesToggle, -- Callback
0 -- Default Checked/Unchecked
);

The comments there are left as I found them on WoWWiki's Cosmos Developer's Guide. Although I'm uncertain as to what it means by "Callback". Is this supposed to be a funtion to handle when a checkbox is toggled? I assumed so, and wrote this function:

function JDHP_ShowMaxesToggle ()
JDHP_ShowMaxes = COS_JDHP_ShowMaxes_X;
if (JDHP_ShowMaxes == 1) then
Cosmos_UpdateValue("COS_JDHP_ShowMaxes",CSM_CHECKONOFF,0);
CosmosMaster_Save();
else
Cosmos_UpdateValue("COS_JDHP_ShowMaxes",CSM_CHECKONOFF,1);
CosmosMaster_Save();
end
end

Any ideas?

Dutchy
03-07-2005, 08:08 PM
I assumed the same for the callback, but it didnt do anything at all
http://www.cosmosui.org/forums/viewtopic.php?t=7572

Jerek
03-08-2005, 11:07 PM
I sent AlexanderYoshi an email about this, and got this reply:

The callball calls YOU when the checkbox is toggled, e.g.

function CallBack(checked)

if ( checked ) then
-- Do X
else
-- Do Y
end

end

calling CosmosMaster_Save() will cause CallBack() to be called in an infinite loop. CosmosMaster_Save() is only useful when you want to update the
gui from outside of the screen.
I'll take a look at my code later and see what I can do with it. Right now I'm trying to get my new video card (which replaced my fried one) to accept its drivers. I may have to reinstall Windows. :(

Dutchy
03-09-2005, 03:31 PM
sarf replied to my thread, you might find it usefull... it's for the slider, the checkbox is similar

Jerek
03-22-2005, 12:24 AM
Ok, I fixed my toggle variable problem (the problem being that I wasn't using it at all), and now things seem to work, except that variables don't seem to sink in until the interface is reloaded (either by relogging or /rl). As a workaround I'm manually setting extra non-saved variables with the same values. So the non-saved variable keeps track of current settings, and the saved ones don't work currently but are saved for the next time the mod is started. Is this behavior intentional, or is there a way to use the Cosmos saved variables actively, or am I just doing something wrong?

(I took a long time before fixing this thanks to a marathon of bizarre computer problems that kept me from WoW and my mod. :()