Block after a certain number

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

Block after a certain number

Postby Techa » Thu Feb 11, 2010 10:19 am

Would someone mind telling me how to do this? Basically I want something to collide with something else and it adds a variable. After the variable reach a certain number, it creates a block, stops spinning something. etc.
Techa
 
Posts: 1
Joined: Thu Feb 11, 2010 10:13 am

Re: Block after a certain number

Postby standardtoaster » Thu Feb 11, 2010 10:30 am

Code: Select all
Scene.my.num > x ? {Spawn box} : {}

X is any number
Spawn box is whatever spawn box script you would use
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Block after a certain number

Postby Mystery » Thu Feb 11, 2010 10:31 am

Easy, I'll show you how.

What you've described is a perfect If Statement

{}?{}:{}

And if Statement can be sumarized in english pretty well

{Scene.my.variable == 5}?{scene.my.example = 6}:{scene.my.example = 0}
If scene.my.variable is equal to 5 then make scene.my.example equal 6 otherwise scene.my.example = 0

So lets say the number you want to reach is 10
{scene.my. Variable == 5}

And what you want to happen is for a block to spawn.
?{Scene.addbox({size := [1,2]; pos := e.pos; color := [0,0,0,1]})}

Otherwise Do nothing :{}

All up you get
Code: Select all
{Scene.my.variable == 5}?{Scene.addbox({size := [1,2]; pos := e.pos; color := [0,0,0,1]})}:{}


I trust you understand creating and using variable.
User avatar
Mystery
 
Posts: 2802
Joined: Thu Sep 03, 2009 1:16 pm
Location: Southern Australia

Re: Block after a certain number

Postby Rideg » Thu Feb 11, 2010 9:50 pm

Code: Select all
(e)=>{
    sim.time >= 5 ? {         Scene.addbox({             size := [1, 2];             collideSet := 0;             pos := e.pos;             color := [0.3, 0.3, 0.3, 1]         })     } : {} }


this will spawn a box after the simulation have been activated for 5 seconds.
Hope this helped :)
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 0 guests