Data Realms Fan Forums http://45.55.195.193/ |
|
Why can't i understand lua? http://45.55.195.193/viewtopic.php?f=73&t=15696 |
Page 1 of 1 |
Author: | Mind [ Fri Jul 03, 2009 5:26 am ] |
Post subject: | 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. |
Author: | mail2345 [ Fri Jul 03, 2009 5:27 am ] |
Post subject: | Re: Why can't i understand lua? |
Migrate this: self.timerl = Timer() Out of the if block. |
Author: | Mind [ Fri Jul 03, 2009 5:33 am ] |
Post subject: | 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? |
Author: | TheLastBanana [ Fri Jul 03, 2009 5:36 am ] |
Post subject: | Re: Why can't i understand lua? |
Nope, there isn't. You'll have to make a bunch of glows in different sizes. |
Author: | Mind [ Fri Jul 03, 2009 5:38 am ] |
Post subject: | 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. |
Author: | Mind [ Fri Jul 03, 2009 6:06 am ] |
Post subject: | 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. |
Author: | mail2345 [ Fri Jul 03, 2009 6:06 am ] |
Post subject: | Re: Why can't i understand lua? |
LifeTime = 0 in the ini should do the trick. |
Author: | Mind [ Fri Jul 03, 2009 6:13 am ] |
Post subject: | 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 |
Author: | Grif [ Fri Jul 03, 2009 6:18 am ] |
Post subject: | 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. |
Author: | zalo [ Fri Jul 03, 2009 4:11 pm ] |
Post subject: | 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). |
Author: | Grif [ Fri Jul 03, 2009 4:21 pm ] |
Post subject: | 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. |
Author: | Mind [ Fri Jul 03, 2009 5:37 pm ] |
Post subject: | 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..? |
Author: | mail2345 [ Fri Jul 03, 2009 5:39 pm ] |
Post subject: | Re: Why can't i understand lua? |
Negative rest threshould. |
Author: | Mind [ Fri Jul 03, 2009 6:33 pm ] |
Post subject: | Re: Why can't i understand lua? |
mail2345 wrote: Negative rest threshould. Okay, I'll try that and see what happens :3 |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |