Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
Register
(Added information on scriptCVar)
(Updated with new information)
Line 20: Line 20:
   
 
By default CVAR_UPDATE is not fired when you call SetCVar, to make sure it does you need to pass the third argument scriptCVar which will be the first argument in the event when it's fired.
 
By default CVAR_UPDATE is not fired when you call SetCVar, to make sure it does you need to pass the third argument scriptCVar which will be the first argument in the event when it's fired.
  +
  +
  +
== Notes ==
  +
From Ohklus: '''Do not overwrite this function!''' You'll have a very hard time finding the reason for those nasty "sry, your addon was blocked cause it called a secure function" errors.
  +
  +
My example: hitting the escape key should just open the game menu. If you overwrite SetCVar you'll get the error each time you press Esc (except when closing a window). The error is released by the Blizzard UI functions [[API_SpellStopCasting]], [[API_SpellStopTargeting]] and [[API_ClearTarget]], because they appear in [[API_ToggleGameMenu]]. I've got no idea why SetCVar is called between hitting Esc and reaching [[API_ToggleGameMenu]].
   
 
__NOTOC__
 
__NOTOC__

Revision as of 23:37, 20 July 2008

Changes a variable located inside Config.wtf

 SetCVar( "cvar", value[, "scriptCVar"] );

Parameters

Arguments

cvar
String - CVar to modify
value
New value of the CVar, the game
scriptCVar
String - First argument for the CVAR_UPDATE event, if none is passed then the event isn't fired

Details

Settings that are changed using this will be applied to the game UI immediately, however settings are not saved until exit and settings which were previously not defined in Config.wtf are not available to GetCVar until the file has been saved at logout.

Some options require a call to RestartGx() before they take effect.

If you try and pass an invalid CVar you'll get an error, check Config.wtf defaults for a list of valid CVars.

By default CVAR_UPDATE is not fired when you call SetCVar, to make sure it does you need to pass the third argument scriptCVar which will be the first argument in the event when it's fired.


Notes

From Ohklus: Do not overwrite this function! You'll have a very hard time finding the reason for those nasty "sry, your addon was blocked cause it called a secure function" errors.

My example: hitting the escape key should just open the game menu. If you overwrite SetCVar you'll get the error each time you press Esc (except when closing a window). The error is released by the Blizzard UI functions API_SpellStopCasting, API_SpellStopTargeting and API_ClearTarget, because they appear in API_ToggleGameMenu. I've got no idea why SetCVar is called between hitting Esc and reaching API_ToggleGameMenu.