color=skycolor and sim.time

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

color=skycolor and sim.time

Postby Cs24 » Fri Nov 13, 2009 3:35 am

I need some help changing the colour of the big white box in this scene
[scene]33509[/scene] to match the colour of the circles in the background changer.

i.e. I need the white box to be the same color as the background as the background changes.

I've tried putting this on the box but doesn't work
(e)=>{e.this.color=app.background.skycolor}


--------------------------------------------
What script would I need to make a spawned object delete after it has been in the scene x amount of sim.time :think:

any help is greatly appreciated

this is part of a lager project to remake
Rating: rated 8.3
Filesize: 8.33 kB
Comments: 17
Ratings: 14
download

and could someone explain why the above scene doesn't work in algodoo
Newbie Thymer
Intermediate Phuner
Cs24
 
Posts: 41
Joined: Tue Nov 03, 2009 5:30 am

Re: color=skycolor and sim.time

Postby standardtoaster » Fri Nov 13, 2009 4:31 am

You were very close with the first scene! Instead of using onCollide to change the color put {app.background.skyColor}

As for the delete after a set amount of time look at this scene.
Rating: rated 5.6
Filesize: 38.51 kB
Comments: 3
Ratings: 2
download

Timer script:
Code: Select all
(e)=>{
    sim.time - e.this.controllerAcc >= 2 ? {         Scene.my.deleteDensity = 0;         e.this.controllerAcc = sim.time     } : {Scene.my.deleteDensity = 2} }


Spawn script:
Code: Select all
(e)=>{
    scene.addCircle({         radius := 1;         density := {Scene.my.deleteDensity};         restitution := 0.5;         friction := 0.5;         color := [0, 0, 0, 0.5];         vel := [0, 0];         pos := App.mousePos     }) }


In the timer script you can change the "2" after the >= sign to however long you want it to wait.
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: color=skycolor and sim.time

Postby niffirg1 » Fri Nov 13, 2009 4:40 am

standardtoaster wrote:
Code: Select all
(e)=>{
    sim.time - e.this.controllerAcc >= 2 ? {         Scene.my.deleteDensity = 0;         e.this.controllerAcc = sim.time     } : {Scene.my.deleteDensity = 2} }

Could you explain this code I do not really understand it. I get the if statement but i don't get why this works
User avatar
niffirg1
 
Posts: 376
Joined: Mon Aug 31, 2009 10:31 pm
Location: The Great American South!

Re: color=skycolor and sim.time

Postby standardtoaster » Fri Nov 13, 2009 4:53 am

I put that script into a beacon so that it is constantly checking. I take the current simulation time and store it in the controllerAcc of the object. I continuously subtract the current simulation time with the controlerAcc and check if it greater than or equal to the set delete time. Once it reaches the delete time it sets the variable, scene.my.deleteDensity, to zero. I have another beacon in the scene with a similar script that will spawn a circle with the density of {scene.my.deleteDensity}. Once it reaches the delete time it will 'reset' the circle's controllerAcc to the simulation time. If it hasn't reached the delete time yet it keeps scene.my.deleteDensity at a constant value of 2. Now do you understand? ;)
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: color=skycolor and sim.time

Postby Cs24 » Fri Nov 13, 2009 6:04 am

Thanks standardtoaster for the quick rply!

so any idea why RaRamalum's life scene doesn't work in algodoo?
or a way to get to delete objects with the timer in phun
and the delete only works with the newest spawned circle

(either or, I just need one other two to work)

edit: adding timer to raramalum's "animals" is going to be fun.....
so many things to fix :crazy: :P
Last edited by Cs24 on Fri Nov 13, 2009 6:08 am, edited 1 time in total.
Newbie Thymer
Intermediate Phuner
Cs24
 
Posts: 41
Joined: Tue Nov 03, 2009 5:30 am

Re: color=skycolor and sim.time

Postby standardtoaster » Fri Nov 13, 2009 6:05 am

I don't know why it doesn't work in Algodoo. I'll look into it but I think that RaRaMalum would be more suited for it, as it is his scene.
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: color=skycolor and sim.time

Postby Cs24 » Fri Nov 13, 2009 6:19 am

and where do I put {app.background.skyColor}, if not in OnCollide?

edit: thanks (to below)
Last edited by Cs24 on Fri Nov 13, 2009 6:45 am, edited 1 time in total.
Newbie Thymer
Intermediate Phuner
Cs24
 
Posts: 41
Joined: Tue Nov 03, 2009 5:30 am

Re: color=skycolor and sim.time

Postby standardtoaster » Fri Nov 13, 2009 6:40 am

Sorry I didn't tell you. Put it in the color section of the script window.
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: color=skycolor and sim.time

Postby standardtoaster » Sun Nov 15, 2009 2:55 am

standardtoaster wrote:I don't know why it doesn't work in Algodoo. I'll look into it but I think that RaRaMalum would be more suited for it, as it is his scene.

I know why it doesn't work. It has a backwards e.normal. If you want me to I can upload the fixed scene unless RaRaMalum wants to update it. :roll:
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 8 guests