f2k sel 164 Posted June 30, 2012 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
Prodavec 10 Posted June 30, 2012 _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
f2k sel 164 Posted June 30, 2012 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
Prodavec 10 Posted June 30, 2012 Just use SET command when working with arrays if it is possible. It's the fastest (most speed-optimized) way to work with. Code Optimisation Share this post Link to post Share on other sites
f2k sel 164 Posted June 30, 2012 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