Two quick questions
Hey there, instead of filling the forum with more threads I thought I'd just put these two into one.
Firstly, I have a script that sets a global variable:
global nudgeValue
And later in the script it's set and changed and accessed by different functions. It's being manipulated later on in the script by a spinner. But to make it so that the spinner remembers it's last value after it's closed it will see if the global value has been set and if so use it, if not, not.
So...
if nudgeValue == undefined then
Right?
Doing that in the listener works fine, but that one after the other in the script throws up an error: Syntax error: at if, expected
Second question!
My script contains some regular steps that creates a dialog to manipulate the global value. It then creates a four functions which use this global variable.
I want to set-up keyboard shortcuts for these four functions, but how can I without making each an individual script and then assigning keyboard shortcuts?
Many thanks in advance!
Comments
Even with the code: if
Even with the code:
It gives me an error. Is there another way of checking if a global variable has been used?
I understand the keyboard entry now, thank you very much. It helps a lot with another part of the script I'm doing.
There's another way to check
There's another way to check for global values only, the double-colon :: which would work even if there is a local variable of the same name used before the test:
However, your previous code should work as it is anyway...
Some of my scripts and MCGs :: 3ds Max SDK Intro for Scripters
It's really strange to have
It's really strange to have any errors on the example code you wrote, it s'd works fine.
my recent MAXScripts RSS (archive here)
Ok, at the If-Then question.
Ok, at the If-Then question. Your syntax is correct (due to the docs) cause the docs say that Else is optional but the practice is against that, so if you want to not go in unnecessary troubles then just always use the full form If-Then-Else (never omit Else) and if there no need of Else just use If-Do instead.
And for the hotkeys and "Keyboard Entry" help-topic, I presume you talk about
getKBValue()
but read below, their is 4 keys you can track:Yes, very limited amount of keys but you can combine them, for eg:
And if thats not enough, then yes, for a custom keyboard hotkeys you need to write your functions to separate macro scripts.
my recent MAXScripts RSS (archive here)
The full code for the if
The full code for the if statement simply creates a box at the moment to check if it works.
Once it works it will simply state:
And later the spinner value will state:
As for the second question, I've looked in the documentation about "Keyboard Entry" but it doesn't seem to apply to what I want. If I've looked over that correctly then that's for entering text into the Listener and it evaluating it?
I would like the user to run this whole script once, setting up a dialog box which they use a spinner and then close; but for the functions to be set to keyboard shortcuts which the user is able to initiate while in the viewport (which is why the nudge value is set as a global).
Is this possible at all? I suppose I could make several scripts but... it seems oddly inefficient.
Thanks for your help.
At the 1st question - maybe
At the 1st question - maybe you miss something inside your Then expression; w/o additional code cant helps more.
At the 2nd - check "Keyboard Entry" topic in the help.
my recent MAXScripts RSS (archive here)