Bars with Variables

Jeremy Cannady

Coldfire
Veteran
Joined
Oct 25, 2015
Messages
449
Reaction score
262
First Language
English
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.
 
Last edited by a moderator:

Sera

Veteran
Veteran
Joined
Oct 27, 2015
Messages
80
Reaction score
16
First Language
English
Would there be a way to make the bar fill in the opposite direction when the variable reaches into negative numbers?
 

Jeremy Cannady

Coldfire
Veteran
Joined
Oct 25, 2015
Messages
449
Reaction score
262
First Language
English
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.

Is that kind of what you wanted?
Of course the color of the negative value can be easily changed.
 

Sera

Veteran
Veteran
Joined
Oct 27, 2015
Messages
80
Reaction score
16
First Language
English
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?
 

Jeremy Cannady

Coldfire
Veteran
Joined
Oct 25, 2015
Messages
449
Reaction score
262
First Language
English
I don't think I will post in there.
 

Here is the positive 50% screen shot.

Here is the negative 80% example.

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.
 

Sera

Veteran
Veteran
Joined
Oct 27, 2015
Messages
80
Reaction score
16
First Language
English
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!
 

Jeremy Cannady

Coldfire
Veteran
Joined
Oct 25, 2015
Messages
449
Reaction score
262
First Language
English
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.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,788
Reaction score
12,217
First Language
English
Primarily Uses
RMMV
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.
 

Sera

Veteran
Veteran
Joined
Oct 27, 2015
Messages
80
Reaction score
16
First Language
English
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?
 

Jeremy Cannady

Coldfire
Veteran
Joined
Oct 25, 2015
Messages
449
Reaction score
262
First Language
English
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?
 

Sera

Veteran
Veteran
Joined
Oct 27, 2015
Messages
80
Reaction score
16
First Language
English
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.
 

Jeremy Cannady

Coldfire
Veteran
Joined
Oct 25, 2015
Messages
449
Reaction score
262
First Language
English
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.
 
 

Sera

Veteran
Veteran
Joined
Oct 27, 2015
Messages
80
Reaction score
16
First Language
English
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?
 

Jeremy Cannady

Coldfire
Veteran
Joined
Oct 25, 2015
Messages
449
Reaction score
262
First Language
English
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.
 

Sera

Veteran
Veteran
Joined
Oct 27, 2015
Messages
80
Reaction score
16
First Language
English
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.
 

Jeremy Cannady

Coldfire
Veteran
Joined
Oct 25, 2015
Messages
449
Reaction score
262
First Language
English
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?
 

Sera

Veteran
Veteran
Joined
Oct 27, 2015
Messages
80
Reaction score
16
First Language
English
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
 

Jeremy Cannady

Coldfire
Veteran
Joined
Oct 25, 2015
Messages
449
Reaction score
262
First Language
English
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.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 2)

Latest Threads

Latest Profile Posts

Social distancing extended for another week. Personally I'm cool, but this is depressing.
GOOOOD MOOORNING!
APRIL WILL BE BETTER!
First time I've seen the shelves full in my local shop in a while. Still no soap, though.
RachelTheSeeker wrote on StormyRange's profile.
Hey! Haven't I seen you before? :p Good to see you on a RPG Maker site; am pleasantly surprised. :)
When you really think about it, the Trolley Problem is pretty dumb.

Forum statistics

Threads
95,566
Messages
930,132
Members
125,851
Latest member
khanmovies
Top