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

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:

Spoiler
◆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:

Spoiler
◆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.

Spoiler
◆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.
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.
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 :/
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.
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.

Original thread: https://forums.rpgmakerweb.com/threads/i-know-its-possible-to-link-in-game-steps-to-a-variable-but-can-the-variable-be-reset.96116/