View unanswered posts | View active topics It is currently Thu Apr 25, 2024 8:28 am



Reply to topic  [ 3 posts ] 
 How do you run two scripts on something? 
Author Message
User avatar

Joined: Sat Nov 18, 2006 8:11 pm
Posts: 266
Reply with quote
Post How do you run two scripts on something?
This mod I am working on relies on a script for remote detonation, and one for sticking stuff to actors and terrain. However, only the script loaded last works. If I put both scripts in one file, only the one on the bottom works.

How could I have both scripts work?


Sun Jun 21, 2009 10:04 pm
Profile WWW

Joined: Sat Jan 13, 2007 11:04 pm
Posts: 2932
Reply with quote
Post Re: How do you run two scripts on something?
Make the single script do both.
Just make sure you start and end the blocks of code right.

Somehow like this:

Code:
Function.Update(self)

if blah blah then
 -function n.1
end

if wootlol then
 -function n.2
end

end


Sun Jun 21, 2009 10:12 pm
Profile
User avatar

Joined: Sat Nov 18, 2006 8:11 pm
Posts: 266
Reply with quote
Post Re: How do you run two scripts on something?
numgun wrote:
Make the single script do both.
Just make sure you start and end the blocks of code right.

Somehow like this:

Code:
Function.Update(self)

if blah blah then
 -function n.1
end

if wootlol then
 -function n.2
end

end


Like this? :???:

Code:
function Create(self)
    print("C4 Spray planted!");
    --Make sure the C-4 Spray list exists.
    if c4ListS == nil then
   --If not, create it.
   c4ListS = { };
    end
    --Add this C-4 to the list.
    c4ListS[#c4ListS + 1] = self;

   self.hooked = false
    local curdist = 50;
   self.parent = self;
    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
self.stickyfactor = 2 -- Change this to chagne stickyness
end

function Update(self)
   if not(self.hooked) then
   self.stickyMOID = SceneMan:CastMORay(self.Pos,Vector(self.Vel.X * self.stickyfactor, self.Vel.Y *

self.stickyfactor),self.ID,0,false,0)
   if self.stickyMOID ~= 255 and self.stickyMOID ~= nil and MovableMan:GetMOFromID(self.stickyMOID).RootID ~= self.parent.RootID

then
      self.hooked = true
      self.stickyMO = MovableMan:GetMOFromID(self.stickyMOID)
      if self.probetarg then
      self.stickyMO = MovableMan:GetMOFromID(MovableMan:GetMOFromID(self.stickyMOID).RootID)
      end
      --self.GetsHitByMOs = false
      self.hookpos = self.stickyMO.Pos
   end
   else
   self.Pos = self.hookpos
   if self.stickyMO ~= nil and MovableMan:ValidMO(self.stickyMO) then
   self.hookpos = self.stickyMO.Pos
   self.Vel = self.stickyMO.Vel
   else
   self.hooked = false
   end
end
end


Sun Jun 21, 2009 10:16 pm
Profile WWW
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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.345s | 15 Queries | GZIP : Off ]