Data Realms Fan Forums http://45.55.195.193/ |
|
Lighting a Screen [Fixed] http://45.55.195.193/viewtopic.php?f=73&t=16194 |
Page 1 of 1 |
Author: | CombatMedic02 [ Wed Aug 12, 2009 1:37 pm ] |
Post subject: | Lighting a Screen [Fixed] |
I need a little help in making my screen module light up. I want it to light up when a player get's close to it and I want it to turn of when they walk away from it. I suck at Lua but all other coding is there. It can be placed in game but doesn't light up when a actor is near it. I only used a basic piece of code as I have no real knowledge or concept of Lua and couldn't possibly make it work. When completed it will be put in my combat modules pack and the appropriate credits will be given. Please make my idea come to life! Thanks in advance, CBM02 |
Author: | Grif [ Wed Aug 12, 2009 4:10 pm ] |
Post subject: | Re: Lighting a Screen |
Step 1: Make an MOSRotating with two frames. Frame 000 is unlit, normal frame. Frame 001 is the frame lit with whatever you want. Step 2: function Create(self) self.checktimer = Timer(); self.checkbox = Box(Vector(self.Pos.X - 24,self.Pos.Y - 24),Vector(self.Pos.X + 24,self.Pos.Y + 24)); end function Update(self) if self.checktimer:IsPastSimMS(100) == true then self.checktimer:Reset(); for actor in MovableMan.Actors do if self.checkbox:WithinBox(actor.Pos) == true then self.Frame = 1; else self.Frame = 0; end end end end |
Author: | CombatMedic02 [ Wed Aug 12, 2009 7:49 pm ] |
Post subject: | Re: Lighting a Screen |
But what if I want it animating? Forgot to mention that. And I've already made it a MOSRotating. I figured it would have to be for the whole Lua thing to work. In my .RAR: 1] The screen and lit content image. 2] The .ini with the screen as a MOSRotating and the lighted up content as an AEmitter coded. 3] The Lua script that isn't currently working. The Lua Script: Code: --Reading the console if MovableMan:IsParticle(self.litscreen) == false then self.litscreen = CreateAEmitter("Lit Screen"); self.litscreen:EnableEmission(true); self.litscreen.Pos = Vector(1104,612); MovableMan:AddParticle(self.litscreen); end It looks a little light but I don't know enough about Lua to figure out what I'm missing. Basically I'm just trying to make it so that I get the little animation from the Doainar mission's screen to appear on my screen. Variations can be made later after I figure out how to do it and so I can practise it. CBM02 |
Author: | Grif [ Thu Aug 13, 2009 12:27 am ] |
Post subject: | Re: Lighting a Screen |
Change the litscreen position line to equal self.Pos, then use my previous script except for two changes: Instead of Frame = 1, add that block of code (all of it). And instead of Frame = 0, add: if MovableMan:IsParticle(self.litscreen) == true then self.litscreen.ToDelete = true; end |
Author: | CombatMedic02 [ Thu Aug 13, 2009 1:29 am ] |
Post subject: | Re: Lighting a Screen |
Code: function Create(self) self.checktimer = Timer(); self.checkbox = Box(Vector(self.Pos.X - 24,self.Pos.Y - 24),Vector(self.Pos.X + 24,self.Pos.Y + 24)); end function Update(self) if self.checktimer:IsPastSimMS(100) == true then self.checktimer:Reset(); for actor in MovableMan.Actors do if self.checkbox:WithinBox(actor.Pos) == true then self.if MovableMan:IsParticle(self.litscreen) == false then self.litscreen = CreateAEmitter("Lit Screen"); self.litscreen:EnableEmission(true); self.litscreen.Pos = self.Pos; MovableMan:AddParticle(self.litscreen); end else self.if MovableMan:IsParticle(self.litscreen) == true then self.litscreen.ToDelete = true; end end end end end Uh thanks but it's still not lighting up. [Probably my fault] It has to look like that? I wasn't sure if I had to keep the "self."s in. And I put the self.Pos in... I feel like a complete newbie not being able to do something as simple as this but Lua confuses me. What did I miss? |
Author: | Grif [ Thu Aug 13, 2009 1:50 am ] |
Post subject: | Re: Lighting a Screen |
http://pastebin.com/m4d352d56 Several things, most notably one (kinda my fault I guess) being that I mean for you to replace the block that said self.Frame with that, not just add that on instead of it. But that's almost guaranteed to work. That code, anyways. |
Author: | CombatMedic02 [ Thu Aug 13, 2009 12:24 pm ] |
Post subject: | Re: Lighting a Screen |
Thanks Grif! It's almost working! I have 2 minor problems though... One being that it doesn't turn off again and the second being that it is sightly off place. Any suggestions on how to fix? |
Author: | Grif [ Fri Aug 14, 2009 1:19 am ] |
Post subject: | Re: Lighting a Screen |
Off place would be adding a constant to position; instead of *emitter*.Pos = self.Pos, do: *nameofemitter*.Pos = Vector(self.Pos.X + numberofpixelstooffset,self.Pos.Y + numberofpixelstooffset); And then to delete it, just give the aemitter a Lifetime (in the .ini) as long as you want it to stay animating. |
Author: | CombatMedic02 [ Fri Aug 14, 2009 2:15 am ] |
Post subject: | Re: Lighting a Screen |
Thanks Grif! All working now. I'll work it into my Combat Modules mod with a few other bits and bobs and upload the update. Woo! It's so pretty. Thanks again for all your help Grif. CBM02 |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |