Simple Counter Display

I have a minigame and I want to make it so that you only have so many turns. I would like to be able to have a display running during the game to show how many turns you have left. I'm thinking just a small window in one of the top corners that shows the number of turns left and changes as the variable that holds the number of turns changes.

I have searched and can't seem to find what I am looking for it, but if it's out there great. If not and someone would like to help create this for me, I would be very grateful. Thank you in advance!

And if you do want to do it and need more information, please just let me know what.
Wouldn't a simple display picture event work? each time the variable changes the number of turns on the picture counts up or down.
I'm to lazy to write this(give me a sec), but couldn't you just make a script that would create a window (at 0,0 or the left hand corner) whose text shows a variable corresponding to the turns remaining ?
@Reiker - I thought about that. But then, wouldn't I have to make and upload all of those different pictures? And for this particular game it will likely take more than 20 turns. If I do more challenging levels, possibly 30, 40, etc. That's a lot of little pictures to make, save, load and then display. It seemed to me it would be much simpler to have a bit of code that creates a small window that displays text. Maybe I'm wrong though. Hopefully a scripter will chime in.

@Ruiran - Well, I'm hoping that someone simply can but no, I do not know enough about scripting to do this. At least, I don't think I do. If I thought I could, I would have done it.
module mlogan def self.create $spr = Sprite.new(Viewport.new) $spr.x = 0 $spr.y = Graphics.width-32 #for example $spr.bitmap = Bitmap.new(Graphics.height,Graphics.width) $spr.bitmap.draw_text(0,0,32,32,"Initial turn count here") end def self.adjust(value) $spr.bitmap.clear $spr.bitmap.draw_text(0,0,32,32,value.to_s) end def self.clear spr.bitmap.clear endendso just call mlogan.create at the start (then possibly call mlogan.clear in case you don't need it yet)then just call mlogan.adjust(value) when you want to show a new value

Note though that this is a basic show text method, there will be no window backgrounds
First, thanks Engr!

Second, I stuck it under Materials, like I have with other scripts. I am getting this error, upon game start (don't even make it to the menu).

d76s7sf.png


I do have other scripts, could they possibly be interfering? If not, what am I doing wrong?
First, thanks Engr!

Second, I stuck it under Materials, like I have with other scripts. I am getting this error, upon game start (don't even make it to the menu).

d76s7sf.png


I do have other scripts, could they possibly be interfering? If not, what am I doing wrong?
I'm not sure but try replacing mlogan with Mlogan or MLOGAN
@Ruiran - Thanks, the capital M did the trick for whatever reason.

However, I'm not getting it to display. I'm sure it's just my ignorance. I changed "Initial Turn Count Here" to "25". I then created a parallel process event triggered by a switch that has the script call Mlogan.create. I tested it and even with the switch is definitely triggered, there it no display shown.

Is there more I need to customize so that it shows?
ah yes, it should at least start with a capital letter... sorry... 🙂 \


try adding this to the create method


$spr.z = 400
Still nothing. Just to clarify, this is how I called the script. Yes? Or totally wrong?

ScriptError2.png
oh wait, my formula is wrong... silly me


it should be


$spr.x = Graphics.width - 32


$spr.y = 0


right now, it tries to show at y = 544-32 => 512, while the maximum height of the window is just 416... 🙂


btw, you can adjust the .x and .y lines to fit your needs
Yay, that did it! I figured those were the display position values, but I didn't want to mess with them until it showed up first.

Now, hopefully last question. Is there a way to show the value of a variable in "Initial turn count" spot? I know in text input you would use \V or whatever. Can something similar be done here?
replace the "INITIAL VALUE HERE" with $game_variables[iD].to_s, ID being the id of the game variable


for the adjust(value), just remove the to_s part


so like


Mlogan.adjust($game_variables[iD])
Sweet! Working beautifully! Thank you so much!

This can be closed now.
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/simple-counter-display.25285/