Author |
Message |
CombatMedic02
Joined: Wed Dec 17, 2008 11:35 am Posts: 122 Location: London
|
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
|
Mon Jul 23, 2012 9:50 pm |
|
|
xenoargh
Joined: Fri Dec 30, 2011 3:33 am Posts: 276
|
Re: Attachables that Heal the Wearer
Quote: how I would get the backpack to target the person wearing it If that's the only person you want affected, then just give it a very short range. Quote: Also if the backpack broke the effect would stop right? If the Lua script is referenced by the backpack, not by the root of the AHuman (i.e., the big long part of the INI) it would stop if the backpack was destroyed. That's definitely the way to go about this, I think
|
Mon Jul 23, 2012 10:13 pm |
|
|
Roast Veg
Data Realms Elite
Joined: Tue May 25, 2010 8:27 pm Posts: 4521 Location: Constant motion
|
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.
|
Mon Jul 23, 2012 10:20 pm |
|
|
xenoargh
Joined: Fri Dec 30, 2011 3:33 am Posts: 276
|
Re: Attachables that Heal the Wearer
Ah, much better, yeah; no MOID brute-force search. I'm a little slow today
|
Mon Jul 23, 2012 10:22 pm |
|
|
CombatMedic02
Joined: Wed Dec 17, 2008 11:35 am Posts: 122 Location: London
|
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. :/
|
Tue Jul 24, 2012 1:25 pm |
|
|
Roast Veg
Data Realms Elite
Joined: Tue May 25, 2010 8:27 pm Posts: 4521 Location: Constant motion
|
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.
|
Tue Jul 24, 2012 1:55 pm |
|
|
CombatMedic02
Joined: Wed Dec 17, 2008 11:35 am Posts: 122 Location: London
|
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. :/
|
Tue Jul 24, 2012 3:43 pm |
|
|
Roast Veg
Data Realms Elite
Joined: Tue May 25, 2010 8:27 pm Posts: 4521 Location: Constant motion
|
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.
|
Tue Jul 24, 2012 4:05 pm |
|
|
CombatMedic02
Joined: Wed Dec 17, 2008 11:35 am Posts: 122 Location: London
|
Re: Attachables that Heal the Wearer
You can have self.wearer.Health? I thought that might have been where I was going wrong. >_<
|
Tue Jul 24, 2012 4:34 pm |
|
|
Roast Veg
Data Realms Elite
Joined: Tue May 25, 2010 8:27 pm Posts: 4521 Location: Constant motion
|
Re: Attachables that Heal the Wearer
Should work just fine.
|
Tue Jul 24, 2012 4:37 pm |
|
|
CombatMedic02
Joined: Wed Dec 17, 2008 11:35 am Posts: 122 Location: London
|
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
|
Tue Jul 24, 2012 4:51 pm |
|
|
Roast Veg
Data Realms Elite
Joined: Tue May 25, 2010 8:27 pm Posts: 4521 Location: Constant motion
|
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
|
Tue Jul 24, 2012 5:05 pm |
|
|
CombatMedic02
Joined: Wed Dec 17, 2008 11:35 am Posts: 122 Location: London
|
Re: Attachables that Heal the Wearer
Still nothing. How odd. o.o
|
Tue Jul 24, 2012 7:32 pm |
|
|
Coops
Joined: Wed Feb 17, 2010 12:07 am Posts: 1545 Location: That small peaceful place called Hell.
|
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
|
Tue Jul 24, 2012 9:37 pm |
|
|
CombatMedic02
Joined: Wed Dec 17, 2008 11:35 am Posts: 122 Location: London
|
Re: Attachables that Heal the Wearer
ERROR: Elite.rte/Actors/Elite Commander/healbp.lua:5: attempt to index a nil value
|
Wed Jul 25, 2012 12:41 am |
|
|
|