Get array of selected entities
5 posts • Page 1 of 1
Get array of selected entities
Hi all!
I am new to Algodoo and and the community. I find the program fascinating. I have a lot of experience in game programming. But I am new to Thyme, and its language. I have found the tutorials and references pinned to this forum. But I have some questions.
Here is my first question: How can I acquire an array of entities via selection?
Thanks!
I am new to Algodoo and and the community. I find the program fascinating. I have a lot of experience in game programming. But I am new to Thyme, and its language. I have found the tutorials and references pinned to this forum. But I have some questions.
Here is my first question: How can I acquire an array of entities via selection?
Thanks!
- nomcycle
- Posts: 3
- Joined: Sat Aug 08, 2015 8:08 am
Re: Get array of selected entities
You mean the code data of some entities in the scene to use them as scene.add[something] ?
Select all the shapes you need the data of, press copy, and then insert it into some text editor. Delete the beginning with fileInfo and phunlet, so that the first thing is a scene.addsomething command. Then you can seperate each add command and edit their attributes if you want. I recommend removing the Body attribute before adding the code again, as you end up with glued shapes otherwise
Select all the shapes you need the data of, press copy, and then insert it into some text editor. Delete the beginning with fileInfo and phunlet, so that the first thing is a scene.addsomething command. Then you can seperate each add command and edit their attributes if you want. I recommend removing the Body attribute before adding the code again, as you end up with glued shapes otherwise
- FRA32
- Posts: 229
- Joined: Wed Dec 03, 2014 9:51 pm
Re: Get array of selected entities
Ok thanks, that's pretty cool. Although I am trying something a little different.
Lets say I want to write a script that modifies the parameters of existing entities in the scene. Specifically the entities that I have selected in the scene. Is there a way to access an array of spawned entities or an array of selected entities?
I know you can store an entity into a variable by calling "Scene.entityByID". But I want to store an entity into a variable without having to find it's ID.
Lets say I want to write a script that modifies the parameters of existing entities in the scene. Specifically the entities that I have selected in the scene. Is there a way to access an array of spawned entities or an array of selected entities?
I know you can store an entity into a variable by calling "Scene.entityByID". But I want to store an entity into a variable without having to find it's ID.
- nomcycle
- Posts: 3
- Joined: Sat Aug 08, 2015 8:08 am
Re: Get array of selected entities
If you want to get all the entityID's from a selection all you have to do is select them go to script menu and paste "scene.my.stuff = scene.my.stuff ++ [entityid]" into the menu. This will create the variable scene.my.stuff as a list with all the id's.
ID's are in random order
If you want the list to be there every time the scene starts then select all the entities you want and put "scene.my.stuff = scene.my.stuff ++ [entityid]" into the "onspawn" in their script menu.
This list will be organized from oldest object to newest. (ID's are in ascending order)
Any other questions just ask.
ID's are in random order
If you want the list to be there every time the scene starts then select all the entities you want and put "scene.my.stuff = scene.my.stuff ++ [entityid]" into the "onspawn" in their script menu.
This list will be organized from oldest object to newest. (ID's are in ascending order)
Any other questions just ask.
-

homieeee - Posts: 14
- Joined: Thu Oct 09, 2014 2:13 am
Re: Get array of selected entities
That worked pretty well, thanks.
- nomcycle
- Posts: 3
- Joined: Sat Aug 08, 2015 8:08 am
5 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 3 guests



