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



Reply to topic  [ 3 posts ] 
 Energy Bar? 
Author Message
User avatar

Joined: Sat Jul 23, 2011 6:15 am
Posts: 82
Reply with quote
Post Energy Bar?
No. Not the food. Sorry if this has already been asked, but is it possible to make something similar to an energy bar, where it shows how much energy you have and each shot reduces that? So, basically, you would make a global variable and spawn particles so that you can see how much energy there is, then attach a script to the guns or the bullets to reduce the amount of energy, right? I'm not exactly certain how you would type this, so please help. All my (two) attempts at lua... Failed. But please don't just type up the code for me. Just give me pointers and stuff.


Fri Mar 30, 2012 8:09 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Energy Bar?
If the energy bar is only for a single item (say, the meter represents the amount of "ammo" in a gun), you'd want it localized. The bar can simply be a multi-framed spirte where frame 0 is "empty", and as the frame number increases, the "fullness" of the bar increases until it's completely full. Then you can sync that with your ammo counter and have the bar sprite frame increase/decrease accordingly.


Fri Mar 30, 2012 11:16 pm
Profile
User avatar

Joined: Sat Jul 23, 2011 6:15 am
Posts: 82
Reply with quote
Post Re: Energy Bar?
Nope. I'm making it so that the script is attached to an actor that has a weapon pre-equipped that uses that energy. It's magic, so mana. Thanks. I'll try to code that. Try... If I fail and need more help, I'll post the code and my problem.



Edit: Yeah... I need help. I currently only have a code to increase the amount of mana every tenth of a second, but I want a visual representation. I remember seeing threads on animations and MOSRotatings around here somewhere, but... I can't find them. Please could you help me? I kind of want a stationary bar hovering somewhere a bit above or a bit below the actor. How should I do that? Should I just make another gib particle on the head or something and attach it higher up and animate that? Or is it possible to have it actually spawn the sprite somewhere in relation to the actor and keep it there? Well, I could just tack on a code to the sprite to make it stay somewhere in relation to the actor. Well, basically, two questions:

1. How do I create a sprite using Lua (As in, what function do I use and what are the arguments?)

2. Once I create that sprite, how do I position it?

Wow. I just found CreateMOSRotating on the HTML version of the wiki, and it can't find the file for anything there...

Edit 2: Oh. And how would I attach this script to the actor? Would I have to integrate it with some other script or something?



Edit 3: Ah. Now that I think about it, the script should probably be attached to the gun. It'll be easier, too, anyways.


Okay. Starting fresh with edits. So. Basically, to create the MOSRotating, I simply make a variable with whatever name I like and use the CreateMOSRotating() function. The arguments are the preset name of the MO and the location (of the file), right?

Then I make <variable_name>.Pos.Vector = Whatever I like, so in this case, something like (self.target.PosX,self.target.PosY + 100)... Do I have to set the velocity? Well, anyways, then I'll attach a script to that MOSRotating that makes the velocity the same as the actor's.

Ah. Then I could just make the script on the gun change the frame of the MOSRotating according to the variable called "Mana." Now I just have to make a script to change the gun's magazine when I hit a certain key and make each type of ammo use a different amount of mana... Well, I have to finish coding that first and testing it. Then I can move on to the actual functions of the weapon.


Fri Mar 30, 2012 11:41 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 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.057s | 14 Queries | GZIP : Off ]