Flash Light with Battery Timer

Hello Guys,


i need your help.


I want to create an script for which you need batterys to keep your flashlight alive.


There are 3 bars and every minute 1 bar is going down and if you have 0 bars left - the flashlight would not work.


I already have an script that you get the flashlight, but dont have a plan how to get the "battery script" working.


Any ideas?
This should be easily acheived via a common event.


You need a variable that will contain the duration of the battery. Set it to the duration you'd like to have when you first get the flashlight or when you get new batteries.


Then periodically decrease this variable via the common event if the flashight is active. (Do something like wait 60 frames, variable -=1 )


At certain threshold you can change the imagine that represent your battery bars: lets say you first set the variable to 180, you'd changes images at 120, 60 and 0 probably.


Then if the variable is 0, you make the flashlight disappear.


I don't know your light system so I can't say much about activating or deactivating the light but this should get you a simple battery system going.
got it thx

Original thread: https://forums.rpgmakerweb.com/threads/flash-light-with-battery-timer.63171/