How to add default variables?

Hey, so I'm trying to make a puzzle where there's 5 windows, and specific one's need to be open or closed to unlock a door. So it's fairly easy to add a variable to myself by interacting with the window and closing/opening it, but I want 2 of them to be correct by default. Meaning you don't have to interact with them to get their variable. But you can remove the variable if you open/close it when it needs to be the opposite. Problem is, you can't remove the variable when there's none there to begin with. So I need someway to add the variable when you walk into the room.

I tried making a parallel event, but that didn't work. And doing an autorun event just prevented me from moving. I also tried making a common event for it but that didn't work either. And the last thing I tried was giving myself the variable at the start of my game during the first event and that STILL didn't work. What other way is there?

Or maybe there's a much simpler solution to this.
Problem is, you can't remove the variable when there's none there to begin with.
every variable in the game is initialized as 0 when the save is created, they'll never hold a null value unless you intentionally set it as such for some reason. What values do you need your variables to be, and can you share a screenshot of your event handling this?
I'm rather confused by some of your terminology, because I don't really know what "get their variable," "remove the variable" and "add the variable" all mean. That makes it sound like every window has its own variable which is unnecessary and confusing.

Also, this:
I tried making a parallel event, but that didn't work. And doing an autorun event just prevented me from moving. I also tried making a common event for it but that didn't work either.

indicates that you need to read up on/do some more basic event tutorials. You should know the difference between a triggered event, parallel process, autorun event, and common event, and understand how they work and how to turn autoruns and parallels off.

I'm not saying that to be snobbish, like, "Well you should know this," but these are legitimately basic elements of RPG Maker's event system. 🙂

As far as your puzzle goes, you only need to use one variable. Create an autorun event in the room. Make it set your variable = 2, then set self switch A. Give it a second page that is entirely blank except for the condition of self switch A.

Then your window events presumably have two pages that toggle self switches to go from open to closed.

Put event commands on the wrong page so that it adds 1 to the variable before setting the switch. Similarly, the right page has the command to subtract 1 from the variable before turning the switch back.

When the variable = 5, the windows are in the correct combination.
every variable in the game is initialized as 0 when the save is created, they'll never hold a null value unless you intentionally set it as such for some reason. What values do you need your variables to be, and can you share a screenshot of your event handling this?

1697600333962.png

This is the event that's correct by default. So as you see interacting with and opening it when it should be closed is removing the variable that I'm trying to add. Because the variable is supposed to unlock this door's event

1697600678171.png

Now that I'm thinking about it though, I could do a 3rd variable that is one you don't want to have...like a negative variable you get for opening them...that could be an option. That way I shouldn't need a default variable, I just need to not have the bad variable
The way you're using variables is kind of wasteful - if you're only using two values like that, that's what switches are for.

Now that I'm thinking about it though, I could do a 3rd variable that is one you don't want to have...
Why? I described very procedurally in my previous post how you only need to use one variable. Not 5 and not...I'm not sure how you get 3 here, but not that 😛
View attachment 280476
This is the event that's correct by default. So as you see interacting with and opening it when it should be closed is removing the variable that I'm trying to add. Because the variable is supposed to unlock this door's event

View attachment 280477
Now that I'm thinking about it though, I could do a 3rd variable that is one you don't want to have...like a negative variable you get for opening them...that could be an option. That way I shouldn't need a default variable, I just need to not have the bad variable
i mean yeah, like Turan says, you're using variables in a binary state, which is what switches should be used for. You don't even need 5 switches, just have one variable, initialize it at the value of 2 or however many curtains start in the correct spot, and then on the open/close interaction just add or subtract 1 from the variable depending on if they're being moved into the correct or incorrect state. Then for your check you're only looking at if one variable equals 5, rather than if 5 variables/switches have the same value.
Okay, I'm grasping what you guys are saying now. Sorry, I took a break from this program for a while, so I'm super rusty with all this stuff.

The main reason why I can't do it all as one variable is cause there's 2 parts to the curtain. So when I change the bottom part where the variable is at, it has to change the top part as well. So I don't think that can work like that if there's one variable for everything.

Here's a picture of it to show you what I mean. The bottom part of the curtain is what I interact with, but the top part has to change for each one separately. I know there's a way to make an event 2 blocks big, but I remember reading that you need plugins for that.
1697602986689.png
Just use switches, then, and either manually check each switch with the built in conditional or use a script box to make it faster and more readable
you have two solutions here:
-one, leave everything as you designed it initially, but add a "Self-switch ON" at the end of your autorun, and a new page set to self-switch condition. That should break the loop.
-and two: for the curtains, leave the bottom part as interactable, and within that part add a set move route block targeted to the top part. Use that move route to change the sprite.
The main reason why I can't do it all as one variable is cause there's 2 parts to the curtain. So when I change the bottom part where the variable is at, it has to change the top part as well.
None of that has to do with your variable that you're using to track the puzzle. That has to do with events. You can make one event look at another event without using a global variable, but you don't need to:

I know there's a way to make an event 2 blocks big, but I remember reading that you need plugins for that.
No, you don't. Just take the 2-tile-high graphics for your window and use a free image editor to put it in the format of a character sheet (described in MV's instructions). Then you assign that image to the event and use a self switch to go between two pages with open and closed curtains.
Hmm, variables aren't really intended for the kind of puzzle you're making tbh. If you have a game element with only 2 states (open/closed, on/off, etc.) you'd be better off using switches instead.
If you need something to be on by default, set that switch on at the beginning of the game.

You can make as many events as you want be controlled by the same switch, so 2 curtain events for example can change their page by interacting with just the lower one.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-add-default-variables.162114/