Explain "scene.addGroup"

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

Explain "scene.addGroup"

Postby Xray » Mon Apr 14, 2014 9:50 pm

I have only a vague understanding of scene.addGroup, and I hope that someone could shine some light on it. I know that the arguments are entityIDs, name, and particlesIDs. Some examples of "name" are: "selected" and "tracked" (I think). But that's about all I know about it. So, could someone please explain how "scene.addGroup" is used, and give a few examples of it? Also, please list all the possible "names" that are associated with it (besides that two that I listed above). I searched the forum for more information, but there are only a few very sketchy entries about it.

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

Re: Explain "scene.addGroup"

Postby Kilinich » Mon Apr 14, 2014 11:30 pm

scene.addGroup is just for grouping objects for selecting/moving together.
Inside there is name, entityIDs and/or particleIDs (for water).
There is also special group names: selected, tracked, gravityGroup

That's all. I use it for deslecting or change tracking object.
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: Explain "scene.addGroup"

Postby Xray » Mon Apr 14, 2014 11:53 pm

Please explain what gravityGroup is.

Also, could you give some actual examples of how scene.addGroup is used? You said basically what it does, but in order for me to actually use it, I need some example scripts. Or even better, if you can take the time, make some simple scenes of it being used with each of its arguments, that would be very helpful. Thanks!
User avatar
Xray
 
Posts: 501
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

Re: Explain "scene.addGroup"

Postby Xray » Tue Apr 15, 2014 3:49 am

More info....

I wrote this in two separate geometries:

onHitByLaser = (e)+> { scene.addGroup({
name = "selected";
entityIDs = entity
})}

I then hit those two geometries with a laser, and nothing happened. They did not become "selected", therefore, I must not be using the correct syntax. That's what I need is to be taught the proper syntax for how to use scene.addGroup.

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

Re: Explain "scene.addGroup"

Postby Kilinich » Tue Apr 15, 2014 8:32 am

Correct script example for laser:

Code: Select all
(e)=>{
    scene.addGroup({
        name = "selected";
        entityIDs = [e.geom.entityID]
    })
}
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: Explain "scene.addGroup"

Postby Xray » Tue Apr 15, 2014 8:46 am

Kilinich wrote:Correct script example for laser:

Code: Select all
(e)=>{
    scene.addGroup({
        name = "selected";
        entityIDs = [e.geom.entityID]
    })
}


Okay, and what about for onCollide? I tried

scene.addGroup({
name = "selected";
entityIDs = [e.this.entidyID,e.other.entityID]
})
and it did not work.
User avatar
Xray
 
Posts: 501
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

Re: Explain "scene.addGroup"

Postby Kilinich » Tue Apr 15, 2014 3:58 pm

just an error in code
entityIDs = [e.this.entidyID,e.other.entityID]
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: Explain "scene.addGroup"

Postby Xray » Wed Apr 16, 2014 2:19 am

OOPS! :oops:

Okay, now the script works. I can group two geometries together. But how can it be used to GLUE two geometries together? For example, a circle collides into another circle, and they get glued together. How can that be done?

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

Re: Explain "scene.addGroup"

Postby Kilinich » Wed Apr 16, 2014 10:13 am

Xray wrote:OOPS! :oops:

Okay, now the script works. I can group two geometries together. But how can it be used to GLUE two geometries together? For example, a circle collides into another circle, and they get glued together. How can that be done?

Thanks

respawn one of it with body ID of another
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: Explain "scene.addGroup"

Postby Kilinich » Wed Apr 16, 2014 11:25 am

There is a chance it will not work in 2.1 because of known bug - you could not conect objects (hinges, fixates) to existing one.
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: Explain "scene.addGroup"

Postby Xray » Wed Apr 16, 2014 5:39 pm

How did you do it in your Robin Ballistic Computer ? The arrow appears to become glued to the target!
User avatar
Xray
 
Posts: 501
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

Re: Explain "scene.addGroup"

Postby Kilinich » Wed Apr 16, 2014 10:53 pm

Xray wrote:How did you do it in your Robin Ballistic Computer ? The arrow appears to become glued to the target!

What?! It works!!! :wtf: :crazy:
Thats really strange because it was created in Phun and store geomID in controllerAcc (I did it in code, kinda hack). Now it shouldn't work because geomIDs is incorrect, but it works! I should dig it a little bit more.... :ugeek:
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: Explain "scene.addGroup"

Postby Xray » Thu Apr 17, 2014 4:08 am

Yes, it works, and it's one of my favorite scenes!
User avatar
Xray
 
Posts: 501
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 2 guests