I improved on it some, I separated updating the hud graphics from determining if it's a new hour (it was getting stuck in a loop before with two methods calling each other), and fixed the code that caused the clock sound effect ($game_system.se_play expects an RPG::Audio_File, not a sound name, so it crashed). It does update the hud on the map now. You still need to do something to make the hour change only occur at the initial change of an hour, not for the entire second following the change in time.
I also changed the indentation, it was hard to read :M
[rgss]#_______________________________________________________________________________
# MOG XAS Time Hud V1.0
#_______________________________________________________________________________
# By Moghunter, edited by Darkseed
#
#_______________________________________________________________________________
module XAS_TIME
# Variablen für Tag und Nacht
TAG = 16 #=600 Sekunden
NACHT = 17 #=420 Sekunden
TAGZ = 40 #Variable zum abfragen für den Updateprozess Tag
NACHTZ = 41 #Variable zum abfragen für den Updateprozess Nacht
#Position
XASTIME_X = 450
XASTIME_Y = -16
#ID vom Schalter der alles ausstellt
DISABLE_STATUS_TIME_SWITCH = 77
#HUD transparent machen bei Heldenkontakt
FADE = true
end
$mog_rgss_xas_time = true
#####################
# Window_Status_Map #
#####################
class Window_Time < Window_Base
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.windowskin = RPG::Cache.windowskin("")
self.contents.font.bold = true
self.contents.font.name = "Georgia"
self.opacity = 255
@old_day = $game_variables[XAS_TIME::TAGZ]
@old_night = $game_variables[XAS_TIME::NACHTZ]
refresh
end
def refresh(time_bitmap_name = "Uhr1")
self.contents.clear
draw_mapzeit(@actor, 0, 0, time_bitmap_name)
end
def update
if XAS_TIME::FADE == true
x = ($game_player.real_x - $game_map.display_x) / 4
y = ($game_player.real_y - $game_map.display_y) / 4
time_size_x = 184
time_size_y = 149
oc_range_x = time_size_x + XAS_TIME::XASTIME_X
oc_range_y = time_size_y + XAS_TIME::XASTIME_Y
if x < oc_range_x and x > XAS_TIME::XASTIME_X - 5 and
y > XAS_TIME::XASTIME_Y and y < oc_range_y
self.contents_opacity -= 10 if self.contents_opacity > 120
else
self.contents_opacity += 10 if self.contents_opacity < 255
end
end
@old_day = $game_variables[XAS_TIME::TAGZ]
@old_night = $game_variables[XAS_TIME::NACHTZ]
bitmap_name = update_time
if @old_day != $game_variables[XAS_TIME::TAGZ] or
@old_night != $game_variables[XAS_TIME::NACHTZ]
$game_system.se_play(RPG::AudioFile.new('033-switch02', 100))
refresh(bitmap_name)
end
end
def update_time
if $game_variables[XAS_TIME::TAG] == 1 and $game_variables[XAS_TIME::NACHT] == 0
bitmap_name = "Uhr1"
$game_variables[XAS_TIME::TAGZ] += 1
$game_variables[XAS_TIME::NACHTZ] = 0
elsif $game_variables[XAS_TIME::TAG] == 120 and $game_variables[XAS_TIME::NACHT] == 0
bitmap_name = "Uhr2"
$game_variables[XAS_TIME::TAGZ] += 1
elsif $game_variables[XAS_TIME::TAG] == 240 and $game_variables[XAS_TIME::NACHT] == 0
bitmap_name = "Uhr3"
$game_variables[XAS_TIME::TAGZ] += 1
elsif $game_variables[XAS_TIME::TAG] == 360 and $game_variables[XAS_TIME::NACHT] == 0
bitmap_name = "Uhr4"
$game_variables[XAS_TIME::TAGZ] += 1
elsif $game_variables[XAS_TIME::TAG] == 480 and $game_variables[XAS_TIME::NACHT] == 0
bitmap_name = "Uhr5"
$game_variables[XAS_TIME::TAGZ] += 1
elsif $game_variables[XAS_TIME::TAG] == 550 and $game_variables[XAS_TIME::NACHT] == 0
bitmap_name = "Uhr6"
$game_variables[XAS_TIME::TAGZ] += 1
elsif $game_variables[XAS_TIME::TAG] == 0 and $game_variables[XAS_TIME::NACHT] == 1
bitmap_name = "Uhr7"
$game_variables[XAS_TIME::NACHTZ] += 1
$game_variables[XAS_TIME::TAGZ] = 0
elsif $game_variables[XAS_TIME::TAG] == 0 and $game_variables[XAS_TIME::NACHT] == 84
bitmap_name = "Uhr8"
$game_variables[XAS_TIME::NACHTZ] += 1
elsif $game_variables[XAS_TIME::TAG] == 0 and $game_variables[XAS_TIME::NACHT] == 168
bitmap_name = "Uhr9"
$game_variables[XAS_TIME::NACHTZ] += 1
elsif $game_variables[XAS_TIME::TAG] == 0 and $game_variables[XAS_TIME::NACHT] == 252
bitmap_name = "Uhr10"
$game_variables[XAS_TIME::NACHTZ] += 1
elsif $game_variables[XAS_TIME::TAG] == 0 and $game_variables[XAS_TIME::NACHT] == 336
bitmap_name = "Uhr11"
$game_variables[XAS_TIME::NACHTZ] += 1
elsif $game_variables[XAS_TIME::TAG] == 0 and $game_variables[XAS_TIME::NACHT] == 420
bitmap_name = "Uhr12"
$game_variables[XAS_TIME::NACHTZ] += 1
else $game_variables[XAS_TIME::TAG] == 0 and $game_variables[XAS_TIME::NACHT] == 420
bitmap_name = "Uhr1"
end
return bitmap_name
end
def draw_mapzeit(actor, x, y, bitmap_name)
bitmapzi = RPG::Cache.picture(bitmap_name)
cw = bitmapzi.width
ch = bitmapzi.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents_opacity = 180
self.contents.blt(x , y , bitmapzi, src_rect)
end
end
###############
# Game_Player #
###############
class Game_Player < Game_Character
attr_accessor :wref
end
#############
# Scene_Map #
#############
class Scene_Map
alias mogtime_main main
def main
@sttime = Window_Time.new
@sttime.x = XAS_TIME::XASTIME_X
@sttime.y = XAS_TIME::XASTIME_Y
@sttime.z = 7901
if $game_switches[XAS_TIME::DISABLE_STATUS_TIME_SWITCH] == false
@sttime.visible = true
else
@sttime.visible = false
end
mogtime_main
@sttime.dispose
end
alias mogtime_update update
def update
if $game_switches[XAS_TIME::DISABLE_STATUS_TIME_SWITCH] == false
@sttime.visible = true
else
@sttime.visible = false
end
@sttime.update
mogtime_update
end
end
[/rgss]