Variable Max

Status
Not open for further replies.

Ichimaru Gin

Veteran
Veteran
Joined
Jul 13, 2013
Messages
78
Reaction score
0
First Language
English
Primarily Uses
I made some variables through events, can anyone tell me how to set the max number to 100? So say I have 99 X and I add 50 x it only goes to 100X
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
When you change the variable, do it via a script, like this:

Code:
Control Variables [0001: Number]: Script: [$game_variables[1] + 50, 100].max
 

Ichimaru Gin

Veteran
Veteran
Joined
Jul 13, 2013
Messages
78
Reaction score
0
First Language
English
Primarily Uses
How do I subtract variables this way?

Thank you
 
Last edited by a moderator:

Arin

Some happiness we have to let go of.
Veteran
Joined
Oct 18, 2012
Messages
1,228
Reaction score
189
First Language
Fraglspock
Primarily Uses
RMMV
So, if I'm reading this right, you only want the maximum of a Variable to be 100? That's easy to do: You have to set up a Common Event with a switch to activate it, while also putting it as a Parallel Process. Feel free to use this as an example. Except since this is run in the Troops Tab, it functions differently than it does through Common events (can only be run on the Map Screen).
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
How do I subtract variables this way?


Thank you
You will need to explain what you are trying to do.


Control Variables already allows you to subtract variables from one another. It's the Sub operator.
 

izanamikun

Veteran
Veteran
Joined
Nov 19, 2013
Messages
34
Reaction score
1
First Language
English
Primarily Uses
Just like Arin said for the max 100, you can set up the parallel event in common events tab to keep the variable 0 and above to 100.

If Var_MaxMin >100, set to 100

If Var_MaxMin>0, set to 0

That should take care of your maximum and minimum.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Why would you use a parallel processing event to check and change something that is only going to change its value when you tell it to? If you know exactly when it's going to change (ie - when you use a Control Variables command), check it and change it straight away.


It's wasteful and poor design to have something running ALL THE TIME when you could easily check it at the exact time it changes.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,355
Reaction score
7,669
First Language
German
Primarily Uses
RMMV
How do I subtract variables this way?

Thank you
Control Variables [0001: Number]: Script: [$game_variables[1] - 50, 0].maxI haven't tested this, but it should work (assuming that you want to substract variables without getting into negatives, if you want something else, please explain.

Edit: (one error already corrected)
 
Last edited by a moderator:

Ichimaru Gin

Veteran
Veteran
Joined
Jul 13, 2013
Messages
78
Reaction score
0
First Language
English
Primarily Uses
Control Variables [0001: Number]: Script: [$game_variables[1] - 50, 0].maxI haven't tested this, but it should work (assuming that you want to substract variables without getting into negatives, if you want something else, please explain.

Edit: (one error already corrected)
Your way does not work, it even contradicts the adding of the variable.

@Shaz I want my variable rest to be added by 80 everytime my character sleeps, but not go past 100. That part works....But I also want my hunger and thirst variables to go down when I sleep, and I don't want the numbers in the negative..
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Andar's method SHOULD work. It's just the same as mine, except it's setting 0 as the minimum.


If your hunger variable is 20 and you want it to go down by 50 when your character sleeps, that would put it at -30, which would then be compared to 0, and the max of those two is 0, so it would be set to 0.


In fact, MY method is the one with the error. That should be .min at the end, not .max


So, to add to variable 1 and ensure it doesn't go over 100, use this:

Code:
Control Variables [0001: ] Script: [$game_variables[1] + 50, 100].min
And to subtract from variable 1 and ensure it doesn't go below 0, use this:
Code:
Control Variables [0001: ] Script: [$game_variables[1] - 50, 0].max
 

Ichimaru Gin

Veteran
Veteran
Joined
Jul 13, 2013
Messages
78
Reaction score
0
First Language
English
Primarily Uses
Thank you everyone it works fine, if you could help me with my other problems in my other thread it would be much appreciated
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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.
 
Status
Not open for further replies.

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

Latest Threads

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,853
Messages
1,016,990
Members
137,562
Latest member
tamedeathman
Top