View unanswered posts | View active topics It is currently Fri Dec 27, 2024 8:10 am



Reply to topic  [ 3 posts ] 
 Check type of Actor 
Author Message
User avatar

Joined: Wed Aug 27, 2008 6:44 am
Posts: 20
Reply with quote
Post 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.


Wed Jul 29, 2009 1:07 am
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post 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 "==".


Wed Jul 29, 2009 1:15 am
Profile WWW
User avatar

Joined: Wed Aug 27, 2008 6:44 am
Posts: 20
Reply with quote
Post Re: Check type of Actor
Thank you, you really are a Lua djinn.


Wed Jul 29, 2009 1:36 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.076s | 13 Queries | GZIP : Off ]