- Home /
Changing the value of variable in regards to some event
Lets say I have following code
var range = 0.1;
and a function that has to internally change the value of that variable;
function someFunction(){
}
How can I change the value of the range variable to be lets say 0.4 inside this function?
Does this not work?
function someFunction(){ range = 0.4; }
The above comment will work. But looking for the question type, do you know how to call the function (no offense here, plz)?
where did you read how to call the function? :) Zyzyx, yes, that's fine( declaring locally your variable to be greater than the value, and if you exit that sequence, get back to it's original state value ) ... :D
I just asked if you know how to call a function.
If you do that, the variable should hold that value during all execution time unless you modify it again in other function or statement.
When the function I postet is called the original value is not restored when the function finishes. But the others are right, the question is a bit vague (as, I$$anonymous$$HO, javascript most of the time is).
Answer by Xerelin · Dec 07, 2012 at 07:02 PM
function someFunction(){
var strange = range;
range = 0.4;
///////////
//Do stuff
///////////
range = strange;
}
TA DA!
Answer by skalev · Dec 07, 2012 at 04:30 PM
Your question is a bit vague.
if you don't know HOW to call a function i recommend reading the scripting tutorials.
basically you just put it's name.
so:
someFunction();
will cause it to be called.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
A node in a childnode? 1 Answer
What is a good unityscript writing program? 1 Answer
Need help with a Borderlands style proficiency system. 0 Answers