Data Realms Fan Forums http://45.55.195.193/ |
|
Attachment's through lua? http://45.55.195.193/viewtopic.php?f=73&t=31461 |
Page 1 of 2 |
Author: | ShadowStorm [ Tue Jul 17, 2012 8:22 pm ] |
Post subject: | Attachment's through lua? |
I was wondering, is it possible to add an attachable through lua? because what I had in mind was, having an item with a pie menu button which when pressed, adds an helmet attachable on an actor's head... |
Author: | Asklar [ Tue Jul 17, 2012 8:29 pm ] |
Post subject: | Re: Attachment's through lua? |
As an attachable, I'm not sure. But, you can create the helmet and make it's position the head position, simulating to be a helmet. |
Author: | ShadowStorm [ Tue Jul 17, 2012 8:35 pm ] |
Post subject: | Re: Attachment's through lua? |
hmm.. would it still function as a helmet though? Edit: Or are you suggesting something that would replace the head? |
Author: | Asklar [ Tue Jul 17, 2012 8:43 pm ] |
Post subject: | Re: Attachment's through lua? |
Nonono, of course not! You create the helmet, and do something like Helmet.Pos = self.Head.Pos. It would work like a helmet, except that it wouldn't transfer the kinetic energy of the bullets if it is hit to the head. |
Author: | ShadowStorm [ Tue Jul 17, 2012 8:49 pm ] |
Post subject: | Re: Attachment's through lua? |
Oh, Alright, well I'll try it out anyways and see how badly "... It wouldn't transfer the kinetic energy of the bullets if it is hit to the head" would affect the actor. Thanks btw. |
Author: | Asklar [ Tue Jul 17, 2012 8:53 pm ] |
Post subject: | Re: Attachment's through lua? |
Post the results later, to see if you need more help. |
Author: | Roast Veg [ Tue Jul 17, 2012 11:06 pm ] |
Post subject: | Re: Attachment's through lua? |
There is an attach function, but it is extremely buggy and not officially documented. |
Author: | Asklar [ Tue Jul 17, 2012 11:51 pm ] |
Post subject: | Re: Attachment's through lua? |
Really? Where did you see that? |
Author: | Bad Boy [ Wed Jul 18, 2012 5:30 am ] |
Post subject: | Re: Attachment's through lua? |
You could also make the helmet have two frames, with the first one transparent. Change to the second frame with the pie button on the item. Though that may make the helmet completely unhittable even when it's showing, I'm not really sure. |
Author: | ShadowStorm [ Wed Jul 18, 2012 7:06 pm ] |
Post subject: | Re: Attachment's through lua? |
I have a few questions.. (Still new to lua, but previous programming helps!.. a bit) @Asklar - "Helmet.Pos = self.Head.Pos" Helmet is a variable I have to set/define right? @Bad Boy - I'm gonna try both methods and see which works better but I currently don't know how to switch frames... @Anyone - If what I think the "CreateAttachable" function does what I think it does then this: The following script is attached to a TDExplosive I've created Code: function Create(self) local Parent = ToAHuman(Actor) if Parent.EquippedItem then CreateAttachable("Civilian Helmet 1", "Shadow.rte") -- Create the Helmet? also, not sure if I did the "preset,rte name" thing right local Helmet = ("Civilian Helmet 1") -- Set recently created helmet as "Helmet" variable, or at least it is suppose to.. Helmet.Pos = Parent.Head.Pos -- Position Helmet to head position, Parent.Head.Pos is used because a bomb doesn't have limbs ToTDExplosive(Parent.EquippedItem):GibThis() -- Gib Helmet item end end EDIT: Fix't Should work, but it doesn't (and it usually doesn't on the first try). I get a error on the first line for some reason. EDIT: ERROR: [string "CreateHelmet"(ToActor(LuaMan.TempEntity));"]:1: attempt to call global 'CreateHelmet' (a nil value) This is the pie code on the actual Helmet item Code: AddPieSlice = Slice Description = Equip Helmet Direction = 1 Icon = Icon PresetName = Helmet FrameCount = 1 BitmapFile = ContentFile FilePath = Shadow.rte/Sprites/IconHelmet.bmp ScriptPath = Shadow.rte/Create Helmet.lua FunctionName = CreateHelmet |
Author: | Bad Boy [ Wed Jul 18, 2012 7:19 pm ] |
Post subject: | Re: Attachment's through lua? |
To get tabs, put it in [code] bbcodes. It'll change tabs into 3 spaces unfortunately but it's better than nothing. Anyway, I don't remember if there is actually a CreateAttachable but if it doesn't bug out there then I guess there is. Either way, you should combine the helmet making lines to be: local Helmet = CreateAttachable("Civilian Helmet 1", "Shadow.rte"); Then you'll want to actually add the helmet; as before I'm not sure if AddAttachable works either (but I doubt it) so you might have to change it a bit. MovableMan:AddAttachable(Helmet); Also, you don't seem to have defined actor and it's not part of the function. Unless there's more I'm not seeing or something you'll want to put local Actor = MovableMan:GetMOFromID(self.RootID); at the top of the create function. You could also combine it into one line with setting the parent if you wanted. Oh, and I'm not sure what you're going for but it might be better for the helmet maker to be deleted instead of gibbed, i.e. replace the gibbing line with Parent.EquippedItem.ToDelete = true; Finally, if this is supposed to be a pie script you'll either want to move everything into a pie button script instead or move all of this into the update function for the item and have it trigger when the item's sharpness changes (the pie button would be used to change the sharpness instead). |
Author: | Roast Veg [ Wed Jul 18, 2012 8:27 pm ] |
Post subject: | Re: Attachment's through lua? |
Asklar wrote: Where did you see that? Kyred found one here, and Darlos9D found another here. |
Author: | Roast Veg [ Wed Jul 18, 2012 9:42 pm ] |
Post subject: | Re: Attachment's through lua? |
CreateAttachable isn't a new function, we've had all the Create<<MO> functions for some time. Kyrid discovered the Attach function. |
Author: | Bad Boy [ Wed Jul 18, 2012 10:02 pm ] |
Post subject: | Re: Attachment's through lua? |
Okay yeah, I just couldn't remember if there was a CreateAttachable or if you had to create something else like an MOSRotating or whatever. I haven't really had to use CreateAttachable since most of what I do is activity scripting. |
Author: | Roast Veg [ Wed Jul 18, 2012 10:40 pm ] |
Post subject: | Re: Attachment's through lua? |
Well it has no purpose really other than to prepare an attachable for being attached, you'd do better to create the MOSR and pseudooffset it. |
Page 1 of 2 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |