Help with variables

Cejmr5_AJ :D

Villager
Member
Joined
Nov 13, 2016
Messages
15
Reaction score
1
First Language
English
Primarily Uses
So, in my game I want to make it so that every time a certain switch is turned on, the value of a variable increases by 1. Does anyone know how to do this? I've tried and I haven't gotten far. Thanks. :)

EDIT: Oh, forgot to mention originally that I'm looking to find a way to make a variable still be increased from when the switch was on, even if it's off.
 
Last edited:

Guiguimu

Walking Disaster
Veteran
Joined
Oct 1, 2015
Messages
606
Reaction score
7,279
First Language
Portuguese
Primarily Uses
RMVXA
With a conditional branch you can do that easily. Simply create a conditional branch like this:


this way when that switch timer is on, the variable Car will increase by 1 (this is just an example)

Then it depends much on what you intend to do. If you want this in an event with parallel process you need to create another switch or self-switch so it will not be constantly adding 1 to that variable since said switch will still be on.

Hope this helps and someone correct me if I am wrong XD
 

Attachments

Cejmr5_AJ :D

Villager
Member
Joined
Nov 13, 2016
Messages
15
Reaction score
1
First Language
English
Primarily Uses
Yea, I've been trying this, and it hasn't worked; If you use the \v[n] command in a text box, it will tell you the value of a variable, and all it says for me is 0. I probably should've mentioned this earlier, but I'm looking to find a way to make a variable still be increased from when the switch was on, even if it's off. Thanks for trying to help, though!
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
1,483
Reaction score
986
First Language
English
Primarily Uses
It might be better to explain what it is you're trying to do, rather than how you're trying to do it. What is this supposed to accomplish?
 

Guiguimu

Walking Disaster
Veteran
Joined
Oct 1, 2015
Messages
606
Reaction score
7,279
First Language
Portuguese
Primarily Uses
RMVXA
Could you explain a little more, please? Or maybe a screenshot of your actual event?
Because I don't understand what you are trying to do or how...
 

Cejmr5_AJ :D

Villager
Member
Joined
Nov 13, 2016
Messages
15
Reaction score
1
First Language
English
Primarily Uses
Sure, sorry for the confusion.

I'm trying to make it where the player goes to "sleep", and each time they do at the end of the day, a switch turns on, and I'm trying to make it so that when that switch is on, the value of the variable I have labeled "days" increases by 1. Hope that helps.

EDIT: Oh, and the switch sleep turns off by the next day.
 

White Flare

Villager
Member
Joined
Mar 23, 2016
Messages
20
Reaction score
5
First Language
English
Primarily Uses
Sure, sorry for the confusion.

I'm trying to make it where the player goes to "sleep", and each time they do at the end of the day, a switch turns on, and I'm trying to make it so that when that switch is on, the value of the variable I have labeled "days" increases by 1. Hope that helps.

EDIT: Oh, and the switch sleep turns off by the next day.
So I'm working on a game where every night the player goes to sleep they end up in a dream world, then when they wake up it counts the day up, if they return to the house the switch is still on because they haven't gone back to sleep so it doesn't trigger every time they walk in the room until they sleep and wake up again. It sounds like my 3 events may be helpful so I'll post them up for you.

 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
29,230
Reaction score
6,775
First Language
German
Primarily Uses
RMMV
Yea, I've been trying this, and it hasn't worked; If you use the \v[n] command in a text box, it will tell you the value of a variable, and all it says for me is 0.
Then you made a mistake in your events somewhere.
The example to which you answered WILL work, and if it doesn't for you then something in your event was done in the wrong way.
Please post a screenshot of your event page(s) and we can tell you where you made your mistake.
 

Celianna

Tileset artist
Global Mod
Joined
Mar 1, 2012
Messages
10,535
Reaction score
5,541
First Language
Dutch
Primarily Uses
RMMV
That event won't run just because you turned on that switch :p there is no condition for it to run if that switch is on - see the left side of the event screen? You would need to select that switch of yours there, and then set the event to autorun, and don't forget to turn it off either, since it'll loop with an autorun.

In fact, why does it need to be a separate event in the first place? You can simply .. fade the screen, add +1 to variable Days, and fade the screen back in - no need for a switch either.

But if you're trying to do a day & night system, then I suggest using common events for this. Create a new common event, call it "New Day" or whatever. In this common event, add in everything you want to happen when the player has gone to sleep (don't add in a fade!), such as increasing the variable Days.

Then, in the event that asks if you want to sleep, and the player selects yes, fade out the screen, and call common event New Day, fade the screen back in. Tada ~ a new day, and you can always go back to your common event and edit it with new stuff, and the sleep event does not need to be edited.

Mostly though, you need some beginner guides!
 

Guiguimu

Walking Disaster
Veteran
Joined
Oct 1, 2015
Messages
606
Reaction score
7,279
First Language
Portuguese
Primarily Uses
RMVXA
Yes, like Celianna said, the event does not process because the trigger you have doesn't allow it. You need to check the triggers, and be sure that they will activate accordingly with your needs. So, if it is action button, it will only start if the player activates it. I also agree with Celianna, you don't need to have another event for this one, you can add it in the current event of sleeping. And that would even prevent the need of creating the switch sleep, because it wouldn't do anything. Which saves you a switch for another thing!
https://forums.rpgmakerweb.com/index.php?threads/conditions-triggers-and-event-pages.15098/
Check out this tutorial of GrandaDeb, it's great to learn new things, even if you think you know it already. And if you do, think of it as a little study!
http://blog.rpgmakerweb.com/tutorials/understanding-common-events/
This one is about common events, like Celianna suggested, a common event is the best way to go.
Hope this helps you somehow...
 

Cejmr5_AJ :D

Villager
Member
Joined
Nov 13, 2016
Messages
15
Reaction score
1
First Language
English
Primarily Uses
Oh, I see what I was doing wrong. Thanks a bunch for helping me, guys!!! :)
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Coffee + Silk Coconut Milk + Splenda Zero = Not ..... awful :/ .
My new RPG Maker music pack, Emotional: Redemption, is now in progress and will be coming to RPG Maker soon. It is an album that focuses on emotional themes including the darker forms of sorrow and despair. Below is a demo of a composition from the album.

Please watch out for your hands when handling chests! XD Did this a few days ago, it was fun to animate

Apparently, it's illegal to be drunk on licensed premises: pubs, etc. It's illegal for keepers of public houses to permit drunkenness and disorderly conduct. lol.
Pillow Hero - A 16-bit arcade styled puzzle game, update 0.5 is live now on Itch.io! --> https://bifrost09.itch.io/pillow-hero

Forum statistics

Threads
94,437
Messages
920,906
Members
124,241
Latest member
toanbeokame
Top