View unanswered posts | View active topics It is currently Fri Dec 27, 2024 9:54 am



Reply to topic  [ 32 posts ]  Go to page 1, 2, 3  Next
 I need help with a script I am making 
Author Message
User avatar

Joined: Sat Nov 18, 2006 8:11 pm
Posts: 267
Reply with quote
Post I need help with a script I am making
My gun fires an MOPixel, and the MO pixel runs the lua script.

I want the script to spawn an emitter at the same velocity and direction as the original MOPixel. So far, I have that. What I don't have, is more than one object spawned. I want it to spawn 50 objects randomly within a certain field after the MOPixel. So let's so they randomly spawn between pixel 0 and 100. BUT I WOULD PREFER if I could get them to shoot out evenly spaced every time. So The first emitter spawns from the MOPixel, and another one spawns five pixels ahead, and then another one five pixels ahead, and so on.

Here is what I have so far. You can see I tried to use the random method, but I am terrible at lua. Once again I would prefer if they were evenly spaced every time.

Code:
function Create(self)
   local shot = CreateAEmitter("Justice Shot");
   shot.Pos = self.Pos, -math.random(150) - 50;
   shot.Vel = self.Vel;
   MovableMan:AddMO(shot);
end


Sun Jan 17, 2010 8:55 am
Profile WWW
User avatar

Joined: Mon Jun 29, 2009 2:40 am
Posts: 610
Location: Deep below The Map of Mars
Reply with quote
Post Re: I need help with a script I am making
If you want them all spawned at once, I would use a for-loop.
Code:
i = 0
for i < 50 do
   local emitter = CreateEmitter(<presetname of emitter>)
   emitter.Pos = <placement method>
   emitter.Vel = self.Vel
   MovableMan:AddParticle(emitter)
   i=i+1
end

I have not tested this code, it's just a tweak of something I wrote a while ago. There's probably a better way to do that too.

As for placement, do you want a straight line in front of the original MOPixel, or random emitters scattered all around?
I don't get it.
Please reiterate what you want most from this, I am confused by the way you initially say random, and then say evenly spaced.
Neither way is impossible, or even difficult, but we need to know exactly how to help.
Also, is this to use sparkle magic to make an effect look nice? I am a fan of prettiness in CC weapons.


Sun Jan 17, 2010 12:55 pm
Profile
User avatar

Joined: Sat Nov 18, 2006 8:11 pm
Posts: 267
Reply with quote
Post Re: I need help with a script I am making
PhantomAGN wrote:
If you want them all spawned at once, I would use a for-loop.
Code:
i = 0
for i < 50 do
   local emitter = CreateEmitter(<presetname of emitter>)
   emitter.Pos = <placement method>
   emitter.Vel = self.Vel
   MovableMan:AddParticle(emitter)
   i=i+1
end

I have not tested this code, it's just a tweak of something I wrote a while ago. There's probably a better way to do that too.

As for placement, do you want a straight line in front of the original MOPixel, or random emitters scattered all around?
I don't get it.
Please reiterate what you want most from this, I am confused by the way you initially say random, and then say evenly spaced.
Neither way is impossible, or even difficult, but we need to know exactly how to help.
Also, is this to use sparkle magic to make an effect look nice? I am a fan of prettiness in CC weapons.


Well thanks for the reply!

Well let's just focus on the "evenly spaced" method, because I would prefer that.

So it will look like this:

Image

The MOPixel is fired, and from that position it spawns the objects all directly ahead of each other with five pixels in between each spawned object. And I want them to spawn at the same time(or as close as possible). Also, refer to the GIF bellow, that's how it should work.

No sparkle magic required to make it look better, it already looks great:
Image
That version is bugged though, using ridiculous offsets and whatnot. It uses a high separation and and high muzzleoffset, but that causes some issues so I need to achieve that same effect with lua. But yeah, it's going to look like that.

Also, I tested that code and it said "=" or "in" expected near "<"


Sun Jan 17, 2010 9:26 pm
Profile WWW
User avatar

Joined: Mon Jun 29, 2009 2:40 am
Posts: 610
Location: Deep below The Map of Mars
Reply with quote
Post Re: I need help with a script I am making
I could watch that gif all day.
How far do you want it to fire?

I think a loop of using the particle's rotation (or that of its parent) and then measuring out an increasing distance and placing a dot there is all you need to do, to a limit of whatever range you want it to fire. Simple Trig stuff, I'll test it and show you shortly.

Got a lot of soldering to do on a real-world project first, should be done in a few hours.


Mon Jan 18, 2010 12:30 am
Profile
User avatar

Joined: Sat Nov 18, 2006 8:11 pm
Posts: 267
Reply with quote
Post Re: I need help with a script I am making
PhantomAGN wrote:
I could watch that gif all day.
How far do you want it to fire?

I think a loop of using the particle's rotation (or that of its parent) and then measuring out an increasing distance and placing a dot there is all you need to do, to a limit of whatever range you want it to fire. Simple Trig stuff, I'll test it and show you shortly.

Got a lot of soldering to do on a real-world project first, should be done in a few hours.


Alright, cool. Are we talking distance in pixels?

Maybe somewhere around 1000 pixels.


Mon Jan 18, 2010 1:03 am
Profile WWW
User avatar

Joined: Mon Jun 29, 2009 2:40 am
Posts: 610
Location: Deep below The Map of Mars
Reply with quote
Post Re: I need help with a script I am making
Spent three hours on stupid stupid errors, have to temporarily admit defeat.
There is something very wrong here, and it's missing some of what is supposed to be there, but it's code you can look at I suppose.
http://pastebin.com/d111c685e
The error is with AddParticle., if anyone has any idea why this fails to work, let me know.
It's is letter for latter the same code I have used in another script.


Mon Jan 18, 2010 12:03 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: I need help with a script I am making
I've had some problems where if there is an "if" or "for" statement between the to-be-spawned MO definition and the spawning part when using "local" variables. Change it to "self" and it should work.


Mon Jan 18, 2010 5:32 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: I need help with a script I am making
It's because you only have one 'beam' particle that you're attempting to create fifty times in different spots. If you define it as local inside the if it should work fine.


Mon Jan 18, 2010 7:04 pm
Profile
User avatar

Joined: Mon Jun 29, 2009 2:40 am
Posts: 610
Location: Deep below The Map of Mars
Reply with quote
Post Re: I need help with a script I am making
Ahhahahaha
This is why I should not be allowed to code after 15 hours of consciousness.

Pulled the junk out, reorganized, here's something you can try to use.
http://pastebin.com/m76411ebc
This script is attached to a null bullet the gun fires, which must have a lifetime of 1 and a high pinstrength.
Then of course you need to define
Code:
AddAmmo = MOPixel
   InstanceName = Beam Dot
   blah blah blah
   etc
   ScreenEffect = ContentFile
      FilePath = glow you want to see


You will probably want to make the glows move or something too.
I'm fiddling with making the spawned glows disperse nicely now.


Mon Jan 18, 2010 8:46 pm
Profile
User avatar

Joined: Sat Nov 18, 2006 8:11 pm
Posts: 267
Reply with quote
Post Re: I need help with a script I am making
PhantomAGN wrote:
Ahhahahaha
This is why I should not be allowed to code after 15 hours of consciousness.

Pulled the junk out, reorganized, here's something you can try to use.
http://pastebin.com/m76411ebc
This script is attached to a null bullet the gun fires, which must have a lifetime of 1 and a high pinstrength.
Then of course you need to define
Code:
AddAmmo = MOPixel
   InstanceName = Beam Dot
   blah blah blah
   etc
   ScreenEffect = ContentFile
      FilePath = glow you want to see


You will probably want to make the glows move or something too.
I'm fiddling with making the spawned glows disperse nicely now.


Well... the good news is that it works.

The bad news is that it doesn't work right...
Image
(And they are appearing so far out front because the muzzleoffset, not the script, so don't worry about that part)

I was kinda hoping it would fire in a straight line despite the aiming direction :P

And even so, firing horizontally, all the emitters travel at a downward angle(which you can see in that gif too)

Thanks for all the effort so far though, gosh, you've put a lot of time into this already :P

Thank you


Tue Jan 19, 2010 1:18 am
Profile WWW
User avatar

Joined: Mon Jun 29, 2009 2:40 am
Posts: 610
Location: Deep below The Map of Mars
Reply with quote
Post Re: I need help with a script I am making
Hah, I bet it was not able to find the actor that fired it.
Fix the offset, and then tell me if it still does that, I can also just change how it finds him.

If anyone knows a way to make the fired emitters defeat gravity without attaching Lua to all of them, please speak up.


Tue Jan 19, 2010 1:35 am
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post Re: I need help with a script I am making
Add this line to the emitters' code:
Code:
GlobalAccScalar = 0


Tue Jan 19, 2010 1:42 am
Profile WWW
User avatar

Joined: Sat Nov 18, 2006 8:11 pm
Posts: 267
Reply with quote
Post Re: I need help with a script I am making
PhantomAGN wrote:
Hah, I bet it was not able to find the actor that fired it.
Fix the offset, and then tell me if it still does that, I can also just change how it finds him.

If anyone knows a way to make the fired emitters defeat gravity without attaching Lua to all of them, please speak up.


OH GOD FUUUUUUUUU-
Image

I only changed the muzzleoffset by like, 20 pixels that's all D:


Tue Jan 19, 2010 1:50 am
Profile WWW
User avatar

Joined: Mon Jun 29, 2009 2:40 am
Posts: 610
Location: Deep below The Map of Mars
Reply with quote
Post Re: I need help with a script I am making
This is THE best fail ever.
I suspect you placed the offset 20 px behind the gun, or something crazy.

Can I work on the code directly?
Then I'll fix the getting-of-aim-angle thing too.


Tue Jan 19, 2010 2:05 am
Profile
Loose Canon
User avatar

Joined: Sun Mar 29, 2009 11:07 pm
Posts: 2992
Location: --------------->
Reply with quote
Post Re: I need help with a script I am making
I suspect gravity and a map that loops very quickly happened.


Tue Jan 19, 2010 2:21 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 32 posts ]  Go to page 1, 2, 3  Next

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.042s | 13 Queries | GZIP : Off ]