A pair of requests relating to variables

Hello, and thanks for reading my thread~

I've come with with the concept of Purity for my game; basically, it's depleted when you use spells and increased by using certain items. I've decided to make Purity a variable, and so far, my tests for using it have worked without a hitch. What I'm asking for is not how to run Purity.

What I'm asking for is two scripts; one to set Purity to it's "Max" and one so the player can see Purity.

The first script I know precisely where to put it, I just need the commands. This script goes into events on the overworld to recover Purity, and the way I want to do it is base 100 Purity, plus 10 Purity per level. I may adjust the numbers, depending on how much Purity I want larger spells to use, but I think once I have the script to calculate that increase, I should be able to edit it to my needs.

The second one is...a bit trickier. Purity is combat exclusive, so what I need is a way to display Purity in combat, preferably graphically. I had in mind a bar, but my imaging skills are...not so great. I did come up with a 150x10 pixel blue bar! But that's as far as I got.

As you can see above, I hope to increase purity throughout the game to allow larger spells to be cast; I think it will be more interesting to have a wide array of spells, plus it gives the player a choice of a Nuke, taking a chunk of purity, or gradually using Purity on smaller spells, without making Purity trivial at lower levels. So, if you could make the bar percentage-based, that would be super!

If you can come up with a script that also displays it out of combat, that would open up some interesting possibilities for cutscenes, but at the moment, I'm concerned only about the in-combat bar. I'm not using TP, so you could, in theory, put it there, but i plan to have a two-member party with a rotating third member, and only the first character would ever use purity.

So basically, if you come up with this script, of course I'll credit you in the credits, and I'd even be willing to write you in as an NPC if you like. That would be a lot of fun!

Thanks again.
Polite Bump - I'd like to have this script installed before I release a demo.
Polite bump again: going back to this project.
Well, I might be able to do this...

For the first one, call script: 

$game_variables[x] = 100 + $game_actors[n] * 10The second one is a bit tough. Do you use a custom battle script or some such? If so, I may need to see them, as I don't know the draw_item method they use. It should not be too hard, though.

I can also write a dedicated script for this, if you want...
Wooo someone really replied.

I'm just using a sideview battle system, Yamis Battle Symphony. 

Thank you so much for this. With this and a bit (read, a lot) more writing on my part, I should be able to present a working demo very soon!
Spoiler
module PurityConfig Actor_Using_Purity = { #actor_id => var_id 1 => 100, 3 => 103, } endclass Game_Actor < Game_Battler def use_purity? PurityConfig.has_key?(@actor_id) end def purity_var use_purity? ? PurityConfig[@actor_id] : 0 end def purity_max return level * 10 + 100 end def purity_rate return 0 unless use_purity? return $game_variables[purity_var] / purity_max.to_f end def restore_purity return unless use_purity? $game_variables[purity_var] = purity_max end endclass Game_Interpreter def restore_purity(actor) actor.restore_purity end endclass Window_BattleStatus < Window_Selectable alias :dgawt12740 :draw_gauge_area def draw_gauge_area(rect, actor) return dgawt12740(rect, actor) unless actor.use_purity? draw_actor_hp(actor, rect.x + 0, rect.y, 64) draw_actor_mp(actor, rect.x + 72, rect.y, 64) draw_actor_purity_gauge(actor, rect.x + 144, rect.y, 64) end def draw_actor_purity_gauge(actor, x, y, width) purity_rate = actor.purity_rate draw_gauge(x, y, width, purity_rate, normal_color, system_color) change_color(normal_color) draw_text(x, y, width, line_height, "Purity") draw_text(x, y, width, line_height, "#{purity_rate * 100}%", 2) end end 
If you are using a standard screen then, try this.

Edit: Using spoiler tag, it's a bit too long.
Nifty! So where do I plug it in, and am I going to have to put anything into the script to make it work? (Numbers, names, images, what have you)?
Just specify the actor using the variable in Actor_Using_Purity (at this point, I should just rename it to a generic name...)

In my example. 

1 => 100,means actor 1 uses variable no. 100. Change it as necessary.
Oh, you can also use 

Code:
restore_purity(actor)
on script calls, though it should be better if I streamline it more.
Code:
class Game_Interpreter  def restore_purity_id(actor_id)    $game_actors[actor_id].restore_purity  end    def restore_purity_all    $game_actors.each { |o| o.restore_purity }  endend
Add them, and you should be able to call script
Code:
restore_purity_by_id(actor_id)restore_purity_all
As for where to plug the scipt in, standard "below material above main" should work.
]Okay, stupid question time. Do I need to change @actor_id?

Right now, I'm getting an error

Script 'Purity Bar' line 14: NoMethodError occured.

undefined method 'has_key?' for PurityConfig:Module

I'm using Variable 002 for Purity, here's a screenshot of what it's at right now.

Purity.png
Oops, a syntax error from me. Meant to reference that hash, not the module.

In line 14, change

PurityConfig.has_key?(@actor_id)to

PurityConfig::Actor_Using_Purity.has_key?(@actor_id) Also, in line 18, change

use_purity? ? PurityConfig[@actor_id] : 0 to

use_purity? ? PurityConfig::Actor_Using_Purity[@actor_id] : 0 Also, when inputting numbers in any script, usually the leading zeroes should not be included. So, not 

001 => 002,but

1 => 2,Hope this helps!
The Purity Bar has been inputted and is now working wonderfully. I'm still having problems with the purity restoration script. 

I assume that on the event page, I used "Script" under advanced, but that's returning an undefined method error.

The short one, 

restore_purity_by_id(actor_id)restore_purity_allis what I do in the Script Box, right? But the long one, where should I put it?
Oh I see, it's typo once again. My bad. The correct call is

restore_purity_id(actor_id)This will restore the variable for supplied actor id. Well, it's easier to understand with screenshot.

scr3235.png


You don't need to use both. If you want to restore the variable value for actor 1 only, just use the first one.
Nailed it.

Now for the fun tasks of taking out my purity placeholders from the Alpha and implementing this new call~

Much thanks!
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/a-pair-of-requests-relating-to-variables.23329/