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



Reply to topic  [ 27 posts ]  Go to page 1, 2  Next
 Setting mass in lua. 
Author Message
User avatar

Joined: Sun Apr 25, 2010 12:04 am
Posts: 303
Location: Australia
Reply with quote
Post Setting mass in lua.
How would I make a bullet first have 0 mass then wait 2 seconds and then have 0.25 mass?

Or make the bullet 0 mass then slowly add mass.


Sun Jul 04, 2010 7:11 am
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Setting mass in lua.
In a .lua file:
Code:
function Update(self)
self.Mass = self.Mass + 1;
end

will make your mass go up by 1 every frame.
Code:
function Create(self)
  this.timer = Timer();
  this.Mass = 0;
end

function Update(self)
  if self.timer:IsPastSimMS(2000)
    self.Mass = 0.25;
  end
end

would make your mass go to 0.25 from 0 after 2 seconds.

I haven't tried this but I don't see why it wouldn't work.


Sun Jul 04, 2010 7:14 am
Profile
User avatar

Joined: Sun Apr 25, 2010 12:04 am
Posts: 303
Location: Australia
Reply with quote
Post Re: Setting mass in lua.
Thanks a lot Duh i'll test it out now!


EDIT

Worked.


Sun Jul 04, 2010 7:20 am
Profile
User avatar

Joined: Sun Jul 04, 2010 8:09 pm
Posts: 12
Reply with quote
Post Re: Setting mass in lua.
I have a quick question about this too. If I wanted to have the bullet gib after it reached like, 100 mass, how would I do that?


Sun Jul 04, 2010 8:21 pm
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Setting mass in lua.
As long as your bullet can gib, meaning it is a MOSRotating, AEmitter, Attachable, Actor, etc, use this:
Code:
function Update(self)
  self.Mass = self.Mass + 1;
  if self.Mass > 100 then
    self:GibThis();
  end
end

You can change the 1 and 100 to whatever numbers you like. Also, if you want to be more sophisticated and not do this every frame but every time period...
Code:
function Create(self)
  self.timer = Timer();
end

function Update(self)
  if self.timer:IsPastSimMS(500) then
    self.Mass = self.Mass + 1;
    self.timer:Reset();
  end
  if self.Mass > 100 then
    self:GibThis();
  end
end
Where the 500 is the time delay in simulated milliseconds.

I forgot the "then" after the if condition in the previous code examples, you need that.


Sun Jul 04, 2010 8:28 pm
Profile
User avatar

Joined: Sun Jul 04, 2010 8:09 pm
Posts: 12
Reply with quote
Post Re: Setting mass in lua.
Ok, so what I did is copy the Coalition Rocket Launcher, deleted the homing missile parts, and made sure it worked. Then I put the lua file in:
Quote:
AddAmmo = Round
PresetName = Round Coalition Rocket Launcher
Path = mod.rte/Mass.lua
ParticleCount = 1
Particle = AEmitter
CopyOf = Particle Coalition Rocket Launcher
Shell = AEmitter
CopyOf = Shell Coalition Rocket Launcher
FireVelocity = 40
ShellVelocity = 5
Separation = 5


And now it errors, and I don't know why.


Sun Jul 04, 2010 9:25 pm
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Setting mass in lua.
The ini variable to change is ScriptPath, not Path. Put ScriptPath = where the red is instead of Path = and it should work.


Sun Jul 04, 2010 9:42 pm
Profile
User avatar

Joined: Sun Jul 04, 2010 8:09 pm
Posts: 12
Reply with quote
Post Re: Setting mass in lua.
OK, changed that, but now it says "Cannot match property at line 369," which, assuming that it doesn't count empty lines, is that line.


Sun Jul 04, 2010 9:50 pm
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Setting mass in lua.
It counts every line actually, unless you have block quotes (the /* */ things).
I assume you are using b23 since you have the homing rocket launcher, did you accidentally type it or tab it wrong? It should be on the same tab line as PresetName and the capitalization must be ScriptPath.


Sun Jul 04, 2010 9:55 pm
Profile
User avatar

Joined: Sun Jul 04, 2010 8:09 pm
Posts: 12
Reply with quote
Post Re: Setting mass in lua.
It's actually b22, just with all the data files copied over from b23 (long story). Does that make a difference? Does it just not count comment lines? Sorry that was phrased so inelegantly.

Anyway, this is what it is now:
Quote:
AddAmmo = Round
PresetName = Round Coalition Rocket Launcher
ScriptPath = Mod.rte/Mass.lua
ParticleCount = 1
Particle = AEmitter
CopyOf = Particle Coalition Rocket Launcher
Shell = AEmitter
CopyOf = Shell Coalition Rocket Launcher
FireVelocity = 40
ShellVelocity = 5
Separation = 5


Mod folder name is, well, Mod.rte, lua file is Mass.lua.


Last edited by carnaxcce on Sun Jul 04, 2010 10:04 pm, edited 1 time in total.



Sun Jul 04, 2010 10:02 pm
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Setting mass in lua.
b23 is the only version that can do Lua, so yes it does matter. If you aren't using b23 you can't use any Lua.


Sun Jul 04, 2010 10:03 pm
Profile
User avatar

Joined: Sun Jul 04, 2010 8:09 pm
Posts: 12
Reply with quote
Post Re: Setting mass in lua.
The revolver cannon works, and that uses lua...
Can b23 be used on a non-moderator account on a mac? (It's actually not that long of a story).


Sun Jul 04, 2010 10:09 pm
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Setting mass in lua.
I'm afraid I don't follow? As long as you have a registration key you can use b23 (though you might need to upgrade it through licensing.datarealms.com)


Sun Jul 04, 2010 10:17 pm
Profile
User avatar

Joined: Fri Dec 22, 2006 4:20 am
Posts: 4772
Location: Good news everyone!
Reply with quote
Post Re: Setting mass in lua.
Moderator is to Mac as Administrator is to Windows?

If so, There's no "Run as Moderator" button? >_>


Sun Jul 04, 2010 10:46 pm
Profile WWW
User avatar

Joined: Sat Oct 17, 2009 2:07 pm
Posts: 127
Reply with quote
Post Re: Setting mass in lua.
Quote:
AddAmmo = Round
PresetName = Round Coalition Rocket Launcher
ScriptPath = Mod.rte/Mass.lua
ParticleCount = 1
Particle = AEmitter
CopyOf = Particle Coalition Rocket Launcher
Shell = AEmitter
CopyOf = Shell Coalition Rocket Launcher
FireVelocity = 40
ShellVelocity = 5
Separation = 5


You need to attach the script to particle, not round.


Sun Jul 04, 2010 10:51 pm
Profile ICQ
Display posts from previous:  Sort by  
Reply to topic   [ 27 posts ]  Go to page 1, 2  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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.055s | 13 Queries | GZIP : Off ]