Author |
Message |
Kyred
Joined: Sun May 31, 2009 1:04 am Posts: 308
|
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: There is an Attachable:Attach(); function! So I tried it out by trying to attach a Soldier's helmet to a Dummy's head: 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 |
|
|
mail2345
Joined: Tue Nov 06, 2007 6:58 am Posts: 2054
|
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 |
|
|
Foa
Data Realms Elite
Joined: Wed Sep 05, 2007 4:14 am Posts: 3966 Location: Canadida
|
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 |
|
|
TheLastBanana
DRL Developer
Joined: Wed Dec 13, 2006 5:27 am Posts: 3138 Location: A little south and a lot west of Moscow
|
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 |
|
|
Foa
Data Realms Elite
Joined: Wed Sep 05, 2007 4:14 am Posts: 3966 Location: Canadida
|
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 |
|
|
Geti
Joined: Sun Jul 13, 2008 9:57 am Posts: 4886 Location: some compy
|
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 |
|
|
Foa
Data Realms Elite
Joined: Wed Sep 05, 2007 4:14 am Posts: 3966 Location: Canadida
|
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 |
|
|
MaximDude
Joined: Wed Nov 22, 2006 3:19 pm Posts: 2073
|
Re: Attaching using Lua
Try attaching an ACrab to an ACDropShip? See if that works propely.
|
Fri Aug 07, 2009 8:17 pm |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
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 |
|
|
Geti
Joined: Sun Jul 13, 2008 9:57 am Posts: 4886 Location: some compy
|
Re: Attaching using Lua
it would probably just gib the dude though.
|
Fri Aug 07, 2009 11:29 pm |
|
|
LowestFormOfWit
Joined: Mon Oct 06, 2008 2:04 am Posts: 1559
|
Re: Attaching using Lua
Behemoth says hi.
|
Sun Aug 09, 2009 5:20 am |
|
|
TorrentHKU
Loose Canon
Joined: Sun Mar 29, 2009 11:07 pm Posts: 2992 Location: --------------->
|
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 |
|
|
Roon3
Joined: Sun May 11, 2008 12:50 pm Posts: 899
|
Re: Attaching using Lua
Done, I did this a few builds ago:
|
Mon Aug 10, 2009 11:23 am |
|
|
|