Data Realms Fan Forums http://45.55.195.193/ |
|
Attachables that Heal the Wearer http://45.55.195.193/viewtopic.php?f=1&t=31480 |
Page 1 of 3 |
Author: | CombatMedic02 [ Mon Jul 23, 2012 9:50 pm ] |
Post subject: | Attachables that Heal the Wearer |
Hi guys, Just got round to installing the latest version of the game and I have started working on bits and bobs again. I have made a backpack type device that I have attached to an actor as an attachable. I wanted this to heal the wearer. I know how to make lua regen a actors health when the script is added to the actor but I want to put the script on the attachable so that if the attachable breaks the effect stops. I'll stop rambling now and get to the point... basically I've never been too great with lua and would like to know how I would get the backpack to target the person wearing it. Also if the backpack broke the effect would stop right? I wouldn't need to stop the script or anything? This would basically give my actor a cool medi-backpack that would prevent him from bleeding out while it is functioning and on his back. I thought this would be pretty cool. If anyone could help me with this I'd be most grateful. Thanks in advance, CBM02 |
Author: | xenoargh [ Mon Jul 23, 2012 10:13 pm ] |
Post subject: | Re: Attachables that Heal the Wearer |
Quote: how I would get the backpack to target the person wearing it Quote: Also if the backpack broke the effect would stop right? |
Author: | Roast Veg [ Mon Jul 23, 2012 10:20 pm ] |
Post subject: | Re: Attachables that Heal the Wearer |
Code: function Create(self) if self.RootID ~= self.ID then self.wearer = MovableMan:GetMOFromID(self.RootID); end end function Update(self) if self.wearer then --Here, put your healing code, but replace the "self" of the actor with "self.wearer" end end Attach this code to the backpack attachable. |
Author: | xenoargh [ Mon Jul 23, 2012 10:22 pm ] |
Post subject: | Re: Attachables that Heal the Wearer |
Ah, much better, yeah; no MOID brute-force search. I'm a little slow today |
Author: | CombatMedic02 [ Tue Jul 24, 2012 1:25 pm ] |
Post subject: | Re: Attachables that Heal the Wearer |
Oh cool. I think I've screwed my healing code up now though because I got confused with the self.wearer bit. >_< Doesn't matter how many times I read up on this stuff I don't think I'll ever be that great at lua, always get so confused and that just frustrates me because I'd love to be able to just do this stuff. :/ |
Author: | Roast Veg [ Tue Jul 24, 2012 1:55 pm ] |
Post subject: | Re: Attachables that Heal the Wearer |
If you can, go right back to the original code and start again. Post it here if it continues to mess up. |
Author: | CombatMedic02 [ Tue Jul 24, 2012 3:43 pm ] |
Post subject: | Re: Attachables that Heal the Wearer |
Nope, still not working... just wanted something simple like the code in the other healing thread. Quote: Code: function onUpdate(self) if self.Health < 100 then self.Health = self.Health + 1; end end Is there something i'm missing in the .ini other than the normal scriptpath? Something I wouldn't have known about? Used to do all my healing through .ini haha. Feeling a bit lost with lua. :/ |
Author: | Roast Veg [ Tue Jul 24, 2012 4:05 pm ] |
Post subject: | Re: Attachables that Heal the Wearer |
Code: function Create(self) if self.RootID ~= self.ID then self.wearer = MovableMan:GetMOFromID(self.RootID); end end function Update(self) if self.wearer then if self.wearer.Health < 100 then self.wearer.Health = self.wearer.Health + 1; end end end There's your full script. |
Author: | CombatMedic02 [ Tue Jul 24, 2012 4:34 pm ] |
Post subject: | Re: Attachables that Heal the Wearer |
You can have self.wearer.Health? I thought that might have been where I was going wrong. >_< |
Author: | Roast Veg [ Tue Jul 24, 2012 4:37 pm ] |
Post subject: | Re: Attachables that Heal the Wearer |
Should work just fine. |
Author: | CombatMedic02 [ Tue Jul 24, 2012 4:51 pm ] |
Post subject: | Re: Attachables that Heal the Wearer |
Nope, still not healing... but I'm not getting any lua errors in the console, but I wasn't when I was trying to get my lua to work either so I'm not sure how helpful that is. >_< Weird... Code: //Backpack AddEffect = Attachable PresetName = AntiBleedBackPack Mass = 5 Sharpness = 1 HitsMOs = 0 GetsHitByMOs = 1 ScriptPath = Elite.rte/Actors/Elite Commander/healbp.lua SpriteFile = ContentFile FilePath = Elite.rte/Actors/Elite Commander/Backpack.bmp FrameCount = 4 SpriteAnimMode = 1 SpriteAnimDuration = 800 SpriteOffset = Vector X = -4 Y = -7 AngularVel = 6 EntryWound = AEmitter CopyOf = Dent Metal Light ExitWound = AEmitter CopyOf = Dent Metal Light AtomGroup = AtomGroup AutoGenerate = 1 Material = Material CopyOf = Military Stuff Resolution = 4 Depth = 0 DeepCheck = 0 JointStrength = 450 JointStiffness = 0.5 BreakWound = AEmitter CopyOf = Wound Bone Break JointOffset = Vector X = 0 Y = 0 DrawAfterParent = 1 GibImpulseLimit = 1500 GibWoundLimit = 8 [gibstuffhere] Thats okay right? o.O |
Author: | Roast Veg [ Tue Jul 24, 2012 5:05 pm ] |
Post subject: | Re: Attachables that Heal the Wearer |
Might need a ToActor, hang on: Code: function Create(self) if self.RootID ~= self.ID then self.wearer = ToActor(MovableMan:GetMOFromID(self.RootID)); end end function Update(self) if self.wearer then if self.wearer.Health < 100 then self.wearer.Health = self.wearer.Health + 1; end end end |
Author: | CombatMedic02 [ Tue Jul 24, 2012 7:32 pm ] |
Post subject: | Re: Attachables that Heal the Wearer |
Still nothing. How odd. o.o |
Author: | Coops [ Tue Jul 24, 2012 9:37 pm ] |
Post subject: | Re: Attachables that Heal the Wearer |
Replace this with your current create function and post what shows in the console. Code: function Create(self) if self.RootID ~= self.ID then self.wearer = ToActor(MovableMan:GetMOFromID(self.RootID)); end print(MovableMan:GetMOFromID(self.RootID).PresetName) print(MovableMan:GetMOFromID(self.ID).PresetName) end |
Author: | CombatMedic02 [ Wed Jul 25, 2012 12:41 am ] |
Post subject: | Re: Attachables that Heal the Wearer |
ERROR: Elite.rte/Actors/Elite Commander/healbp.lua:5: attempt to index a nil value |
Page 1 of 3 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |