Data Realms Fan Forums
http://45.55.195.193/

Eye lasers
http://45.55.195.193/viewtopic.php?f=73&t=45466
Page 1 of 1

Author:  omegadrace [ Fri Nov 01, 2013 9:30 am ]
Post subject:  Eye lasers

I wish to use eye lasers for an ahuman (the head is where the gun is. I can't seem to attach the arms to the head), but I don't want it to be a continuous laser. I'm using an old laser script posted ages ago, as such:

What would I add to this to space out the shots more? And, as an aside, how would I go about making this spawn MOSParticles rather than AEmitters?
Sorry if this question is easily answered, I am not good with LUA. :(

Author:  clunatic [ Fri Nov 01, 2013 4:01 pm ]
Post subject:  Re: Eye lasers

I'm not sure what you mean by space the shots out more? The script seems to fire one TA Laser every time you press the fire button. To make it fire MOSParticles, just change this line:

Code:
 local Emitter = CreateAEmitter("TA Laser", "Terran Alliance.rte")


to this:

Code:
 local Emitter = CreateMOSParticle("TA Laser", "Terran Alliance.rte")


You can also change the local Emitter to local MOSParticle (or whatever you want), but make sure to change the other places where Emitter is used as well.

Author:  Foa [ Sat Nov 02, 2013 8:14 pm ]
Post subject:  Re: Eye lasers

Code:
local \Var\ = \etc\

Simply defines a local variable with the name \var\.

Author:  omegadrace [ Sun Nov 03, 2013 2:16 am ]
Post subject:  Re: Eye lasers

It doesn't fire a single shot, it fires a steady stream as long as the button is pressed. I want to add a small space between the shots.

And thank you, I'll get to changing it to mosparticle.

Author:  clunatic [ Sun Nov 03, 2013 3:49 am ]
Post subject:  Re: Eye lasers



This code should work to add a delay to the shots, you'll just need to adjust the time to whatever you want.

Author:  omegadrace [ Sun Nov 03, 2013 2:03 pm ]
Post subject:  Re: Eye lasers

Alright, that works perfectly! Thank you.
My next question is, how would I go about having certain parts of that script active when the actor is holding a certain weapon? Set out probably like this:
Code:
   if self:GetController():IsState(Controller.WEAPON_FIRE) and self.Head:IsAttached() and (Detect specific gun?) then
            (do that specific laser firing)
      end
      if self:GetController():IsState(Controller.WEAPON_FIRE) and self.Head:IsAttached() and (Detect another specific gun?) then
            (do another specific laser firing)
      end
      if self.Head:IsAttached() and (Neither of those guns?) then
            (Drop whatever is being held)
      end
   end


Is this possible?

Author:  clunatic [ Sun Nov 03, 2013 3:53 pm ]
Post subject:  Re: Eye lasers

Yup, self.EquippedItem.PresetName("GunNameHere") is what you want to use in the if statements. For the last one you can do

Code:
if self.Head:IsAttached() and not self.EquippedItem.PresetName("GunNameHere1") and not self.EquippedItem.PresetName("GunNameHere2") then
    self:GetController():SetState(Controller.WEAPON_DROP,true)
end


Again, untested code written from memory in 3 minutes, so don't sue me if it doesn't work :P.

Author:  omegadrace [ Mon Nov 04, 2013 6:29 am ]
Post subject:  Re: Eye lasers

I had to remove the brackets for it to detect the guns for the different laser types like so:
Code:
if self:GetController():IsState(Controller.WEAPON_FIRE) and self.Head:IsAttached() and self.EquippedItem.PresetName == "Pulse Laser Module" then


But the dropping part didn't work. The actor can still pick up things with reckless abandon, with no errors in sight.

Author:  clunatic [ Tue Dec 03, 2013 2:25 am ]
Post subject:  Re: Eye lasers

Oops, I completely forgot about this thread, sorry about that! :oops:

Anyway, glad that you managed to correct my bad code for the equipped weapon name thingy. On the weapon drop part: You could try dropping in a print after the if statement, just to check that the code is actually getting to the weapon drop part. Also, that code, if it was working, would just tell the actor to drop what ever he's holding, it doesn't stop the actor from immediatedly picking the weapon up again, that would require a bit more code.

Let me know if you still need help, or already managed to figure it out yourself.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/