• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code Solved - Script passing value to variable?

S

SVG

Guest
Using GM2

Simple question (I hope):

Similar to how you make an array change in the script and also change it's value in the object calling the script, can the same thing be done for a variable? My question lies in this example code:

Code:
<object>
scr_test(my_array, my_variable);

<scr_test>
var ary = argument[0];
var myv = argument[1];

ary[@0] = 1; //Changes value even for the array inside the object calling this script;
@myv = 1; //How can I do something similar for a variable?
 
S

SVG

Guest
Okay so to add to this, variable_instance_get() inside the script can use that string to retrieve the value, that way you don't need to pass into the script the string AND the value separate, just the string would be needed. Very cool, thanks!
 

gnysek

Member
Code:
var a;
a = script_result(17);

//script_result

return argument0;
Or, if you're 100% sure this variable exist in this object, just write "value = something" or "id.value = something". All variables from current instance scope are visible for script.
 
Top