Click a Box to Kill other boxes

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

Click a Box to Kill other boxes

Postby AN9K » Tue Feb 28, 2017 9:08 am

I tried with these codes, but it couldn't work well. How can I do with that?

The code on the box to click
Code: Select all
OnClick=(e)=>{
    scene.my.MoveRocket = true
}


The code on the box to be killed
Code: Select all
PostStep=(e)=>{
    timeToLive=(scene.my.MoveRocket)=0.1:+inf
}
AN9K
 
Posts: 5
Joined: Tue Jun 30, 2015 12:14 am

Re: Click a Box to Kill other boxes

Postby Kilinich » Tue Feb 28, 2017 2:52 pm

will not work even with correct syntax:

Code: Select all
PostStep=(e)=>{
    timeToLive = scene.my.MoveRocket ? 0.1 : +inf
}


it will assign TTL = 0.1 every tick and live forever ;)

so what you want to archive ?
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: Click a Box to Kill other boxes

Postby The Linkage » Tue Feb 28, 2017 6:56 pm

timeToLive = scene.my.moveRocket? 0 : +inf

Orherwise use density instead of timeToLive, and a value like 2 or more where the +inf is at
The Linkage
 
Posts: 57
Joined: Fri Aug 05, 2011 5:40 pm
Location: Escobar, Argentina

Re: Click a Box to Kill other boxes

Postby Xray » Wed Mar 01, 2017 5:53 am

This is how I would do it......

scene.my.moveRocket ? {TimeToLive = 0}:{TimeToLive = +inf }

Program flow makes more sense this way.
User avatar
Xray
 
Posts: 500
Joined: Sun Jun 17, 2012 6:12 am
Location: USA


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 9 guests