Any better way of accessing/manipulating geometries? :/
4 posts • Page 1 of 1
Any better way of accessing/manipulating geometries? :/
I was planning on getting into Thyme. I've got some experiance with other scripting languages, so it wasn't that big of a leap to learn the syntax. I've gone through the tutorial and quickly browsed the 'Thyme command/variables list' and other relevant topics in the Thyme Scripting section. I was hoping someone could help me get started by answering a few questions...
If I understand this right, there are no proper way of manipulating existing geometries using thyme, but there are workarounds... right? I can shoot a laser on it or make it collide with something, then insert code into the object's "onCollide" or "onHitByLaser", then use .this or .other to be able to access and alter the object's properties.
I understand that thyme was never intended for end-users, but to me this seem like quite an odd way. Are there any better way of accessing/altering objects? Am I able to get some kind of ID from an object so I can refer to them directly in my code?
Sorry for the long post.
Thanks in advance!
[EDIT]
Oh, and are there any ways to access/manipulate objects that don't have the onCollide/onHitByLaser (fixes, hinges, springs, thrusters etc.)?
If I understand this right, there are no proper way of manipulating existing geometries using thyme, but there are workarounds... right? I can shoot a laser on it or make it collide with something, then insert code into the object's "onCollide" or "onHitByLaser", then use .this or .other to be able to access and alter the object's properties.
I understand that thyme was never intended for end-users, but to me this seem like quite an odd way. Are there any better way of accessing/altering objects? Am I able to get some kind of ID from an object so I can refer to them directly in my code?
Sorry for the long post.
Thanks in advance!
[EDIT]
Oh, and are there any ways to access/manipulate objects that don't have the onCollide/onHitByLaser (fixes, hinges, springs, thrusters etc.)?
-

Livirus - Posts: 19
- Joined: Fri Mar 26, 2010 7:08 pm
Re: Any better way of accessing/manipulating geometries? :/
For accessing geoms you can use geomByID(geomID).[property] I thought. To get the geomID you need to use an onCollide script with variable = readable(owner).geomID.
To change properties of non-colliding stuff you need to use scene.my. variables, putting them between {} in the property you want to change, and put a script that changes it in an onCollide or onLaserHit script. (or anything else that can change it)
To change properties of non-colliding stuff you need to use scene.my. variables, putting them between {} in the property you want to change, and put a script that changes it in an onCollide or onLaserHit script. (or anything else that can change it)
Cave Johnson wrote:Do you know who I am? I'm the man who's gonna burn your house down! With the lemons! I'm gonna get my engineers to invent a combustible lemon that burns your house down!
-

Matten - Posts: 435
- Joined: Mon Apr 05, 2010 2:03 pm
- Location: The Netherlands
Re: Any better way of accessing/manipulating geometries? :/
Thanks for the answer. Is the geomID constant or does it change over time? I mean, can I use the method you described to get the ID, then refer to that object at any time through console or other events?
EDIT:
I was gonna do some experimenting with geomByID, but it gave me some weird error. So I did some browsing and found two things:
1. You probably ment Scene.entityByGeomID() or possibly Scene.entityByID().
2. The command was released for the 2.0.1 BETA, and I only had the newest _official_ version that is 2.0.0.
What's the difference between geomID and entityID anyway? :/
Gonna download that version and do some experiments. Cheers!
EDIT2:
This code successfully creates a simple unicycle like it's supposed to, with the hinge connecting the two geometries. But then:
???
???
EDIT3:
Tried your method of obtaining ID. Typed scene.my.ID:=0 in console, then inserted following code into the onCollide script for the "wheel":
After Algodoo's autocorrection:
Ran simulation... the unicycle drops to the ground and the wheel collides... but scene.my.ID is still 0.
Tried varying syntaxes:
Ran simulation. scene.my.ID still = 0
:<
EDIT:
I was gonna do some experimenting with geomByID, but it gave me some weird error. So I did some browsing and found two things:
1. You probably ment Scene.entityByGeomID() or possibly Scene.entityByID().
2. The command was released for the 2.0.1 BETA, and I only had the newest _official_ version that is 2.0.0.
What's the difference between geomID and entityID anyway? :/
Gonna download that version and do some experiments. Cheers!
EDIT2:
- Code: Select all
Scene.addBox {
color := [0.2, 0.5, 0.9, 1.0000000];
density := 2.0000000;
entityID := 1;
geomID := 1;
pos := [0.0, 0.0];
size := [0.2, 2.0]
};
Scene.addCircle {
color := [0.67157185, 0.79965299, 0.62418324, 1.0000000];
entityID := 2;
geomID := 2;
pos := [0,-0.9];
radius := 0.3
};
Scene.addHinge {
geom0 := 1;
world0pos := [0,-0.9];
geom1 := 2;
geom1pos := [0,0];
entityID := 3;
size := 0.2;
};
This code successfully creates a simple unicycle like it's supposed to, with the hinge connecting the two geometries. But then:
- Code: Select all
> scene.entityByID(1)
- WARNING - Failed to find entity with id: 1
> scene.entityByID(2)
- WARNING - Failed to find entity with id: 2
> scene.entityByID(3)
- WARNING - Failed to find entity with id: 3
> scene.entityByGeomID(1)
- WARNING - Failed to find entity with geom id: 1
> scene.entityByGeomID(2)
- WARNING - Failed to find entity with geom id: 2
???
EDIT3:
Tried your method of obtaining ID. Typed scene.my.ID:=0 in console, then inserted following code into the onCollide script for the "wheel":
- Code: Select all
(e)=>{scene.my.ID = readable(owner).geomID}
After Algodoo's autocorrection:
- Code: Select all
(e)=>{scene.my.ID = readable((owner).geomID)}
Ran simulation... the unicycle drops to the ground and the wheel collides... but scene.my.ID is still 0.
Tried varying syntaxes:
- Code: Select all
(e)=>{scene.my.ID = readable((owner).entityID)};
(e)=>{scene.my.ID = readable((owner).ID)};
(e)=>{scene.my.ID = readable(owner.geomID)};
(e)=>{scene.my.ID = readable(owner.entityID)};
(e)=>{scene.my.ID = readable(owner.ID)};
(e)=>{scene.my.ID = readable(e.this.geomID)};
(e)=>{scene.my.ID = readable(e.this.entityID)};
(e)=>{scene.my.ID = readable(e.this.ID)}
Ran simulation. scene.my.ID still = 0
:<
-

Livirus - Posts: 19
- Joined: Fri Mar 26, 2010 7:08 pm
Re: Any better way of accessing/manipulating geometries? :/
Lol, I just realized I could just:
onCollide=
Then scene.my.wheel.[whatever]
Are there any setbacks with this method?
onCollide=
- Code: Select all
(e)=>{scene.my.wheel=e.this}
Then scene.my.wheel.[whatever]
Are there any setbacks with this method?
-

Livirus - Posts: 19
- Joined: Fri Mar 26, 2010 7:08 pm
4 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 5 guests



