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
132
Reaction score
16
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
413
Reaction score
512
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
132
Reaction score
16
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

ddblue

新人
Veteran
Joined
Apr 9, 2013
Messages
132
Reaction score
16
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.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

So, uh, has anyone tried buying any resources from KokoroReflections? Because I've been looking for a 'buy' button on the site for like 10 minutes now and can't find one.
Any also thought it's too cringy to put the word "and you" in your credit as a special thanks?
Cause that's what I thought...
Everyone in the US right now: Please stay safe.
Symphony Celestia: Prophecy of the Falling Stars RPG Maker music pack WIP. Symphony Celestia is a new series that focuses on symphonic and orchestrated music to tell a story. Each story will include compositions that make up that story from beginning to end. Themes include: Battles, adventures, character themes, etc. Below is a video preview to the first story.

Jumping and gravitation 0.1 build - RPG Maker MV

Forum statistics

Threads
97,979
Messages
948,298
Members
129,241
Latest member
LordCola
Top