store data in "n" scene.my. variables

About advanced scenes, and the Thyme scripting language used in Algodoo.

store data in "n" scene.my. variables

Postby hiltropper » Mon Jun 20, 2011 11:38 pm

hey there .
i have a question about creating scene.my. variables in a row .
i want for n times the laser hits something , that the newest position is saved as an array in a scene.my.
but creating scene.my.var(i) or something like this that could allow a ongoing row is not possible.
how would i do that ?
it should look like that after:
i have a circle that moves
sim.time=0 => e.pos=[0,0]
now i hit the activation key of a laser and the pos will be saved in scene.my.var0
sim.tim=13 => e.pos=[35.6,0]
when i hit the key now , it should not reset scene.my.var0, it should create a new scene.my.var1 with the new position
as is said, i could not get it working with the
Code: Select all
for(n ,(i)=>{})
structure
what could i do?
yup yup
yuuuuuuup
yupyupyupyupyupyupyupyupyyyuuuup
hm... signatures...
hiltropper
 
Posts: 85
Joined: Mon Dec 20, 2010 12:02 pm
Location: Germany

Re: store data in "n" scene.my. variables

Postby Kilinich » Tue Jun 21, 2011 7:33 am

there are few ways to do that.
must suitable (IMHO) is to add values to list and increment counter

//init
scene.my.array := [];
scene.my.count := 0;

//add value
scene.my.array = scene.my.array ++ [e.pos];
scene.my.count = scene.my.count + 1;

//read and display array
for (scene.my.count, (i) => {print("Pos #" + i + " = " + scene.my.array(i)});
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: store data in "n" scene.my. variables

Postby hiltropper » Tue Jun 21, 2011 11:59 am

ah alright did not think of lists
thank you !
yup yup
yuuuuuuup
yupyupyupyupyupyupyupyupyyyuuuup
hm... signatures...
hiltropper
 
Posts: 85
Joined: Mon Dec 20, 2010 12:02 pm
Location: Germany


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 3 guests