Bars with Variables

Ok, I have updated the script for you to have the option of moving the text x and y. As well as enabled / disable/
Try this one: http://pastebin.com/xxZPxma6
Jeremy, would it be possible for you to add an option where the bar only displays during battle scenes, only displays during map scenes, or displays during both?

Also, how does the bar behave when the variable starts going into negative numbers?
Negative numbers just make the entire bar black. I can look into the battle scene.

Edut 2: nvm the negatives just fill the bar back up.
Would there be a way to make the bar fill in the opposite direction when the variable reaches into negative numbers?
That is a gnarly bit of code.
As you can see in this example once the bar reaches 0  it will extend in the other direction.

Spoiler
Untitled_zpsgjntiwdp.png
Is that kind of what you wanted?
Of course the color of the negative value can be easily changed.
Pretty much, yeah! I was thinking of having a bar where the unfilled parts would stretch to the ends of the screen in both directions, and the bar could then fill up in either direction. Like a tug of war.

Will you be posting this in the plugins section anytime soon?
I don't think I will post in there.
 

Here is the positive 50% screen shot.

Spoiler
50percent_zpsx8xx71wh.png
Here is the negative 80% example.

Spoiler
neg80percent_zpswyw3uklb.png
This code specifically written for you can be found here:

http://pastebin.com/8Tp93xw9

I must reiterate that you have to go into the script and supply it your own variables as it could be anything.

I can answer any questions about how to do this. But is it specific to each user so I don't think it is a good candidate for a released plugin.
I can answer any questions about how to do this. But is it specific to each user so I don't think it is a good candidate for a released plugin.
Ah, that's fair enough. The two examples you provided are pretty much exactly what I had in mind, by the way, nice work. If it were displayed during battle scenes (and updated itself accordingly when the variable was changed during the battle) it would be completely perfect.

P.S: I'm sorry if I'm hijacking your request a bit, Bareacine!
The code to make it show in a battle is most  likely similar. I haven't touched the battle scene yet but I can take a look into it. I guess I could have the option to display on the map or in battle or both.
Maybe something like this? Have the option of making the bar visible on the map or battle or both.

Spoiler
Untitled_zps4gsb4vms.png
Again if there are bug or errors just let me know.

http://pastebin.com/2ckyRvWt
Jeremy Cannady, please avoid double posting, as it is against the forum rules. You can review our forum rules here. Thank you.


If you need to add or change anything, please use the Edit button instead of double posting.
Thanks for continuing to work on this, Jeremy!

I've started testing it but ran into a hitch, although it's quite likely I'm just being code-illiterate.

I'm trying to configure the script so that the bar is displaying a game variable, rather than just a static number.

I tried changing

var b1CurrentValue = 50;

to

var b1CurrentValue = $gameVariables.value(5);

But that seems to break the plugin and renders the bar invisible.

Am I doing something wrong, or is this functionality not implemented yet?
Have you tired just putting it to 50?
This should display half way. If that works then it is something with your variable.
If you press F8 and bring up your console and type in $gameVariables.value(5); what does it spit out?
When I say that the bar is invisible, I mean the entire bar vanishes - it's indistinguishable from if the plugin wasn't turned on at all.

The variable is set to 0. If I set 'var b1CurrentValue' to 0, the bar is indeed empty, but it doesn't vanish, you can still see the empty bar, so I'm not sure why it isn't displaying when referring to a variable instead of a static number.
All you have to do is edit out the code that says drawRect. The default bars actually have two rectangles. It draws the black one (blackish color) first and then the colored one on top of it. You can just not draw the blank (black one) altogether and only the colored one will appear just by itself.
 
I think you may have misunderstood.

I don't want the bar to be invisible, or to edit how it looks: it's just that when I edit the script so that the bar is displaying a variable rather than a static number (the default being 50), it stops working and vanishes. I'm just wondering if you have any idea why this is or how to fix it. Have you tried linking the bar to a variable yourself?
Well it would depend on it your variable is working. If you go into the console can you get the number manually? This will tell you if you indeed have the variable working. If it has anything other then a number showing up then things will get squirrelly on you.
I can get the number from the console, yes. It fluctuates based on events but it all seems to be working correctly. There's also a periodic dialogue event that returns the current value of the variable.
Put a console.log(yourvariable) right after the var current = yourVariable;

This will spit out the variable to the console infinitely. Can you tell me if it is giving an actual number back?
Doesn't seem to be giving anything back. Although if I enter:

console.log($gameVariables.value(5))

directly into the console it does return the correct value.

Also, I don't know how I didn't notice this, but the console has been displaying an error message consistently:

/C:/Users/---/Documents/Games/---/js/plugins/Map_Bars.js:76 Uncaught TypeError: Cannot read property 'value' of null
Do you get the error when you supply fake variables?
If so then it has to be with how you are getting the $gameVariables it just isn't getting that value to plug in.

I will make a game variable and see if I can get it to update based on that variable.

Original thread: https://forums.rpgmakerweb.com/threads/bars-with-variables.47119/