Command Consolidation

UI and Macro
I'm trying to create some macros for testing/playing with some in-game settings, and I'd like to know if the following is possible.

For example, let's just take the in-game View Distance slider, which is tied to the "graphicsViewDistance" CVar.

I'd like to create a macro that, when holding down Shift, will increase its value by one (up to a maximum of 10), and when holding down Ctrl, will decrease its value by one (down to a minimum of 1).

In addition, I would prefer that the command not "wrap around." So, if it's at a value of 1 (its lowest value), it doesn't wrap around and shoot back up to 10. Likewise, if it's already at 10, it should not wrap around and drop to 1.

Is there any quick and easy way to do this? If it requires a macro "extender," then that's fine; I already have access to the full 1,023 characters.

Thanks
I think graphicsViewDistance should auto-clamp.

/run local s,g=SetCVar,"graphicsViewDistance"local c=GetCVar(g)if IsShiftKeyDown()then s(g,(c+1))else if IsControlKeyDown()then s(g,(c-1))end end print("View Distance set to "..c)

If holding Shift, gVD+1, else if holding Ctrl gVD-1. Also displays current gVD.

Reply if gVD doesn't auto-clamp. A simple check can be added.
Okay, so it does work, but there are two issues.

  • While it auto-clamps at 10, it doesn't auto-clamp at 1. It will move to 0 and keep moving into negative values.
  • After I begin using the macro, it seems to print out the gVD value incorrectly—one behind its actual value. So, for example, let's say I start at a gVD value of 7; here's what happens:

      (My Action) ‒ (What is printed out) ‒ (What in-game value is set)
      Click [no mod] — 7 — 7
      Ctrl+Click ‒‒‒‒‒ 7 — 6
      Ctrl+Click ‒‒‒‒‒ 6 — 5
      Shift+Click ‒‒‒‒ 5 — 6
      Shift+Click ‒‒‒‒ 6 — 7
      Click [no mod] — 7 — 7
  • So, it's setting the value properly, but it's printing it out incorrectly.

Ultimately, I'd like to set up one of these types of macros for each of the in-game settings (almost all are easily set using graphicsSettingName), so I can hopefully test out more to see which clamp and which don't.

Thanks, again.
Manual clamping is done by;

/run local s,g=SetCVar,"graphicsViewDistance"local c=GetCVar(g)if IsShiftKeyDown()and(c<10)then s(g,(c+1))else if IsControlKeyDown()and(c>1)then s(g,(c-1))end end print("View Distance set to "..GetCVar(g))


gVD will now only be set if gVD is more than 1 or less than 10.

I adjusted the print() statement to print the current gVD value, instead of the un-updated variable.

For future editing for other console variables, change graphicsViewDistance and (c>1) and (c<10).

Here's another script to change between two commonly used variables instead of cycling up and down;

/run local f="farclip"SetCVar(f,GetCVar(f)==3 and 8 or 3)(essentially: if farclip is equal to 3 then set it to 8, otherwise set it to 3.)

This toggles farclip between 3 and 8.
With the latest iteration I'm getting an error when using either of the modifiers.

1x [string "local s,g=SetCVar,"graphicsViewDistance"loc..."]:1: attempt to compare string with number
[string "local s,g=SetCVar,"graphicsViewDistance"loc..."]:1: in main chunk
[C]:: in function 'RunScript'
FrameXML\ChatFrame.lua:2158: in function '?'
FrameXML\ChatFrame.lua:4734: in function <FrameXML\ChatFrame.lua:4681>
[C]:: in function 'ChatEdit_ParseText'
FrameXML\ChatFrame.lua:4396: in function 'ChatEdit_SendText'
FrameXML\ChatFrame.lua:2884: in function <FrameXML\ChatFrame.lua:2877>
[C]:: ?
[C]:: in function 'UseAction'
FrameXML\SecureTemplates.lua:345: in function 'handler'
FrameXML\SecureTemplates.lua:623: in function 'SecureActionButton_OnClick'
[string "*:OnClick"]:4: in function <[string "*:OnClick"]:1>

The above error is for Shift, but if I use Ctrl it says "attempt to compare number to string" instead.

I appreciate the help with this.
Try;
/run local s,g=SetCVar,"graphicsViewDistance"local c=tonumber(GetCVar(g))if IsShiftKeyDown()and(c<10)then s(g,(c+1))else if IsControlKeyDown()and(c>1)then s(g,(c-1))end end print("View Distance set to "..GetCVar(g))
10/13/2018 10:36 AMPosted by Steelfistv
Try;
/run local s,g=SetCVar,"graphicsViewDistance"local c=tonumber(GetCVar(g))if IsShiftKeyDown()and(c<10)then s(g,(c+1))else if IsControlKeyDown()and(c>1)then s(g,(c-1))end end print("View Distance set to "..GetCVar(g))


This one definitely gets the job done with no perceivable quirks or errors.

Thanks, again!
Okay, so I do have an additional question about this on something I overlooked.

Now that I'm setting up some macros and going through all of the settings, I'd like to change the output that is being sent to the chat window.

When it comes to setting values on the sliders, they're obviously labeled 1 through 10 and they line up nicely with their associated CVar value. On the other hand, every other setting pretty much has a word associated with its assignment, in the GUI, rather than just a number.

So, what's an easy way to modify the print line to handle that?

A few examples:

Projected Textures are enabled/disabled. (2 CVar Values)
Shadow Quality set to Low/Fair/Good/High/Ultra/Ultra High. (6 CVar Values)

I assume you'd use GetCVar to obtain the current value, and then plug it into one or more if/else statements with hard-coded setting labels? I wish I knew more about Lua, but if someone could give me a quick and dirty example, then I could just expand upon it myself. ;)

Thanks

Join the Conversation

Return to Forum