checking if CVar exists
Yo, I've been looking for a while and I haven't found something. I simply want to check if a cvar actually exists in case some get removed before Classic release. The following example produces an error if the cvar doesnt exist:
Code:
function setcvarifexists(cvar, value) EDIT: I'm also looking for a command to update all cvars similar to RestartGx(). For example the Timestamp setting will only load after reloading ui. |
Have you tried just using SetCVar and use the return value and the event if necessary to continue the code process.
https://wow.gamepedia.com/API_C_CVar.SetCVar The other option is to use the static variable NUM_LE_EXPANSION_LEVELS that is set to 1 for Classic and use that as a guide for Classic based functionality access and make any necessary changes using an if statement block, if you were hoping to have one source code base for both versions. |
I'm getting an error as soon as im calling SetCvar or GetCvarDefault with a nonexisting CVar. "Couldn't find a CVar named 'xdtest'".
|
You can use pcall() to capture the error and prevent it from being raised. If an error occurs, it instead returns false plus the error message as a string. Otherwise, if successful, it returns true with the returns from the called function appended.
|
Thank you very much for this great solution!
Lua Code:
Only one call, I'm super happy with that! Gonna look into the secure action button from my other thread now :) |
All times are GMT -6. The time now is 05:31 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI