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
numgun
Joined: Sat Jan 13, 2007 11:04 pm Posts: 2932
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
Foogooman
Joined: Sat Nov 18, 2006 8:11 pm Posts: 267
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
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