I know it's possible to link in-game steps to a variable, but can the variable be reset?

ddblue

新人
Veteran
Joined
Apr 9, 2013
Messages
137
Reaction score
20
First Language
English
Primarily Uses
Hey everyone.

I'm trying to create a flashlight / battery system.
I will decide the final values later, but for now I'd like a battery to go dead after 50 steps.
I've found several flashlight tutorials, but they're all frame based - I really want a step based system.

Here's how I did it:
1. Create 2 flashlight items, one uses a common event called Flashlight ON, the other uses one called Flashlight OFF.
2. Created 3 common events: Flashlight ON, Flashlight OFF, and Flashlight ON FORMULA.

Flashlight ON common event works as follows:

◆If:Flashlight OK to USE is ON
◆If:Battery ≥ 50
◆Text:None, Window, Bottom
: :The battery is dead.
◆Show Choices:Use a battery, Cancel (Window, Right, #1, #2)
:When Use a battery
◆If:Party has Battery
◆Change Items:Battery - 1
◆Control Variables:#0007 Battery = 0
◆Control Switches:#0014 Flashlight ON = ON
◆Change Items:Flashlight off - 1
◆Change Items:Flashlight on + 1
◆Plugin Command:Fire radius 150 #333333
◆Plugin Command:Flashlight on 8 20 #333333 1

:Else
◆Text:None, Window, Bottom
: :You are out of batteries.

:End

:When Cancel

:End

:End
◆If:Battery < 50
◆Plugin Command:Fire radius 150 #333333
◆Plugin Command:Flashlight on 8 20 #333333 1
◆Control Switches:#0014 Flashlight ON = ON
◆Change Items:Flashlight off - 1
◆Change Items:Flashlight on + 1

:End

:Else
◆Text:None, Window, Bottom
: :There is no need to use a flashlight here.

:End

Flashlight OFF common event works as follows:

◆Plugin Command:Flashlight off
◆Plugin Command:Light radius 120 #50a6ce
◆Change Items:Flashlight off + 1
◆Change Items:Flashlight on - 1
◆Control Switches:#0014 Flashlight ON = OFF

And finally, Flashlight ON FORMULA (which is a parallel process that only runs when #0014 Flashlight ON switch is on.

◆Control Variables:#0007 Battery = Steps
◆If:Battery ≥ 50
◆Change Items:Flashlight on - 1
◆Change Items:Flashlight off + 1
◆Wait:30 frames
◆Plugin Command:Flashlight off
◆Plugin Command:Light radius 120 #63cdff
◆Wait:30 frames
◆Text:None, Window, Bottom
: :The flashlight battery has gone dead.
◆Show Choices:Use a battery, Cancel (Window, Right, #1, #2)
:When Use a battery
◆If:Party has Battery
◆Change Items:Battery - 1
◆Control Variables:#0007 Battery = Random 0..5
◆Change Items:Flashlight off - 1
◆Change Items:Flashlight on + 1
◆Play SE:Equip1 (90, 120, 0)
◆Wait:20 frames
◆Plugin Command:Fire radius #333333
◆Plugin Command:Flashlight on 8 20 #333333 1

:Else
◆Text:None, Window, Bottom
: :You are out of batteries.
◆Control Switches:#0014 Flashlight ON = OFF

:End

:When Cancel
◆Control Switches:#0014 Flashlight ON = OFF

:End

:End

Ignore the plugin commands, they're not really related to this particular problem.

I've tried everything I can think of, but without resetting the player step variable to 0 at some point in this process, I can't make the batteries work. As soon as I link things to a variable that increases with player steps, it counts every step the player has taken since the beginning of the game, which is too much.

I'm sorry, I realize that's a lot to read - but is there anything I can do?

Thank you for your time.
 

Aoi Ninami

Veteran
Veteran
Joined
Sep 22, 2015
Messages
428
Reaction score
539
First Language
English
Primarily Uses
RMVXA
When you turn the flashlight on, store the number of steps so far in a variable, let's say InitialSteps. Then check whether Steps > InitialSteps + 50.
 

ddblue

新人
Veteran
Joined
Apr 9, 2013
Messages
137
Reaction score
20
First Language
English
Primarily Uses
Thank you for your reply, but I'm still not quite able to wrap my head around this.
Store the number of steps so far in a variable - by:

1. Creating a variable called InitialSteps
2. In the Flashlight ON common event, add ◆Control Variables:#0008 Initial Steps = Steps

It's the next part I'm not sure I understand how to implement :/
Would you mind telling me a little bit more? Sorry for the inconvenience :/
 

userlame

Veteran
Veteran
Joined
Nov 25, 2014
Messages
47
Reaction score
9
First Language
English
Primarily Uses
Maybe something like this? First it equals a variable (in this example 10) with player steps. Then it adds 50 to that. Then it turns on a self switch so it won't repeat it until you want to. Next, it equals another variable, 9, with player steps. And then, after 50 steps when variable 9 is equal to variable 10, you can make the battery go dead there. And whenever you want to reset it you just turn off self switch A and run it again.
 

Attachments

  • flashl.PNG
    flashl.PNG
    34.6 KB · Views: 23

ddblue

新人
Veteran
Joined
Apr 9, 2013
Messages
137
Reaction score
20
First Language
English
Primarily Uses
Hello.

While I do appreciate very much that you suggested a formula, I spent many an hour on trying to fit that into what I posted above and could not make it work. I tried so many different ways of adapting it that I don't even know which to post here.

I don't suppose you could give it to me in even more detail?

I apologize, I honestly had no idea a step system would be this difficult. I guess that's why there are 0 tutorials for them.
 

Latest Threads

Latest Posts

Latest Profile Posts

Doing RPG Maker News for 24th October 2021

I'm not sure how to do this so I'll just ask here, Wheres a good place to post your game (for free) once its done?
I don't know what I'm doing :D
So got my hearing tested to see if it was the cause of my mishearing what people say. Test showed no problems but talked with the doctor about anxiety and ADHD causing hearing issues and she agreed and also added that some people hear things differently. With my anxiety cause I am in fight or flight I pay attention to all the sounds in the area so body knows when react. Can't pay attention to one source.

Forum statistics

Threads
116,057
Messages
1,095,387
Members
151,417
Latest member
Coffeelake01
Top