How to use variables to make a "fuel" system?

Hi, this is my first post here, so apologies in advance if it's in the wrong place.

I'm currently making a SciFi Space game in RPG Maker MZ, and I want to have a rudimentary "fuel" system for the space ship. This is based on having a variable set up to equal 30% at the start of the game, and then to drop based on the number of steps the player takes. I've got the variables set up this way so far:

"Helium-3" set to 30

Then later,

"Helium-3 Loss" set to "Game Data" "steps"
"Helium-3 Loss" divided by 200
"Helium-3" subtract "Helium-3 Loss"

This does accomplish exactly what I want, and I have an event in a computer terminal where the player can check the fuel level. The problem I have is that every time the player checks the fuel level, the fuel level goes down. It's obvious to me why, but I can't figure out how to prevent it.

Has anyone tried to do something similar to this before? Is there a simpler or better way that anyone knows or can think of, including plugins?
Store the step value you've already subtracted, use 2 variables.

variable 2 = 'game data: steps'
variable 2 - variable 1
variable 2 / 200
helium - variable 2
variable 1 = 'game data: steps'
That works perfectly! Thank you so much. I was pulling my hair out trying to figure out how to preserve that data every time it was called. 🙂
Hi folks, sorry to be asking for more help with this particular issue again, but now I need help with how to "stop" calculating the fuel drain when the player leaves the space ship. (I've got dyscalculia and the arithmetic involved is melting my brain.)

I'm thinking about two approaches to this problem. First, inside the event when the player exits the space ship, I would create a variable to store how much Helium-3 fuel is currently onboard at the time of exit. When the player boards the ship and checks the fuel again, the amount in that variable will be added to the amount of fuel after the "steps" calculation which I already received help with above.

or...

When the player exits the space ship, the number of steps is instead stored in a variable. When the player returns to the ship and checks the fuel level, then a calculation is made to subtract the difference between the number of steps taken while away from the ship while calculating the amount of fuel used.

I don't know which of these two approaches is right or will work best, and I really don't know exactly how to implement either one of them. Thank you again if someone can provide some detailed help to me.
I cannot write the code for it but I can see a way to make this work.


Method - Logic Using an IF statement for if in the spaceship

variable: Shipstate ( 0 or 1)
variable: SpaceSteps (# steps since entering the ship)
variable: EntryStepCount (# of total steps when player entered the ship)


IF the player is in a space ship ShipState=1 (true):else ShipState=0 (false)
IF Shipstate=0 EntryStepCount= 'game data: steps' : else SpaceSteps = 'game data: steps' - EntryStepCount


This captures the stepcount when entering a spaceship. Then it subtracts this captured stepcount # from the game's Steps total to store the difference as a running total of SpaceSteps, which you can use for fuel calculations.
Thanks for this advice. I'll try working with it when I get back to working on the fuel calculations.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-use-variables-to-make-a-fuel-system.175285/