scene.entityByGeomID and other mysteries.

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

scene.entityByGeomID and other mysteries.

Postby Xray » Sun Oct 13, 2013 5:57 am

I have a pretty good handle on Thyme scripting, and I understand many of its functions and concepts, and the proof of that is the fact that some of my scenes were written with fairly complex code. But there are a few functions that are still a mystery to me, and there really isn't very much at all in the forum that I could find that I would call comprehensive tutorials. There are a few bits and pieces in various threads that attempt to explain these concepts, but the explanations are mostly examples without detailed descriptions of the HOWS and WHYS of each function. For example:

Here is a line of code from a particular tutorial.....
_circleCollide = {(scene.entityByGeomID((readable(owner)).geom0))._wasCollision}

I think I have a little understanding of scene.entityByGeomID, but it is VERY little. All I know about it is you can get a property value from a geometry if you know the geometry's geomID. But that's where the confusion begins! In the example script above, there is no geomID NUMBER. There is only (readable(owner)). So, could someone please explain in detail the following questions:

1. What is scene.entityByGeomID used for? Why is it necessary, and when should it be used? (give a few examples). Also, explain the various syntax examples. I have seen it used in many different scripts in many different ways. How can it be used without providing the geometry's geomID number (as shown above in the example script)?

2. What is readable(owner) used for? Why is it necessary, and when should it be used? (give a few examples). Also, explain the various syntax examples. I have seen it used in many different scripts in many different ways. Can readable or owner be used by themselves? If so, give examples. Explain what "readable" is, and what "owner" is.

3. Define geom0 and geom1. I believe it defines two geometries that are connected with a hinge, but is there a formal explanation that defines which geometry is geom0 and which is geom1? Please give examples of how to use them in a script.

4. How can these functions be used to get properties of a tracer, or a thruster, or a hinge that is attached to a geometry? Can they be used in the tracer (for example) to GIVE its property values to the geometry that it is attached to, or can they be used in a geometry to GET the property values of a tracer that is attached to the geometry? (In other words, is it a two-way street?)

Please be detailed, and provide an example scene that uses all the functions that are described here. Many "tutorials" simply say "do this, then do this, then do this" but they do not say WHY, HOW, or WHEN, etc.

I apologize for being verbose, but that's just me. :lol:

Thanks
User avatar
Xray
 
Posts: 501
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

Re: scene.entityByGeomID and other mysteries.

Postby s_noonan » Sun Oct 13, 2013 9:26 pm

Q: What is scene.entityByGeomID used for?
A: It's used to get an entity object when you supply the geometry ID.

Q: Why is it necessary?
A: Because sometimes that's the best way to get the entity.

Q: When should it be used?
A: When it's the best way to get the entity.

Q: How can it be used without providing the geometry's geomID number?
A: It can't. It needs the geometry's geomID number either directly or indirectly. ((readable(owner)).geom0) returns a geomID number.

Q: What is readable(owner) used for?
A: It's used for variable that can't be accessed otherwise (usually the ones at the very bottom of the script property page).

Q: When should it be used?
A: When the variable that can't be accessed otherwise.

Q: Can readable or owner be used by themselves?
A: I don't know.

Q: Define geom0 and geom1
A: The two geometry geomIDs that are connected with a hinge.

Q: Is there a formal explanation that defines which geometry is geom0 and which is geom1?
A: I don't know, but it may be that geom0 is in front of geom1.

Q: How can these functions be used to get properties of a tracer, or a thruster, or a hinge that is attached to a geometry?
A: The tracer, or a thruster, or a hinge can use the functions to write to custom properties of the attached geometry.

Q: Can they be used in the tracer (for example) to GIVE its property values to the geometry that it is attached to?
A: Yes

Q: Can they be used in a geometry to GET the property values of a tracer that is attached to the geometry?
A: Not that I know of.

Q: Is it a two-way street?
A: No.
s_noonan
 
Posts: 61
Joined: Tue Mar 30, 2010 2:25 am

Re: scene.entityByGeomID and other mysteries.

Postby Xray » Sun Oct 13, 2013 9:35 pm

AWESOME! This is very helpful. Now the only other thing I'm asking for is a few examples of the actual syntax. Maybe a sample scene that shows various ways these functions can be used. I realize there are many scenes on Algobox that use these funcions, but all too often the syntax is mixed in the code along with other functions and variables which make it difficult to reverse-engineer.

THANKS very much! :thumbup:
User avatar
Xray
 
Posts: 501
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

Re: scene.entityByGeomID and other mysteries.

Postby s_noonan » Mon Oct 14, 2013 1:18 am

See Heat Transfer Models. Make the hinges visible. Each hinge reads from and writes to the attached geometry.
s_noonan
 
Posts: 61
Joined: Tue Mar 30, 2010 2:25 am

Re: scene.entityByGeomID and other mysteries.

Postby Xray » Mon Oct 14, 2013 3:07 am

That's exactly what I was looking for. :D Thanks again!

BTW - Concerning geom0 and geom1, it appears that the geometry the hinge is attached to which rotates in the direction that the directional indicators on the hinge is pointing, is geom0. The other geometry is geom1. Maybe someone else will want to confirm this just to make certain that my finding is correct.


EDIT: s_noonan created this scene for me which is VERY helpful. It addresses most of the concerns and questions that I have about tracers and geometries communicating with each other. Clear Tracer Response
User avatar
Xray
 
Posts: 501
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

Re: scene.entityByGeomID and other mysteries.

Postby racergonemad » Tue Jan 07, 2014 4:47 am

Please refer to my other response where I go through some of this stuff in detail :D
http://www.algodoo.com/forum/viewtopic.php?f=41&t=9564&p=69295&hilit=entityByGeomID#p69295
My signature is worth a lot of money, So I'm gonna put this stamp instead:
[$20 PER AUTOGRAPH]
racergonemad
 
Posts: 26
Joined: Tue Aug 17, 2010 7:37 am


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 5 guests