Thread Tools Display Modes
05-07-11, 02:57 AM   #1
dstruct2k
A Defias Bandit
Join Date: May 2011
Posts: 2
Issues with SetCVar

I've been working on an addon that dynamically adjusts draw distance based on FPS; I'll be adding many more "dynamic" settings to it once I've fleshed out the concept with farclip.

My issue is... In 4.0.6, I was able to use SetCVar("farclip", newfarclip) to change draw distance, and it was updated immediately. Now in 4.1, the same code isn't having the desired effect; What happens is the cvar is changed but the actual render distance stays the same. If I type /console print(GetCVar("farclip")), I get the expected new value assigned by my addon, yet the game world doesn't change to reflect this new value.

Example:
Farclip @ 1600
Getting 10 FPS out of 60; Addon responds by dropping farclip to 266
Rendered world does not change, but console reports farclip is now @ 266

A quick sample of how I go about this follows:

Code:
if (fps/requestedfps) < 0.9 then
  local newfarclip = floor((fps/requestedfps)*(GetCVar("farclip")))
  SetCVar("farclip", newfarclip)
end
Any ideas? I can pastebin my LUA if anyone wants to take a look.
  Reply With Quote
05-07-11, 03:44 PM   #2
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Originally Posted by dstruct2k View Post
If I type /console print(GetCVar("farclip"))
You have a "typo" there

I just went on Live and tested out these commands and they both worked immediately for me ..
Code:
/console farclip 25
/run SetCVar("farclip", 25)
  Reply With Quote
05-07-11, 04:07 PM   #3
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Careful when using math on GetCVar, as it can return strings even for numerical settings. tonumber() works well.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Issues with SetCVar


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off