ToggleTimer XP
by Kyonides
by Kyonides
Introduction
Do you want to be able to show or hide the default game timer?
Then don't wait anymore and start using my script right away!
It also includes a feature to let you set its horizontal alignment with ease.
Please read the embedded comments before using it.
The Script
Code:
# * ToggleTimer XP * #
# Scripter : Kyonides
# 2024-11-28
# This scriptlet allows you to show or hide the default timer.
# It lets you set its horizontal alignment as well.
# There are just 2 CONSTANTS that you need to configure here.
# Warning! 3 Methods Have Been Modified #
# Sprite_Timer: initialize & update
# Interpreter: command_124 (Control Timer)
# * Script Calls * #
# - Show Timer - #
# $game_system.show_timer = true
# - Hide Timer - #
# $game_system.show_timer = false
# - Align Timer - #
# Alignment Options: 0 or :left, 1 or :center & 2 or :right
# Example:
# $game_system.align_timer = :left
# OPTIONAL: Set Hidden Timer #
# hidden_timer(minutes, seconds)
module KTimer
DEFAULT_VISIBLE = true
# Alignment Options: 0 or :left, 1 or :center & 2 or :right
ALIGN_X = :right
end
class Game_System
alias :kyon_toggle_timer_gm_sys_init :initialize
def initialize
kyon_toggle_timer_gm_sys_init
@show_timer = KTimer::DEFAULT_VISIBLE
@align_timer = KTimer::ALIGN_X
end
attr_accessor :show_timer, :align_timer
end
class Sprite_Timer
def initialize
super
@width = 88
self.bitmap = Bitmap.new(@width, 48)
self.bitmap.font.name = "Arial"
self.bitmap.font.size = 32
refresh_align_x
self.y = 0
self.z = 500
update
end
def refresh_align_x
case @align_x = $game_system.align_timer
when 0, :left
self.x = 0
when 1, :center
self.x = 320 - @width / 2
when 2, :right
self.x = 640 - @width
end
end
def update
super
return unless $game_system.timer_working
self.visible = $game_system.show_timer
if $game_system.align_timer != @align_x
refresh_align_x
end
if $game_system.timer / Graphics.frame_rate != @total_sec
self.bitmap.clear
@total_sec = $game_system.timer / Graphics.frame_rate
min = @total_sec / 60
sec = @total_sec % 60
text = sprintf("%02d:%02d", min, sec)
self.bitmap.font.color.set(255, 255, 255)
self.bitmap.draw_text(self.bitmap.rect, text, 1)
end
end
end
class Interpreter
def command_124
if @parameters[0] == 0
$game_system.timer = @parameters[1] * Graphics.frame_rate
$game_system.timer_working = true
end
if @parameters[0] == 1
$game_system.timer_working = false
$game_system.show_timer = false
end
true
end
def hidden_timer(min, sec)
time = min * 60 + sec
$game_system.timer = time * Graphics.frame_rate
$game_system.timer_working = true
$game_system.show_timer = false
true
end
end
Terms & Conditions
Free for use in ANY game.
Due credit is acceptable.
Mention this forum as well.
That's it!
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE