How do you make a phunet add its own variables into a scene?

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

How do you make a phunet add its own variables into a scene?

Postby Alex_Mercer » Sun Feb 01, 2015 10:04 am

Here's my gearbox>http://www.algodoo.com/algobox/details.php?id=94667

The problem is, when I have saved it as a phunlet and insert it in another scene, it won't work. So, I will have to put in variables "scene.my.gearr, secene.my.gear1-9" all over again for it to work. It is very impractical... and stupid.

I am a super newbie on thyming. Can you help me out here? Any scripts that will add variables every time I use the phunlet? Plus, can you give me a good link where I can learn everything about thyming?
BTW, how's my gearbox? Descent? Bad? Keul?

Thanks a ton, and have a nice day! :D
User avatar
Alex_Mercer
 
Posts: 6
Joined: Thu Oct 30, 2014 9:18 pm
Location: Syriam, Myanmar

Re: How do you make a phunet add its own variables into a scene?

Postby electronicboy » Wed Feb 04, 2015 1:43 pm

All you can really do is add a if onto something in there, with a blank variable or something. pretty much something along the lines of

if scene.my.geartestv != 1 then
scene.my.geartestv :=1
<init other variables
endif


^ Not thyme code ofc, Not touched thyme in while, but in theory that should work
When asking for help, READ THE STICKIES!
electronicboy
 
Posts: 1694
Joined: Mon Aug 31, 2009 6:18 pm

Re: How do you make a phunet add its own variables into a scene?

Postby Kilinich » Wed Feb 04, 2015 2:24 pm

There is a better way - onSpawn events in object's script menu.
So put some geom on scene, send to back, add onSpawn=(e)=>{scene.my.test = 0}
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 do you make a phunet add its own variables into a scene?

Postby Alex_Mercer » Fri Feb 06, 2015 7:08 pm

Kilinich wrote:There is a better way - onSpawn events in object's script menu.
So but some geom on scene, send to back, add onSpawn=(e)=>{scene.my.test = 0}



Thanks a lot man, now my gearbox is working like a charm! :thumbup: :clap: :D

@electronicboy: That was a little complicated for me; didn't really get what you meant... Thanks a lot for your effort, tho!
User avatar
Alex_Mercer
 
Posts: 6
Joined: Thu Oct 30, 2014 9:18 pm
Location: Syriam, Myanmar

Re: How do you make a phunet add its own variables into a scene?

Postby Kilinich » Sat Feb 07, 2015 2:03 pm

Alex_Mercer wrote:
Kilinich wrote:There is a better way - onSpawn events in object's script menu.
So but some geom on scene, send to back, add onSpawn=(e)=>{scene.my.test = 0}



Thanks a lot man, now my gearbox is working like a charm! :thumbup: :clap: :D

@electronicboy: That was a little complicated for me; didn't really get what you meant... Thanks a lot for your effort, tho!


More elegant way is to check if it runs only on scene start (not on undo):

onSpawn=(e)=>{sim.time == 0 ? {scene.my.test = 0} : {}}
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


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 19 guests