Check object existence

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

Check object existence

Postby 0xB10C1DE » Sun Mar 02, 2014 9:51 am

I tried to check some object existence by Scene.entityByGeomID(x)
But if x pointing object were non-existence, console said

Failed to find entity with geom id: #x

I tried this script




Code: Select all
Scene.entityByGeomID(x) == undefined ? {} : {} 


x is a random number

but a conditional sentence don't work from the beginning


Is there checking object existence method in algodoo script ?

sorry, I borrow google translate power
0xB10C1DE
 
Posts: 2
Joined: Wed Feb 26, 2014 4:26 am

Re: Check object existence

Postby Kilinich » Sun Mar 02, 2014 8:13 pm

I've try something like that, usin xFor() to find all entityes by ID. It works but very long (about 30 sec)

Code: Select all
scene.my.xFor = (n1, n2, code) =>
{n2 > n1 ? {m := (n1 + n2) / 2; scene.my.xFor(n1, m, code); scene.my.xFor(m + 1, n2, code)} : {code(n1)}};
scene.my.all = [];
scene.my.xfor(0,65535,(id)=>{scene.my.all = scene.my.all ++ [(Scene.entityByid(id)).entityID]});
scene.my.all
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: Check object existence

Postby 0xB10C1DE » Mon Mar 03, 2014 11:17 am

thank you I'll try it in this weekend i'm in school now
0xB10C1DE
 
Posts: 2
Joined: Wed Feb 26, 2014 4:26 am

Re: Check object existence

Postby s_noonan » Sun Jul 14, 2019 4:27 pm

Code: Select all
_entityExists := (eID)=>{
   rtn := false;
   (entityByID(eID)).entityID > 0 ? {
      rtn = true
   } : {
      rtn = false
   };
   rtn
};
s_noonan
 
Posts: 61
Joined: Tue Mar 30, 2010 2:25 am


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 4 guests

cron