Data Realms Fan Forums http://45.55.195.193/ |
|
Object group statement? http://45.55.195.193/viewtopic.php?f=73&t=14814 |
Page 1 of 1 |
Author: | Areku [ Wed May 20, 2009 9:41 pm ] |
Post subject: | Object group statement? |
Ok, I want that all objects in a specific group are affected by a certain function, but I am in doubt about the exact syntax I should use. Should it be something like: for actor in MovableMan.Actors and actor in MovableMan.GroupName do I am rather confused, as I read the lua documentation and found very little reference to group functions. Any help would be appreciated. Thanks in advance. |
Author: | Thoughtprocess [ Wed May 20, 2009 10:49 pm ] |
Post subject: | Re: Object group statement? |
Not sure which GroupName you're referring to, but your syntax is a little off. Code: for actor in MovableMan.Actors do for whatever GroupName you have in mind, Code: for actor in MovableMan.GroupName do |
Author: | Areku [ Thu May 21, 2009 9:01 pm ] |
Post subject: | Re: Object group statement? |
I think I didn't express myself correctly. What I mean is that, in the .ini file, I give an actor an AddToGroup = XYZ variable. Then, in the .lua file, I want the game to iterate through all the objects in group = XYZ. The problem is that XYZ is not a predefined group in MovableMan, but a custom group. So, any ideas? |
Author: | TheLastBanana [ Thu May 21, 2009 11:51 pm ] |
Post subject: | Re: Object group statement? |
actor:IsInGroup("XYZ") returns true if it is in group XYZ. So, if everything in the group is actors, the code would go like so: Code: for actor in MovableMan.Actors do if actor:IsInGroup("XYZ") then <code> end end Or, if you wanted to cycle through every type of object (including particles and weapons): Code: for actor in MovableMan.Actors do if actor:IsInGroup("XYZ") then <code> end end for item in MovableMan.Items do if item:IsInGroup("XYZ") then <code> end end for particle in MovableMan.Particles do if particle:IsInGroup("XYZ") then <code> end end This is of course assuming the code changes according to object type. Otherwise, you'd just declare a function and call it where <code> would normally be. |
Author: | Areku [ Fri May 22, 2009 1:16 am ] |
Post subject: | Re: Object group statement? |
Yes! It works! Thanks! I've gotta tell you, it's fun using lua to stop missiles in mid-air and send them back to the poor soldier who shot them... |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |