View unanswered posts | View active topics It is currently Fri Apr 19, 2024 2:14 am



Reply to topic  [ 4 posts ] 
 Lua Attachable Test Failure 
Author Message
User avatar

Joined: Mon Apr 05, 2010 8:04 am
Posts: 149
Location: Under your bed
Reply with quote
Post 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


Sun Sep 04, 2011 3:52 pm
Profile YIM
User avatar

Joined: Tue Nov 17, 2009 7:38 pm
Posts: 909
Location: France
Reply with quote
Post 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.


Sun Sep 04, 2011 4:13 pm
Profile
User avatar

Joined: Mon Apr 05, 2010 8:04 am
Posts: 149
Location: Under your bed
Reply with quote
Post 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"


Sun Sep 04, 2011 11:55 pm
Profile YIM
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post 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.


Mon Sep 05, 2011 12:01 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 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.054s | 15 Queries | GZIP : Off ]