How can i edit an object in an array

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

How can i edit an object in an array

Postby l4m2 » Sun Nov 30, 2014 2:29 pm

a=[0,0,0,0,0];a(0)=1;a returns still [0,0,0,0,0]
l4m2
 
Posts: 42
Joined: Fri Jun 27, 2014 6:21 am

Re: How can i edit an object in an array

Postby Kilinich » Mon Dec 01, 2014 1:50 am

you could only re-create an array (or write function to do it).
also there is some tricks like this:

a := [0,0,0,0,0];
a = a * [1,1,0,1,1] + [0,0,1,0,0] * b
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: How can i edit an object in an array

Postby l4m2 » Mon Dec 01, 2014 2:50 am

Kilinich wrote:you could only re-create an array (or write function to do it).
also there is some tricks like this:

a := [0,0,0,0,0];
a = a * [1,1,0,1,1] + [0,0,1,0,0] * b

Byt what if some other things(for example,strings) existed?
setv=(a,i,d){z="";for(string.length(a),(j)=>{z=z+(j>0?",":"")+(i==j?"d":"a("+j+")")});z}
is said Bad index in list.
Of course,if succeed we have to evaluate(eval) it.
l4m2
 
Posts: 42
Joined: Fri Jun 27, 2014 6:21 am

Re: How can i edit an object in an array

Postby l4m2 » Mon Dec 01, 2014 3:10 am

setv=(a,i,d)=>{z="[";for(string.length(a),(j)=>{z=z+(j>0?",":"")+(i==j?"d":"a("+j+")")});eval(z+"]")}
I mistook thyme again....
l4m2
 
Posts: 42
Joined: Fri Jun 27, 2014 6:21 am


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 6 guests