Jump to content
Sign in to follow this  
f2k sel

I need a little help with Setvaraible getvariable

Recommended Posts

Hi, I've just managed to get some of this to work.

Well it works as long as I use a separate variable for every value but I know that isn't needed.

My problem is changing the values.

Example. I have

player setvariable ["my_Var",[1,2,3],true];

What would be the easiest way to change this to

required result

player setvariable ["my_Var",[1,2,9],true];

Will I have to retrieve all elements and put them back or is there a short cut.

Thanks Sel.

Share this post


Link to post
Share on other sites

_value = player getVariable "my_var"; // [1, 2, 3]
_value set [2, 9];
player setVariable ["my_var", _value, true]; // [1, 2, 9]

player setVariable ["my_var", (player getVariable "my_var") set [2, 9], true]; // ERROR!

Share this post


Link to post
Share on other sites

Cheers it works, It turns out though for my purpose that extracting the values will be a little less typing, if there were more than three then I think it would be the way to go.

Share this post


Link to post
Share on other sites

Thanks in this case it really won't matter as it only used occasionally and doesn't involve continuous use of it.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×