dynamically add a variable to an object that sticks?

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

dynamically add a variable to an object that sticks?

Postby Mr_Stabby » Fri Feb 26, 2010 7:46 pm

Im so tired of using color and texture matrix variables to store data, isnt there any way to permanently add a custom variable to an object like u do when u type something=2 in the empty box at the bottom of each objects script menu?
Mr_Stabby
 
Posts: 155
Joined: Wed Dec 16, 2009 12:16 am

Re: dynamically add a variable to an object that sticks?

Postby daniels220 » Fri Feb 26, 2010 8:41 pm

Code: Select all
if (!e.this.somevar) { e.this.{somevar} := something; }


Something like that should work. The := is important. (The syntax could be wrong—I don't really know Thyme, just bits and pieces, and I'm much more used to JavaScript syntax.) It'll work without the if, but throw warnings about variable already defined (if you put this in a repeating onCollide/onLaserHit).
daniels220
 
Posts: 95
Joined: Mon Aug 31, 2009 11:30 pm

Re: dynamically add a variable to an object that sticks?

Postby Mr_Stabby » Sat Feb 27, 2010 4:54 am

great! combined that with something else i found while browsing this forum and came up with this:

Rating: rated 5.6
Filesize: 15.83 kB
Comments: 1
Ratings: 2
download
Mr_Stabby
 
Posts: 155
Joined: Wed Dec 16, 2009 12:16 am


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 6 guests

cron