Set varible to zero

Kazuki

Veteran
Veteran
Joined
May 22, 2013
Messages
109
Reaction score
7
First Language
English
Primarily Uses
I was wondering if there was a way to set a specific variable to zero. For example, for a puzzle you get one "Puzzle" variable when you interact with a switch there would be a total of four switches. This puzzle would be timed and if time ran out regardless of how many "Puzzle" variable you have it would reset the puzzle and drop the "Puzzle" variable to zero. Here's the conditional branch I tried with no sucess.

setting variable back to zero.JPG
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
Well, that won't work because it will only check if the variable is 2 or 3 if it is one, so that won't work. Just use one control variable statement and make the variable 0 with that.
 

Kazuki

Veteran
Veteran
Joined
May 22, 2013
Messages
109
Reaction score
7
First Language
English
Primarily Uses
Well, that won't work because it will only check if the variable is 2 or 3 if it is one, so that won't work. Just use one control variable statement and make the variable 0 with that.
Well, that won't work because it will only check if the variable is 2 or 3 if it is one, so that won't work. Just use one control variable statement and make the variable 0 with that.
What do you mean, you think you can post an example.
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
Your conditional branch works like this:

  • Check is variable is exactly 1. If not, do nothing.
  • If variable is exactly 1, take one away from the variable. Check if the variable is exactly 2. If not, do nothing.
  • If variable is exactly 2, take away two from the variable. Check is the variable is exactly 3. If not, do nothing.
  • If variable is exactly 3, take three away from the variable.

An easier way to do it is just

  • If variable is NOT 0, set variable to 0.
 

Tai_MT

Veteran
Veteran
Joined
May 1, 2013
Messages
5,472
Reaction score
4,859
First Language
English
Primarily Uses
RMMV
If you wanted to do it your way, you'd have to put the "check if variable is 2" or "check if variable is 3" OUTSIDE the "branch end" text so that it first checks for 1, then checks for 2, then checks for three, without being dependent on having the variable actually BE 1 before ever CHECKING for 2.  If your variable is 2 in your current form, it won't check for it, because your variable isn't 1 FIRST.

Basically, here's what you're doing:

"If variable is 1, reset variable to 0 and then check to see if the variable is 2".  Well, if you just reset your variable to zero, it isn't going to be two.  And if it was just checked to see if it was 1 (and not greater than 1) without putting in an "add 1 to variable", it won't ever be higher than 1.  On top of which, if your variable is 2 and never hit 1, it won't check for 2 because it first has to check for 1 instead.  You would have to include it right after where it says "branch end" instead of adding a conditional branch WITHIN the first conditional branch.  Though, your way might also work if you include your commands under the "else" case as well.  As in, if it's not 1, check for 2, if it's not 2, check for 3.  Else Case is really great for things like that.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,676
First Language
German
Primarily Uses
RMMV
I was wondering if there was a way to set a specific variable to zero. For example, for a puzzle you get one "Puzzle" variable when you interact with a switch there would be a total of four switches. This puzzle would be timed and if time ran out regardless of how many "Puzzle" variable you have it would reset the puzzle and drop the "Puzzle" variable to zero. Here's the conditional branch I tried with no sucess.
The answers above try to help you with that rather complex conditional structure, but why do you use that structure at all?

Why do you not simply set the variable to zero without checking for the value?

Just use "control Variable", select the variable you want to set, OPERATION = SET (instead of the SUB you're using) and CONSTANT = 0

Done
 

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

Latest Threads

Latest Posts

Latest Profile Posts

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD

Forum statistics

Threads
105,868
Messages
1,017,078
Members
137,580
Latest member
Snavi
Top