Would there be a way to make the bar fill in the opposite direction when the variable reaches into negative numbers?
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?
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.
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.