View unanswered posts | View active topics It is currently Thu Dec 26, 2024 6:09 pm



Reply to topic  [ 34 posts ]  Go to page 1, 2, 3  Next
 Attachables that Heal the Wearer 
Author Message
User avatar

Joined: Wed Dec 17, 2008 11:35 am
Posts: 122
Location: London
Reply with quote
Post 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. :D

Thanks in advance,

CBM02


Mon Jul 23, 2012 9:50 pm
Profile WWW

Joined: Fri Dec 30, 2011 3:33 am
Posts: 276
Reply with quote
Post 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
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Tue May 25, 2010 8:27 pm
Posts: 4521
Location: Constant motion
Reply with quote
Post 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
Profile

Joined: Fri Dec 30, 2011 3:33 am
Posts: 276
Reply with quote
Post Re: Attachables that Heal the Wearer
Ah, much better, yeah; no MOID brute-force search. I'm a little slow today :roll:


Mon Jul 23, 2012 10:22 pm
Profile
User avatar

Joined: Wed Dec 17, 2008 11:35 am
Posts: 122
Location: London
Reply with quote
Post 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
Profile WWW
Data Realms Elite
Data Realms Elite
User avatar

Joined: Tue May 25, 2010 8:27 pm
Posts: 4521
Location: Constant motion
Reply with quote
Post 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
Profile
User avatar

Joined: Wed Dec 17, 2008 11:35 am
Posts: 122
Location: London
Reply with quote
Post 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
Profile WWW
Data Realms Elite
Data Realms Elite
User avatar

Joined: Tue May 25, 2010 8:27 pm
Posts: 4521
Location: Constant motion
Reply with quote
Post 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
Profile
User avatar

Joined: Wed Dec 17, 2008 11:35 am
Posts: 122
Location: London
Reply with quote
Post 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
Profile WWW
Data Realms Elite
Data Realms Elite
User avatar

Joined: Tue May 25, 2010 8:27 pm
Posts: 4521
Location: Constant motion
Reply with quote
Post Re: Attachables that Heal the Wearer
Should work just fine.


Tue Jul 24, 2012 4:37 pm
Profile
User avatar

Joined: Wed Dec 17, 2008 11:35 am
Posts: 122
Location: London
Reply with quote
Post 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
Profile WWW
Data Realms Elite
Data Realms Elite
User avatar

Joined: Tue May 25, 2010 8:27 pm
Posts: 4521
Location: Constant motion
Reply with quote
Post 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
Profile
User avatar

Joined: Wed Dec 17, 2008 11:35 am
Posts: 122
Location: London
Reply with quote
Post Re: Attachables that Heal the Wearer
Still nothing. How odd. o.o


Tue Jul 24, 2012 7:32 pm
Profile WWW
User avatar

Joined: Wed Feb 17, 2010 12:07 am
Posts: 1545
Location: That small peaceful place called Hell.
Reply with quote
Post 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
Profile
User avatar

Joined: Wed Dec 17, 2008 11:35 am
Posts: 122
Location: London
Reply with quote
Post 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
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 34 posts ]  Go to page 1, 2, 3  Next

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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.065s | 13 Queries | GZIP : Off ]