Differentiate geometries?

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

Differentiate geometries?

Postby icrls984 » Mon Aug 15, 2016 3:58 am

Hello there,

Sorry for asking, but how do you make a script to differentiate a box, circle, and polygon? I've been trying to do this based on the geometries' properties, such as size, radius, but since it throws up undefined my ideas are constantly being thrown out the window. I'm sure there is a painfully simple way to do this, but I couldn't find anything in a search.

Thanks!
.
User avatar
icrls984
 
Posts: 80
Joined: Thu Jun 13, 2013 6:33 am

Re: Differentiate geometries?

Postby carl00s01 » Thu Aug 18, 2016 11:51 pm

Rating: rated 5
Filesize: 24.05 kB
Comments: 0
Ratings: 1
download
User avatar
carl00s01
 
Posts: 24
Joined: Fri Nov 26, 2010 7:03 pm
Location: Brazil

Re: Differentiate geometries?

Postby Kilinich » Fri Aug 19, 2016 10:24 am

{""+object} gives you object name: "polygon", "circle", "box" etc.
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: Differentiate geometries?

Postby Xray » Wed Aug 24, 2016 5:12 am

kilinich - I tried {""+object} and it shows "undefined".

BTW - Who is that person in your new profile picture?
User avatar
Xray
 
Posts: 500
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

Re: Differentiate geometries?

Postby carl00s01 » Wed Aug 24, 2016 8:30 pm

Xray wrote:kilinich - I tried {""+object} and it shows "undefined".

BTW - Who is that person in your new profile picture?


I think he meant e.other or e.this as object
User avatar
carl00s01
 
Posts: 24
Joined: Fri Nov 26, 2010 7:03 pm
Location: Brazil

Re: Differentiate geometries?

Postby Kilinich » Wed Aug 24, 2016 9:45 pm

Xray wrote:kilinich - I tried {""+object} and it shows "undefined".
BTW - Who is that person in your new profile picture?


object means it's some variable like e.this, e.other or result of scene.entityByGeomID()
BTW - It's me )
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: Differentiate geometries?

Postby Xray » Wed Aug 24, 2016 10:17 pm

You look a little bit like I did 20 years ago. I also have a beard. :thumbup:
User avatar
Xray
 
Posts: 500
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

Re: Differentiate geometries?

Postby pnvv » Fri Sep 02, 2016 4:09 am

Kilinich wrote:object means it's some variable like e.this, e.other or result of scene.entityByGeomID()
BTW - It's me )


So, the correct usage would be something along the lines of "e.this.object" or "e.other.object" or something similar?

I ask because I've been trying to find a way to do this for some time.

Also nice whiskers.
Image

(/)(°,,,°)(/)
User avatar
pnvv
 
Posts: 670
Joined: Tue Aug 26, 2014 11:46 pm
Location: Disunited States of America

Re: Differentiate geometries?

Postby Kilinich » Fri Sep 02, 2016 10:36 am

pnvv wrote:
Kilinich wrote:object means it's some variable like e.this, e.other or result of scene.entityByGeomID()
BTW - It's me )

So, the correct usage would be something along the lines of "e.this.object" or "e.other.object" or something similar?
I ask because I've been trying to find a way to do this for some time.


Examples:

for box:
onCollide = (e) => {text = "" + e.other}

for laser:
onLaserHit = (e) => {"" + e.geom == "circle" ? {e.geom.color = color}:{}}
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 8 guests

cron