Data Realms Fan Forums http://45.55.195.193/ |
|
Check type of Actor http://45.55.195.193/viewtopic.php?f=73&t=16048 |
Page 1 of 1 |
Author: | MooCow13 [ Wed Jul 29, 2009 1:07 am ] |
Post subject: | Check type of Actor |
How can i check if a actor is a ADoor or ACDropShip This is part of some code to cheack for actors that are not dropships or doors. Code wrote: for actor in MovableMan.Actors do if actor:IsActor("ADoor") == false and actor:IsActor("ACDropShip") == false then self.active = true; end end Unfortunately this code doent doesnt work at all. Can someone please help. P.S. If you want to copy this code you have to remove Character#255, they were added just for affect. |
Author: | TheLastBanana [ Wed Jul 29, 2009 1:15 am ] |
Post subject: | Re: Check type of Actor |
Always check the LuaDocs before you try this kind of thing. Now onto the problem. MovableObject:IsActor takes no arguments. It just tells you whether it is an actor or not. What you want to check is the MovableObject's ClassName. That's what it is defined as in the INI file (e.g. ACDropShip, ACRocket, AHuman). So, a working version of the code would look like this: Code: for actor in MovableMan.Actors do if actor.ClassName ~= "ADoor" and actor.ClassName ~= "ACDropShip" then self.active = true; end end Also, in case you're wondering, "~=" is an operator that checks for inequality, or, in plain English, checks if something is not equal. It's the opposite of "==". |
Author: | MooCow13 [ Wed Jul 29, 2009 1:36 am ] |
Post subject: | Re: Check type of Actor |
Thank you, you really are a Lua djinn. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |