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



Reply to topic  [ 14 posts ] 
 Why can't i understand lua? 
Author Message
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post Why can't i understand lua?
Sorry, but another problem:
Code:
function Create(self)
   local curdist = 75;
    for actor in MovableMan.Actors do
   local avgx = actor.Pos.X - self.Pos.X;
   local avgy = actor.Pos.Y - self.Pos.Y;
   local dist = math.sqrt(avgx ^ 2 + avgy ^ 2);
   if dist < curdist then
       curdist = dist;
       self.parent = actor
   self.Team = self.parent.Team   
self.timerl = Timer();
   end
    end
end

function Update(self)   
           if self.timerl:IsPastRealMS(250) then <-----
      blah blah
      self.timerl:Reset();
   end
end


Trying to reset "timerl" after .25 seconds, but says timerl is nil.... prolly something I'm missing says the "<---" line is wrong because, again, timerl is trying to be indexed while it is nil.

Btw, attached to an invisible particle.


Fri Jul 03, 2009 5:26 am
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Why can't i understand lua?
Migrate this:
self.timerl = Timer()

Out of the if block.


Fri Jul 03, 2009 5:27 am
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post Re: Why can't i understand lua?
K, thanks. Worked like a charm. Problem is, I know you can't (sigh) but can you use the scale variable on glows? If not, is there any way to change the size of them?


Fri Jul 03, 2009 5:33 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: Why can't i understand lua?
Nope, there isn't. You'll have to make a bunch of glows in different sizes.


Fri Jul 03, 2009 5:36 am
Profile WWW
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post Re: Why can't i understand lua?
TheLastBanana wrote:
Nope, there isn't. You'll have to make a bunch of glows in different sizes.


Hm... I doubt I'll go through the trouble of that.... then i would have to run a different script on every one of the possibly 20 glows for one little effect.


Fri Jul 03, 2009 5:38 am
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post Re: Why can't i understand lua?
Sorry. Double post, but:

Want this particle to last forever unless a button is pressed. Only lasting for twelve seconds.

Particle code:
Code:
AddEffect = MOPixel
   PresetName = Glow Ring Trap
   Mass = 0.1
   AddToGroup = AAA
   ScriptPath = Plasma Trapper.rte/Glow Ring.lua
   LifeTime = 100000
   PinStrength = 9
   Sharpness = 0
   HitsMOs = 0
   GetsHitByMOs = 0
   Color = Color
      R = 0
      G = 0
      B = 255
   Atom = Atom
      Material = Material
         CopyOf = Concrete
      TrailColor = Color
         R = 0
         G = 0
         B = 255
      TrailLength = 5
   ScreenEffect = ContentFile
      FilePath = Plasma Trapper.rte/Glow Ring.bmp
   EffectStartTime = 0
   EffectStopTime = 100000
   EffectStartStrength = 0.9
   EffectStopStrength = 0.9
   EffectAlwaysShows = 1


Lua code of particle:

Code:
function Create(self)
self.timerl = Timer();
   local curdist = 75;
    for actor in MovableMan.Actors do
   local avgx = actor.Pos.X - self.Pos.X;
   local avgy = actor.Pos.Y - self.Pos.Y;
   local dist = math.sqrt(avgx ^ 2 + avgy ^ 2);
   if dist < curdist then
       curdist = dist;
       self.parent = actor
   self.Team = self.parent.Team   
   end
    end
end



function Update(self)
   for actor in MovableMan.Actors do   
        local diff = actor.Pos - self.Pos
        local ang = diff.AbsRadAngle
      if (diff.Magnitude < 75) and (diff.Magnitude > 70) and actor.Team == self.Team then
         actor.Vel = Vector((self.Pos.X - actor.Pos.X) / 10, (self.Pos.Y - actor.Pos.Y) / 10)
      end
   end
   for particle in MovableMan.Particles do   
       local diff = particle.Pos - self.Pos
      if (diff.Magnitude < 110) and (diff.Magnitude > 65) then
         particle.Vel = Vector((self.Pos.X - particle.Pos.X) / 3, (self.Pos.Y - particle.Pos.Y) / 3)
      end
   end
   for device in MovableMan.Items do   
        local diff = device.Pos - self.Pos
      if (diff.Magnitude < 80) and (diff.Magnitude > 65) then
         device.Vel = Vector((self.Pos.X - device.Pos.X) / 3, (self.Pos.Y - device.Pos.Y) / 3)
      end
   end
if (UInputMan:KeyReleased(26)) then
   self.ToDelete = true
end
end


ToDelete works, but for some reason, it disappears after ~ 12-13 seconds.


Fri Jul 03, 2009 6:06 am
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Why can't i understand lua?
LifeTime = 0 in the ini should do the trick.


Fri Jul 03, 2009 6:06 am
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post Re: Why can't i understand lua?
mail2345 wrote:
LifeTime = 0 in the ini should do the trick.


That would kill it instantly, wouldn't it? Or is that the equivalent of inifinity?

Edit: Nope, stilll disappears after the magical 12 seconds.. :| I have no idea what it could be


Fri Jul 03, 2009 6:13 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Why can't i understand lua?
LifeTime = 100000

Make that 0? In the .ini code.

Then, to get around settling (probably the problem) either make it automatically rotate or just use ToSettle. Not sure of the arguments.


Fri Jul 03, 2009 6:18 am
Profile

Joined: Sat Feb 03, 2007 7:11 pm
Posts: 1496
Reply with quote
Post Re: Why can't i understand lua?
No, you have to set:

Code:
      particle.ToDelete = false;


Every frame that you don't want it deleted (Thanks TLB).


Fri Jul 03, 2009 4:11 pm
Profile WWW
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Why can't i understand lua?
If it's not disappearing from lifetime, which seems unlikely, given a 12-13 second time on a 100,000 lifetime (and 0 lifetime, if mind tested properly) then todelete won't do anything.

Pretty sure it's settling.


Fri Jul 03, 2009 4:21 pm
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post Re: Why can't i understand lua?
Grif wrote:
If it's not disappearing from lifetime, which seems unlikely, given a 12-13 second time on a 100,000 lifetime (and 0 lifetime, if mind tested properly) then todelete won't do anything.

Pretty sure it's settling.


So a high rest threshold should work then..?


Fri Jul 03, 2009 5:37 pm
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Why can't i understand lua?
Negative rest threshould.


Fri Jul 03, 2009 5:39 pm
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post Re: Why can't i understand lua?
mail2345 wrote:
Negative rest threshould.

Okay, I'll try that and see what happens :3


Fri Jul 03, 2009 6:33 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 14 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.052s | 14 Queries | GZIP : Off ]