View unanswered posts | View active topics It is currently Sat Apr 27, 2024 12:24 pm



Reply to topic  [ 13 posts ] 
 Need to figure out specific part of script 
Author Message
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post 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.


Sat May 16, 2009 12:37 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post 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.


Sat May 16, 2009 12:45 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post Re: Need to figure out specific part of script
Thanks, that would work. Would Sharp Aim be "WEAPON_SHARP" or "WEAPON_SHARP_AIM"?


Sat May 16, 2009 12:51 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Need to figure out specific part of script
AIM_SHARP, actually.

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


Sat May 16, 2009 12:52 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post 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...


Sat May 16, 2009 1:17 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Need to figure out specific part of script
http://rafb.net/p/G4sL8915.html


Sat May 16, 2009 1:41 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post 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 224 times
Sat May 16, 2009 1:54 am
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1359
Location: USA
Reply with quote
Post 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


Sat May 16, 2009 1:57 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post Re: Need to figure out specific part of script
I have that. And it isn't commented out either.


Sat May 16, 2009 1:57 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post 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.


Sat May 16, 2009 2:00 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post 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?


Sat May 16, 2009 2:03 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post 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.


Sat May 16, 2009 2:04 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post 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.


Sat May 16, 2009 2:13 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 13 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.095s | 16 Queries | GZIP : Off ]