KModTimer XP
Version 1.0.0
by Kyonides
Introduction
This is a simple scriptlet that provides some extra features for your timer sprite like custom font name and size and even a colored background. The last feature can be deactivated as well.
XP Script
Code:
# * KModTimer XP * #
# Scripter : Kyonides Arkanthes
# v1.0.0 - 2023-05-02
# * Script Calls * #
# - Reset Timer's Setup
# $game_system.reset_timer
# - Change Timer's X Alignment - Positions: :left, :center or :right
# $game_system.timer_pos_x = X-Alignment
# $game_system.timer_font_name = "Font Name"
# $game_system.timer_font_size = Number
# $game_system.timer_font("Font Name", Number)
# - Change the Font Color
# $game_system.timer_font_color(Red, Green, Blue)
# $game_system.timer_font_color(Red, Green, Blue, Alpha)
# - Change the Background Color
# $game_system.timer_bg_color(Red, Green, Blue)
# $game_system.timer_bg_color(Red, Green, Blue, Alpha)
# - Toggle Background Color - Boolean: true or false
# $game_system.timer_use_bg = Boolean
module KModTimer
# Initial Values
FONT_NAME = "Arial"
FONT_SIZE = 32
# Color Ranges (0..255) [Red, Green, Blue, Alpha]
FONT_COLOR = [255, 255, 255, 255]
BG_COLOR = [0, 0, 0, 80]
USE_BG_COLOR = true
# Choose the Position: :left, :center or :right
POSITION_X = :left
# * End of Setup Section * #
extend self
attr_accessor :refresh
class TimerData
def initialize() reset_settings end
def reset_settings
@font_name = FONT_NAME.dup
@font_size = FONT_SIZE
@font_color = FONT_COLOR.dup
@bg_color = BG_COLOR.dup
@use_bg = USE_BG_COLOR
@pos_x = POSITION_X
end
attr_accessor :font_name, :font_size, :font_color
attr_accessor :bg_color, :use_bg, :pos_x
end
end
class Sprite_Timer
def initialize
super
@data = $game_system.timer_setup
self.bitmap = Bitmap.new(88, 48)
bg_setup
font_setup
update_position
self.y = 0
self.z = 500
update
end
def bg_setup
@bg_color = Color.new(*@data.bg_color)
end
def font_setup
font = self.bitmap.font
font.name = @data.font_name
font.size = @data.font_size
font.color.set(*@data.font_color)
end
def update_x
case @data.pos_x
when :left
self.x = 0
when :center
self.x = 320 - self.bitmap.width / 2
when :right
self.x = 640 - self.bitmap.width
end
end
def update_position
update_x
self.y = 0
self.z = 200
end
def redraw_backdrop
bm = self.bitmap
@data.use_bg ? bm.fill_rect(bm.rect, @bg_color) : bm.clear
end
def timer_text
min = @total_sec / 60
sec = @total_sec % 60
sprintf("%02d:%02d", min, sec)
end
def redraw
if KModTimer.refresh
KModTimer.refresh = nil
bg_setup
font_setup
end
redraw_backdrop
bm = self.bitmap
bm.draw_text(bm.rect, timer_text, 1)
end
def update_bitmap
if $game_system.timer / Graphics.frame_rate != @total_sec
@total_sec = $game_system.timer / Graphics.frame_rate
redraw
end
end
def update
super
self.visible = $game_system.timer_working
update_x
update_bitmap
end
end
class Game_System
alias :kyon_mod_timer_gm_sys_init :initialize
def initialize
kyon_mod_timer_gm_sys_init
@timer_setup = KModTimer::TimerData.new
end
def reset_timer
@timer_setup.reset_settings
end
def timer_pos_x=(new_x)
@timer_setup.pos_x = new_x
end
def timer_font(new_name, new_size)
KModTimer.refresh = true
@timer_setup.font_name = new_name
@timer_setup.font_size = new_size
end
def timer_font_name=(new_name)
KModTimer.refresh = true
@timer_setup.font_name = new_name
end
def timer_font_size=(new_size)
KModTimer.refresh = true
@timer_setup.font_size = new_size
end
def timer_font_color(red, green, blue, alpha=255)
KModTimer.refresh = true
@timer_setup.font_color = [red, green, blue, alpha]
end
def timer_bg_color(red, green, blue, alpha=255)
KModTimer.refresh = true
@timer_setup.bg_color = [red, green, blue, alpha]
end
def timer_use_bg=(bool)
KModTimer.refresh = true
@timer_setup.use_bg = bool
end
attr_reader :timer_setup
end
Terms & Conditions
Feel free to use it.
Optionally, you could include my nickname in your game credits.
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