View unanswered posts | View active topics It is currently Thu Dec 26, 2024 4:37 am



Reply to topic  [ 2 posts ] 
 Basic Lua Question (total newb question) 
Author Message
User avatar

Joined: Thu Jan 18, 2007 5:16 am
Posts: 397
Location: Back at DRL for a while?
Reply with quote
Post Basic Lua Question (total newb question)
Code:
function Create(self)
    local curdist = 100;
    self.parent = nil;

    for actor in MovableMan.Actors do
   local avgx = actor.Pos.X - self.Pos.X;
   local avgy = actor.Pos.Y - self.Pos.Y;
   local dist = math.sqrt(avgx ^ 2 + avgy ^ 2);
   if dist < curdist then
       curdist = dist;
       self.parent = actor;
   end
    end
end

(taken from the Dear Sister weapon)
Does this mean:
"When the Create function is called, take the following actions:" ?


Sun May 24, 2009 6:29 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Basic Lua Question (total newb question)
It means:

when the object is created (since I am fairly sure the DS runs a script on the round fired)

run the following script, which in this case determines the closest actor and calls it the parent.


Sun May 24, 2009 6:41 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 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.071s | 13 Queries | GZIP : Off ]