Data Realms Fan Forums
http://45.55.195.193/

Need to figure out specific part of script
http://45.55.195.193/viewtopic.php?f=73&t=14668
Page 1 of 1

Author:  CaveCricket48 [ Sat May 16, 2009 12:37 am ]
Post subject:  Need to figure out specific part of script

Ok, I need help finding the part in the Red Detonater Lua script where it says you press fire to gib the Red C-4.

Here's the script:
Code:
function Create(self)
    print("Red C-4 detonated!");
    --Make sure the red C-4 list exists.
    if c4ListA ~= nil then
       --Go through the list of red C-4.
   for i=1,#c4ListA do
       --Make sure the C-4 still exists, it may have been destroyed.
       if MovableMan:IsParticle(c4ListA[i]) then
           --Detonate the C-4!
      c4ListA[i]:GibThis();
       end
   end
    end
    --Empty/create the red C-4 list.
    c4ListA = { };
end


Thanks in advance.

Author:  Grif [ Sat May 16, 2009 12:45 am ]
Post subject:  Re: Need to figure out specific part of script

What's happening is that a weapon is firing. The "detonator" creates a particle with an attached script. That script, posted above, is run on the "create" event--when the particle is created. Thus, by firing the detonator, you create the particle, which runs the script, which detonates the C4.

An actor specific alternative to this is the following:

Code:
if self:GetController():IsState(Controller.WEAPON_FIRE) then


Again, that's actor specific; only works for one actor with a specific script attached.

Author:  CaveCricket48 [ Sat May 16, 2009 12:51 am ]
Post subject:  Re: Need to figure out specific part of script

Thanks, that would work. Would Sharp Aim be "WEAPON_SHARP" or "WEAPON_SHARP_AIM"?

Author:  Grif [ Sat May 16, 2009 12:52 am ]
Post subject:  Re: Need to figure out specific part of script

AIM_SHARP, actually.

http://datarealms.com/wiki/index.php/LuaDocs/Controller

Author:  CaveCricket48 [ Sat May 16, 2009 1:17 am ]
Post subject:  Re: Need to figure out specific part of script

Well, I just found out Lua is difficult to learn by just messing around...
Anyways, if I was to implement your code into the red detonater script so it would replace the need for a particle, and detonate the C-4 with a push of the sharp aim button, what would that look like?
This reminds me when I had trouble with simple ini modding as a noob. Now it's with Lua...

Author:  Grif [ Sat May 16, 2009 1:41 am ]
Post subject:  Re: Need to figure out specific part of script

http://rafb.net/p/G4sL8915.html

Author:  CaveCricket48 [ Sat May 16, 2009 1:54 am ]
Post subject:  Re: Need to figure out specific part of script

Can I attach the script to a Gun? Maybe that's what I'm doing wrong. Here's what I have:

Attachments:
RA-GL.zip [6.33 KiB]
Downloaded 239 times

Author:  Mind [ Sat May 16, 2009 1:57 am ]
Post subject:  Re: Need to figure out specific part of script

You need to put this in the round code i think...:

Code:
ScriptPath = BlahBlah.rte/BlahBlah.lua

Author:  CaveCricket48 [ Sat May 16, 2009 1:57 am ]
Post subject:  Re: Need to figure out specific part of script

I have that. And it isn't commented out either.

Author:  Grif [ Sat May 16, 2009 2:00 am ]
Post subject:  Re: Need to figure out specific part of script

CaveCricket48 wrote:
Can I attach the script to a Gun? Maybe that's what I'm doing wrong. Here's what I have:


That's the problem; for the code I posted it has to be attached to an actor.

For a gun, you'd have to have it fire a unique particle and basically duplicate the detonators.

Author:  CaveCricket48 [ Sat May 16, 2009 2:03 am ]
Post subject:  Re: Need to figure out specific part of script

Drats. I can see that this is going to get really complicated. Is there a way to replace the sharp aim feature for a specific weapon to have an alt fire that creates the said particle?

Author:  Grif [ Sat May 16, 2009 2:04 am ]
Post subject:  Re: Need to figure out specific part of script

I...don't think so.

I'm really not all that good with lua, but to my knowledge that's not possible.

Author:  CaveCricket48 [ Sat May 16, 2009 2:13 am ]
Post subject:  Re: Need to figure out specific part of script

I'll just make a special actor then. It suprises me that with all the hype about Lua being the magic scripting language that can do it all, it can't replace the sharp aim for a firing mode.
Thanks for the help Grif. I can still have the gun design I want, but with only one actor. That's a pretty nice deal. Sort of.

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