Page 1 of 1

Multiball preset

Posted: 11 Jan 2015 13:43
by r00n
Hi
while typing with fat fingers on a small phone, i am atempting to make 2 buttons
1 will capture the x and y of multiball and the other will retreive it.
In first button... Capture
Ive declared variable v
And script is
V={multiball.x,multiball.y};

Second button... Retrieve
MultIball.x = v[1];
Multiball.y = v[2];
//My questions are:
Is there a way i can make a small output window to see what variable values are stored in array?

And
Why isnt the multiball updating upon depressing of the retreive button?

Re: Multiball preset

Posted: 12 Jan 2015 00:38
by Softcore
Declaringa variable inside a script makes it "local" to that script - plain english, the variable "exists" as the script is executed and then "dies". So declaring a variable inside a script, is strictly for REUSING IT, inside the same script.

To achieve what you are after, create a new expression inside the MultiBall object, (editor button x= ), name it for example V, and leave it blank! Then inside your capturing script (In capture button) without declaring anything type:

MultiBall.V = {MultiBall.x, MultiBall.y};

Then in your Retrieve button type:
MultiBall.x=MultiBall.V[0];
MultiBall.y=MultiBall.V[1];

Some general tips, aftervseeing what you typed above:
1.Variables are referenced from a script, according to where a script is - so for example, if V is inside the mutliball object, ANY script IN multiball "sees" it as "V" - any script outside multiball ( or inside your buttons) sees it as "MultiBall.V"
2.Always remember that the first value of an array is [0] - NOT [1]

To display what is captured, use a monitor object and type
MultiBall.V in its input

;)

Re: Multiball preset

Posted: 12 Jan 2015 00:47
by Softcore
PS. After understanding the above....it becomes clear, that you could create the V variable in the root of your project, NOT inside the multiball object.

Test: how would the scripts be different then?

Answer: therecwould be no need for the "MultiBall.V" reference then - you would just type "V"

;)

Re: Multiball preset

Posted: 12 Jan 2015 03:47
by r00n
I follow that
Thanks you so much for taking the time.
Really appreciated.