View unanswered posts | View active topics It is currently Thu Dec 26, 2024 5:50 pm



Reply to topic  [ 9 posts ] 
 Lighting a Screen [Fixed] 
Author Message
User avatar

Joined: Wed Dec 17, 2008 11:35 am
Posts: 122
Location: London
Reply with quote
Post 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

Image


Last edited by CombatMedic02 on Fri Aug 14, 2009 2:17 am, edited 3 times in total.



Wed Aug 12, 2009 1:37 pm
Profile WWW
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post 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


Wed Aug 12, 2009 4:10 pm
Profile
User avatar

Joined: Wed Dec 17, 2008 11:35 am
Posts: 122
Location: London
Reply with quote
Post Re: Lighting a Screen
But what if I want it animating? Forgot to mention that. :P

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. :oops:

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.

Image

CBM02


Wed Aug 12, 2009 7:49 pm
Profile WWW
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post 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


Thu Aug 13, 2009 12:27 am
Profile
User avatar

Joined: Wed Dec 17, 2008 11:35 am
Posts: 122
Location: London
Reply with quote
Post 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. :oops:

What did I miss?


Thu Aug 13, 2009 1:29 am
Profile WWW
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post 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.


Thu Aug 13, 2009 1:50 am
Profile
User avatar

Joined: Wed Dec 17, 2008 11:35 am
Posts: 122
Location: London
Reply with quote
Post Re: Lighting a Screen
:0 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? :-(

Image


Thu Aug 13, 2009 12:24 pm
Profile WWW
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post 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.


Fri Aug 14, 2009 1:19 am
Profile
User avatar

Joined: Wed Dec 17, 2008 11:35 am
Posts: 122
Location: London
Reply with quote
Post 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. :grin:

Woo! It's so pretty. :grin:

Thanks again for all your help Grif. :)

CBM02


Fri Aug 14, 2009 2:15 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 9 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.063s | 13 Queries | GZIP : Off ]