Data Realms Fan Forums http://45.55.195.193/ |
|
How do you run two scripts on something? http://45.55.195.193/viewtopic.php?f=73&t=15476 |
Page 1 of 1 |
Author: | Foogooman [ Sun Jun 21, 2009 10:04 pm ] |
Post subject: | 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? |
Author: | numgun [ Sun Jun 21, 2009 10:12 pm ] |
Post subject: | 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 |
Author: | Foogooman [ Sun Jun 21, 2009 10:16 pm ] |
Post subject: | 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 |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |