View unanswered posts | View active topics It is currently Thu Jan 09, 2025 10:13 pm



Reply to topic  [ 13 posts ] 
 Attaching using Lua 
Author Message
User avatar

Joined: Sun May 31, 2009 1:04 am
Posts: 308
Reply with quote
Post Attaching using Lua
I was thinking of a way to attach a layer of armor to an actor. I heard that you could not do attach things using Lua, however I also knew that the Docs didn't cover every function. The Attachables class has a Detach() function, so I thought "why not an Attach()?"

So typed in Attachable.Attach(); into the console:
Image
There is an Attachable:Attach(); function! :D

So I tried it out by trying to attach a Soldier's helmet to a Dummy's head:
Image
Not pretty, and it's hard to see (behind his head, there's like 2 of them), but it did attach. However, it still rotates around. Also, I haven't found a way of applying offsets. However, I think this function might be worth looking into.

Here's the code that I used to do it:
Code:
function Update(self)
    if self:GetController():IsState(Controller.BODY_CROUCH) then
        --Finds the dummy's head.
        for i = 1, MovableMan:GetMOIDCount()-1, 1 do
             local a = MovableMan:GetMOFromID(i);
             if a.PresetName == "Dummy Head A" then
                if a.RootID == self.ID then
                    self.head = ToAttachable(a);
                end
            end
        end
        print(self.head);
        local helm = CreateAttachable("Soldier Helmet A");
        helm.Pos = self.Pos + Vector(20,10);  --Place it in front of the dummy for a second

        --This didn't seem to have any effect.
        helm.ParentOffset = Vector(-50,-50);
        MovableMan:AddMO(helm);
       
      --Attaches a helmet.
        helm:Attach(self.head);
    end
end


Fri Aug 07, 2009 4:01 am
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Attaching using Lua
GAH YOU FOUND A HACK BEFORE I DID.

That aside. ToAttachable(x).ParentOffset is useful.
EDIT:
Refenced from MovableMan.GetMOFromID


Last edited by mail2345 on Fri Aug 07, 2009 8:00 am, edited 1 time in total.



Fri Aug 07, 2009 6:16 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Wed Sep 05, 2007 4:14 am
Posts: 3966
Location: Canadida
Reply with quote
Post Re: Attaching using Lua
So are Centaurs feasible?
Because I really want to see centaurs, and ridable chocoboes.


Fri Aug 07, 2009 6:59 am
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post Re: Attaching using Lua
That has absolutely nothing to do with this. All this does is attach unnattached attachables... If the repetition there is throwing you off, simply put, no, you cannot have mounts outside of doing it hoverboard-styled. The closest you could get to that is making a semi-copy of your leg, detaching it, and sticking it to a mount. That would be lame, though.


Fri Aug 07, 2009 7:14 am
Profile WWW
Data Realms Elite
Data Realms Elite
User avatar

Joined: Wed Sep 05, 2007 4:14 am
Posts: 3966
Location: Canadida
Reply with quote
Post Re: Attaching using Lua
TheLastBanana wrote:
That has absolutely nothing to do with this. All this does is attach unnattached attachables... If the repetition there is throwing you off, simply put, no, you cannot have mounts outside of doing it hoverboard-styled. The closest you could get to that is making a semi-copy of your leg, detaching it, and sticking it to a mount. That would be lame, though.

Attach an AHuman, and have it mimic your moves, does that work?


Fri Aug 07, 2009 7:30 am
Profile
User avatar

Joined: Sun Jul 13, 2008 9:57 am
Posts: 4886
Location: some compy
Reply with quote
Post Re: Attaching using Lua
Foa wrote:
Attach an AHuman, and have it mimic your moves, does that work?

AHuman != Attachable
you could virtual offset it though.


Fri Aug 07, 2009 7:34 am
Profile WWW
Data Realms Elite
Data Realms Elite
User avatar

Joined: Wed Sep 05, 2007 4:14 am
Posts: 3966
Location: Canadida
Reply with quote
Post Re: Attaching using Lua
Geti wrote:
Foa wrote:
Attach an AHuman, and have it mimic your moves, does that work?

AHuman != Attachable
you could virtual offset it though.

What about the gun ship, then.


Fri Aug 07, 2009 7:54 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Attaching using Lua
Try attaching an ACrab to an ACDropShip? See if that works propely.


Fri Aug 07, 2009 8:17 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Attaching using Lua
Can't attach actors to actors or anything to anything besides actual, direct, attachables and actual, direct, actors.

Though you could attach dropship engines to actors.


Fri Aug 07, 2009 9:49 pm
Profile
User avatar

Joined: Sun Jul 13, 2008 9:57 am
Posts: 4886
Location: some compy
Reply with quote
Post Re: Attaching using Lua
it would probably just gib the dude though.


Fri Aug 07, 2009 11:29 pm
Profile WWW
User avatar

Joined: Mon Oct 06, 2008 2:04 am
Posts: 1559
Reply with quote
Post Re: Attaching using Lua
Behemoth says hi.


Sun Aug 09, 2009 5:20 am
Profile
Loose Canon
User avatar

Joined: Sun Mar 29, 2009 11:07 pm
Posts: 2992
Location: --------------->
Reply with quote
Post Re: Attaching using Lua
Grif wrote:
Can't attach actors to actors or anything to anything besides actual, direct, attachables and actual, direct, actors.

Though you could attach dropship engines to actors.

DO EET.


Sun Aug 09, 2009 5:43 am
Profile WWW
User avatar

Joined: Sun May 11, 2008 12:50 pm
Posts: 899
Reply with quote
Post Re: Attaching using Lua
Done, I did this a few builds ago:


Attachments:
ICanFly.rte.zip [1.58 KiB]
Downloaded 249 times
Mon Aug 10, 2009 11:23 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 13 posts ] 

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