Data Realms Fan Forums http://45.55.195.193/ |
|
Lua Attachable Test Failure http://45.55.195.193/viewtopic.php?f=73&t=25417 |
Page 1 of 1 |
Author: | blargiefarg [ Sun Sep 04, 2011 3:52 pm ] |
Post subject: | Lua Attachable Test Failure |
Okay, so I decided to do a little test on the new Lua+Attachable functionality, and see if I could make an underslung grenade launcher using an AEmitter bound to burst whenever the "F" key was pressed, with a burst spacing of 3 seconds so as not to be excessively cheap. I loaded up CC to test it, and tried to fire the gl to no avail. Sadly no errors popped up either. Here's my script: Code: function Create(self) self.rootactor = nil; local curdist = 50; for actor in MovableMan.Actors do local avgx = actor.Pos.X - self.Pos.X; local avgy = actor.Pos.Y - self.Pos.Y; local dist = math.sqrt(avgx ^ 2 + avgy ^ 2); if dist < curdist then curdist = dist; self.rootactor = actor; end end function Update(self) if self.rootactor ~= nil then if UInput:KeyHeld(6) then self.BurstTriggered = 1 self.EmissionAngle = self.rootactor.AimAngle end end |
Author: | Mehman [ Sun Sep 04, 2011 4:13 pm ] |
Post subject: | Re: Lua Attachable Test Failure |
BurstTriggered and EmissionAngle can't be directly modifyed by lua, what you can do however is use the TriggerBurst() function, the angle of emission follows the orientation of the AEmitter that follows the orientation of the thing it is attached to, so no need to set it, also you might want to check if the actor holding the rifle is currently controlled by the player(IsPlayerControlled()) before launching the grenade, otherwise it will lauch even if you control another actor, that can be a problem if you have more than one actor with this weapon. |
Author: | blargiefarg [ Sun Sep 04, 2011 11:55 pm ] |
Post subject: | Re: Lua Attachable Test Failure |
Thanks for the help once again. I never did understand how emitters were coded to work completely, I mean I'm guessing it fires the emission perpendicular to a surface of the emitter, but I never understood how the game chose the surface. It'd be easier if emitters had an equivalent to "MuzzleOffset" |
Author: | Asklar [ Mon Sep 05, 2011 12:01 am ] |
Post subject: | Re: Lua Attachable Test Failure |
It exists, take a look at the script of the dropship's engine: EmissionOffset, used along with EmissionAngle can help you a lot with determining the emissions positions and stuff. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |