Global Day-and-Night System for RMX-OS
Authors: Blizzard
Version: 1.2
Type: RMX-OS plugin
Key Term: RMX-OS Plugin
IntroductionThis script utilizes ATES to allow a serverside globally controlled Day-and-Night System in the game
This script is to be distributed under the same terms and conditions like the script it was created for: RMX-OS.
Features
- easy to configure
- globally controlled time
ScreenshotsN/A for this sort of script.
DemoN/A
ScriptJust make a new script above main and paste this code into it.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Global Day-and-Night System for RMX-OS by Blizzard
# Version: 1.2
# Type: RMX-OS Add-on
# Date: 28.12.2009
# Date v1.01: 3.1.2010
# Date v1.02: 23.4.2010
# Date v1.03: 24.5.2010
# Date v1.1: 14.3.2013
# Date v1.11: 30.3.2013
# Date v1.2: 12.6.2013
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# This script is to be distributed under the same terms and conditions like
# the script it was created for: RMX-OS.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Information:
#
# This script must be placed below RMX-OS and requires RMX-OS to work
# properly. This script utilizes ATES to allow a serverside globally
# controlled Day-and-Night System in the game and requires ATES. It must be
# placed below ATES.
#
# Notes:
#
# - Adding this script can cause save data corruption in the server's
# database.
# - This is only a global day and night system that counts the time. Calender
# features will work, but nothing else will.
# - You can't use [] for the START configuration, you have to set up a start
# date, because the weekday is important.
#
#
# If you find any bugs, please report them here:
# http://forum.chaos-project.com
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
if !defined?(RMXOS) || RMXOS::VERSION < 2.0
raise 'ERROR: The "Global DNS" requires RMX-OS 2.0 or higher.'
elsif !$ates || $ates < 1.01
raise 'ERROR: The "Global DNS" requires ATES 1.01 or higher.'
end
$rmxos_gdns = 1.2
#==============================================================================
# module RMXOS::Options
#==============================================================================
module RMXOS::Options
# additional ATES settings that should be stored
SAVE_DATA[Game_System].push('@ates')
SAVE_DATA[Game_System].push('@show_clock')
SAVE_DATA[Game_ATES] = ['@active']
SAVE_DATA[Game_ATES] = ['@tinting']
SAVE_DATA[Game_ATES] = ['@time']
SAVE_DATA[Game_ATES] = ['@weather']
SAVE_DATA[Game_ATES] = ['@frame_count']
SAVE_DATA[Game_ATES] = ['@current_times']
SAVE_DATA[Game_ATES] = ['@tone']
SAVE_DATA[Game_ATES] = ['@map_type']
SAVE_DATA[Game_ATES] = ['@show_weather']
SAVE_DATA[Game_ATES] = ['@terrain']
SAVE_DATA[Game_ATES] = ['@temp']
SAVE_DATA[Game_ATES] = ['@holiday']
SAVE_DATA[Game_ATES] = ['@time_index']
end
#==============================================================================
# RMXOS::Network
#==============================================================================
class RMXOS::Network
alias check_game_gdns_later check_game
def check_game(message)
if message =~ /\AGDNS\t(.+)\t(.+)\t(.+)\t(.+)/
if $game_system != nil && $game_system.ates != nil
day = $1.to_i
month = $2.to_i
year = $3.to_i
time = $4.to_i
hour_length = ATES::LENGTH / 24.0
hours = (hour_length > 0 ? (time / hour_length) : 0)
minute_length = hour_length / 60.0
minutes = (minute_length > 0 ? (time / minute_length) : 0)
$game_system.ates.time = ATES::Time.new(0, 0, day, month, year, ATES::START[3])
ATES.advance(minutes, 0, 0, 0, 0)
end
return true
end
return check_game_gdns_later(message)
end
end
#==============================================================================
# Game_ATES
#==============================================================================
class Game_ATES
alias init_gdns_later initialize
def initialize
init_gdns_later
@tinting = true
@active = true
if $game_system != nil && $game_system.ates != nil
@time = $game_system.ates.time
end
end
def update # prevent ATES from updating in-game and messing up everything
end
end
Make a new file with an
.rb extension in the
Extensions folder of RMX-OS and copy-paste this script into it.
module RMXOS
def self.load_current_extension
return GlobalDNS
end
module Data
GlobalDNSTimeNow = ' > Global DNS Current Time: TIME'
end
end
#======================================================================
# module GlobalDNS
#======================================================================
module GlobalDNS
VERSION = 1.2
RMXOS_VERSION = 2.0
SERVER_THREAD = true
# START Configuration
MIDNIGHT_TIME = 0 # seconds after midnight when in game midnight starts (between 0 and 86400, use a divider of LENGTH!)
UPDATE_INTERVAL = 1 # how often is time data sent to clients (lower values can increase server load!)
# make sure THESE variables match the ones in the ATES script)
LENGTH = 144 # how many seconds does a full day take (between 24 and 86400, use a divider of 86400!)
START = [24, 11, 2007] # the first day in the game [DAY, MONTH, YEAR] set this option to [] if you want the game to start "now"
# END Configuration
def self.initialize
@mutex = Mutex.new
@client_times = {}
@server_start = Time.now
@start_time = START.clone
if START.size != 3
time = Time.utc(START[2], START[1], START[0])
@start_time = [time.day, time.month, time.year]
end
self.update_time
puts RMXOS::Data.args(RMXOS::Data::GlobalDNSTimeNow, {'TIME' => self.time_to_timestring})
end
def self.mutex
return @mutex
end
def self.main
while RMXOS.server.running
@mutex.synchronize {
self.server_update
}
sleep(0.1)
end
end
def self.server_update
self.update_time
logged_in_clients = RMXOS.clients.get
time = Time.now
@client_times.each_key {|client|
if time - @client_times[client] > UPDATE_INTERVAL
self.send_time(client, time)
end
}
(@client_times.keys - logged_in_clients).each {|key| @client_times.delete(key)}
(logged_in_clients - @client_times.keys).each {|key| @client_times[key] = time}
end
def self.client_update(client)
case client.message
when /\ALRQ\Z/, /\AENT\Z/, /\AMEX\Z/ # send DNS time on load request, enter server and exit map
self.send_time(client)
end
return false
end
def self.send_time(client, time = Time.now)
begin
client.send('GDNS', @start_time[0], @start_time[1], @start_time[2], (@time + MIDNIGHT_TIME).to_i)
@client_times[client] = time
rescue
@client_times.delete(client)
end
end
def self.update_time
@time = Time.now - @server_start
end
def self.time_to_timestring(time = @time)
hour_length = LENGTH / 24.0
hours = (hour_length > 0 ? (time / hour_length) : 0)
minute_length = hour_length / 60.0
minutes = (minute_length > 0 ? (time % hour_length / minute_length) : 0)
return sprintf('%02d:%02d', hours.to_i, minutes.to_i)
end
end
InstructionsIn the script in the first comment.
CompatibilityRequires RMX-OS to work.
Requires ATES to work.
Credits and Thanks
Author's NotesIf you find any bugs, please report them here:
http://forum.chaos-project.com
That's it! N-Joy! =D
darn you beat me to it :P.
oh well i bet you did it better anyway
:bow: this is great!! :bow:
ATES for RMX-OS
I failed big time trying to get ATES to work on my game :P
Lol! I made this for Auspiex. There will be another few scripts/RMX-OS plugins coming which I will make because of Auspiex.
EDIT: And the add-ons are always so small. :3
v1.01 is out. It works properly with RMX-OS v1.08.
Is there a way to make a 12 hour clock instead of a 24 hour?
Why would somebody want that? Yes, you can do that by changing the 24.0 in line 61 to 12.0.
Quote from: Blizzard on February 05, 2010, 10:42:21 am
Why would somebody want that? Yes, you can do that by changing the 24.0 in line 61 to 12.0.
Ummm, because its easier on my eyes so i don't have to remember 24 hour clock. and easier for people who don't know 24 hour clock lol. And easier to coordinate events on the server lol
(EDIT: Ok now im really confused i changed the 24.0 to 12.0 it was actually line 60 but now its either saying its 5:16 in the morning at night not sure lol. but the server is 10:34 lol so yea im mad confused.)
My bad. >.<
Don't worry if there's a line mismatch. It's probably because of the config or something else.
Anyway, change the 12.0 back to 24.0. Find this line (should be 64):
$game_system.ates.time = ATES::Time.new(minutes.to_i, hours.to_i)
Change it to this:
$game_system.ates.time = ATES::Time.new(minutes.to_i, hours.to_i % 12)
So I'm pretty sure the problem is coming from this. Anyway, when I go to start a game before anything else, the screen turns solid Yellow and all I can see is the chat box, my name, and the clock. I turn on ATES and to get rid of the yellow I need to turn ATES.tint_off, and while it fixes it, I'd rather like to have a distinguishable difference between night and day.
That can only happen if you didn't configure everything properly.
What exactly do I need to do in configuration? My script setup is as follows:
RPG Maker defaults
ATES
RMX-OS Options
RMX-OS Script
RMX-OS ATES Plugin
RMX-OS Main
I've got the extension file saved in extensions as a .rb, it comes up as open with Ruby so that's saved correctly and I've got it included in the extentions box on the RMX-OS GUI. I changed the time settings in ATES to reflect that of an entire day but for some reason only the minutes show up on the clock and the hour is just 00.
Quote
ATES
RMX-OS Options
RMX-OS Script
RMX-OS ATES Plugin
RMX-OS Main
Thats your problem right there. ATES needs to go under RMX-OS Script. and the ATES Plugin under ATES so should look like this
Quote
RMX-OS Options
RMX-OS Script
ATES
RMX-OS ATES Plugin
RMX-OS Main
Hope that helps. I fixed the yellow for me. Still trying to get the right time lol. for some reason when i change it to 12 hour clock its way to early or late as in at 12 it mid night and midnight is noon lol
Well, changing the script order to that did nothing...
Well thats what fixed my yellow.
also are you running the event that calls the script as auto run or parallel? maybe thats what fixed mine. although i changed both at the same time so im not sure what one fixed it make sure its not auto run event calling the ates system.
I have it run as Parallel Process, but regardless of whether or not I even turn it on, it starts out yellow and stays yellow, I even do the ATES.make_it_night call and it just flashes the night color and goes back to yellow. The only fix I've found was using ATES.tint_off but that kind of makes the whole system lame if I have a clock but nothing to actually distinguish day from night.
did you make sure to erase the parallel event?
ie
ATES.method_call
Erase Event
other wise the parallel process event loops and keeps calling ATES.method_call every frame.
Yes, I've tried it with and without erasing, I've also tried it as an action button event, ie talking to an NPC, but I still get no difference.
weird...
It can only be yellow if your server configuration is not matched with the game configuration, that's what I was trying to say. -_-
So I delved into the extensions file and changed the time to match the time I have set up so now it at least goes to night when it's supposed to, but the Yellow was still there, so I went and adjusted the tone code to account for the much larger variables. So now it has the exact time as on my computer, unless I click outside the window and let it run, but when it gets to day time which is set at 8am it just keep increasing the yellow color rather than stopping and then just goes to dark at 20 when night starts.
Sorry, I can't replicate the bug. As I said, the only way I could expect this would be if you didn't match the DAY_LENGTH option in the extension and the LENGTH option in the client.
All I did to get it was set the Length of the day in both codes to 84600, if you still can't replicate it I'll upload a demo.
Also, now it would appear that it is only in the ATES script, as I made another test game, put in the script right from where I copied it with 36 second days and it worked fine, then I kicked it up to 84600 second days, used the advance code to go forward an hour each time and as soon as it gets to 8, which is set to be the start of day at 28800 seconds, the screen progressively turns more and more yellow until 20 which is night at 72000 seconds and it changes back to just being dark.
If I leave the tone changing code alone, the get_day/night_tint, the screen stays yellow the whole time, but if I change the variables it uses, day and night, to their values / 3600, which would put them back to what they'd be in the 36 second day instance, then it will properly show night, but day is still just all yellow.
EDIT: Oh god, I hope it's not just me having used 84600 instead of 86400... I could've sworn I had it right... Won't know for another 6 hours.
It's 86400.
EDIT: Yeah.
Ok so, I've arrived home, and I tested the script, I changed the number to 86400. It's also set to that in the extensions file. Now, without the dividing by 3600 in the tint part, I still get a yellow screen regardless of the time. With the division, I get night time and a day that gets to about full yellow in 3 hours.
Here are the scripts I have:
Normal ATES, not the plugin
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Advanced Time and Environment System (ATES) by Blizzard
# Version: 0.4
# Type: Autonomous Timeflow and Environment Controller
# Date v0.3: 11.3.2008
# Date v0.31: 8.4.2009
# Date v0.32: 13.4.2009
# Date v0.33: 4.5.2009
# Date v0.34: 5.5.2009
# Date v0.4: 28.12.2009
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# This work is protected by the following license:
# #----------------------------------------------------------------------------
# #
# # Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# # ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# #
# # You are free:
# #
# # to Share - to copy, distribute and transmit the work
# # to Remix - to adapt the work
# #
# # Under the following conditions:
# #
# # Attribution. You must attribute the work in the manner specified by the
# # author or licensor (but not in any way that suggests that they endorse you
# # or your use of the work).
# #
# # Noncommercial. You may not use this work for commercial purposes.
# #
# # Share alike. If you alter, transform, or build upon this work, you may
# # distribute the resulting work only under the same or similar license to
# # this one.
# #
# # - For any reuse or distribution, you must make clear to others the license
# # terms of this work. The best way to do this is with a link to this web
# # page.
# #
# # - Any of the above conditions can be waived if you get permission from the
# # copyright holder.
# #
# # - Nothing in this license impairs or restricts the author's moral rights.
# #
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Compatibility:
#
# 99% compatible with SDK v1.x. 90% compatible with SDK 2.x. WILL corrupt old
# savegames. Can cause incompatibilty issues with DNS-es.
#
#
# Features:
#
# - complete control over and easy manipulating of time
# - nice day and night tinting
# - HUD clock optional
# - easier to control and more powerful than DDNS
#
#
# IMPORTANT NOTES:
#
# - This system has a working preconfiguration, be aware that a custom setup
# will need you to understand what each option does, so please read the
# configuration instructions.
# - Why does this system use switches to determine whether it's day or night?
# Simple: You can use conditions in enemy attacks to determine whether an
# attack should be used only at night or only at day.
#
#
# Instructions:
#
# - Explanation:
#
# This Time System will make your game have daytime and nighttime periods.
# The screen will be tinted accordingly. You can set up the length of the
# day. Other features are explained below. Please be sure to configure this
# system appropriately.
#
#
# - Basic manipulation of ATES:
#
# This system is based upon your eventing. It will work basically if you
# want, but with a little bit of using the "Call Script" event command you
# are able to control this system fully. You can call following commands:
#
# ATES.on
# Turns ATES on.
#
# ATES.off
# Turns ATES off.
#
# ATES.tint_on
# Turns ATES's screen tinting on.
#
# ATES.tint_off
# Turns ATES's screen tinting off.
#
# ATES.clock_on
# Turns ATES's clock display on.
#
# ATES.clock_off
# Turns ATES's clock display off.
#
# ATES.active?
# Returns true if ATES is turned on, otherwise false.
#
# ATES.tinting?
# Returns true if ATES tinting is turned on, otherwise false.
#
# ATES.day?
# Returns true if it's day, otherwise false. Alternatively you can check the
# assigned switch instead.
#
# ATES.night?
# Returns true if it's night, otherwise false. Alternatively you can check
# the assigned switch instead.
#
# ATES.advance(M, H)
# This will make the time advanced by M minutes and H hours. Any negative
# value used will cancel the execution of this command.
#
# ATES.make_it_day
# This is a feature from DDNS which allows you to quickly jump to the
# daytime.
#
# ATES.make_it_night
# This is a feature from DDNS which allows you to quickly jump to the
# nighttime.
#
#
# - Enhancement hints:
#
# If you wish to implement the DDNS further into your game and e.g. allow
# different behavious of monsters during day and night, you only need to
# check the the state of the appropriate switch. e.g. If NSWITCH is turned
# on inflict "Sleep" on one enemy.
#
#
# Additional info:
#
# The daytime and nighttime tintings were tested appropriately and optimal
# tinting is being used.
# Keep in mind that ATES is initially turned off, you need to turn it on by
# using the ATES.on and ATES.tint_on commands together.
#
#
# If you find any bugs, please report them here:
# http://forum.chaos-project.com
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
module ATES
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# switch ID of the "day" switch
DSWITCH = 51
# switch ID of the "night" switch
NSWITCH = 52
# length of a day in seconds in-game, can't be less than 36, is being
# quantized into intervals of 36 seconds
LENGTH = 86400
# how much time is it when the "day" starts
DAY_START = 28800
# how much time is it when the "night" starts
NIGHT_START = 72000
# makes the screen brighter during "summer" days
OVERLIGHTING = true
# makes the screen darker during the night, not recommended
OVERDARKENING = false
# display HUD clock
SHOW_CLOCK = true
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
$ates = 0.4
#============================================================================
# ATES::Time
#============================================================================
class Time
attr_accessor :hour
attr_accessor :min
def initialize(m = 0, h = 0)
@hour, @min = h, m
end
end
def self.on
$game_system.ates.active = true
return true
end
def self.off
$game_system.ates.active = false
return true
end
def self.tint_on
$game_system.ates.tinting = true
return true
end
def self.tint_off
$game_system.ates.tinting = false
return true
end
def self.clock_on
$game_system.show_clock = true
return true
end
def self.clock_off
$game_system.show_clock = false
return true
end
def self.active?
return $game_system.ates.active
end
def self.tinting?
return $game_system.ates.tinting
end
def self.day?
$game_system.ates.day?
end
def self.night?
$game_system.ates.night?
end
def self.make_it_day
$game_system.ates.time.hour = DAY_START
$game_system.ates.time.min = 0
return true
end
def self.make_it_night
$game_system.ates.time.hour = NIGHT_START
$game_system.ates.time.min = 0
return true
end
def self.day_start
return DAY_START
end
def self.night_start
return NIGHT_START
end
def self.advance(m = 1, h = 0)
return false if m < 0 || h < 0
h += ($game_system.ates.time.min + m) / 60
$game_system.ates.time.hour = ($game_system.ates.time.hour + h) % 24
$game_system.ates.time.min = ($game_system.ates.time.min + m) % 60
return true
end
end
if ATES::DAY_START > ATES::NIGHT_START
raise 'ATEScfgError: A night can\'t start earlier than a day.'
elsif ATES::LENGTH < 36
raise 'ATEScfgError: A day\'s length must be equal to or greater than 36 seconds!'
end
#==============================================================================
# Game_System
#==============================================================================
class Game_System
attr_accessor :ates
attr_accessor :show_clock
alias init_ates_later initialize
def initialize
init_ates_later
@ates = Game_ATES.new
@show_clock = ATES::SHOW_CLOCK
end
end
#==============================================================================
# Game_ATES
#==============================================================================
class Game_ATES
attr_accessor :time
attr_accessor :frame_count
attr_accessor :active
attr_accessor :tinting
def initialize
@time = ATES::Time.new(0, 0)
@frame_count = 0
@active = false
@tinting = false
end
def update
if @active
update_progress
update_ates_progress
end
update_switches
update_screen
end
def update_progress
@frame_count += 1
end
def update_ates_progress
ATES.advance if @frame_count % (ATES::LENGTH / 36) == 0
end
def update_switches
if ATES.day?
$game_map.need_refresh = true if $game_switches[ATES::NSWITCH]
$game_switches[ATES::DSWITCH] = true
$game_switches[ATES::NSWITCH] = false
else
$game_map.need_refresh = true if $game_switches[ATES::DSWITCH]
$game_switches[ATES::DSWITCH] = false
$game_switches[ATES::NSWITCH] = true
end
end
def update_screen
$game_screen.start_tone_change(self.get_tint, 0) if @tinting
end
def day?
return (@time.hour.between?(ATES::DAY_START, ATES::NIGHT_START - 1))
end
def night?
return (!self.day)
end
def get_tint
return (self.day? ? self.get_day_tint : self.get_night_tint)
end
def get_day_tint
day, night = (ATES.day_start / 3600), (ATES.night_start / 3600)
ratio = ((@time.hour - day) * 60 + @time.min) * 255 / (60 * (night - day))
tone = Tone.new(0, 0, 0, 0)
if ratio >= 224
tone.red = (232 - ratio) * 4
tone.green = (208 - ratio) * 2
elsif ratio >= 192
tone.red = ratio - 192
tone.green = 192 - ratio
elsif ATES::OVERLIGHTING
if ratio >= 160
tone.red = tone.green = tone.blue = 192 - ratio
elsif ratio >= 96
tone.red = tone.green = tone.blue = 32
elsif ratio >= 64
tone.red = tone.green = tone.blue = ratio - 64
end
end
return tone
end
def get_night_tint
day, night = (ATES.day_start / 3600), (ATES.night_start / 3600)
hour = (@time.hour >= night ? @time.hour : @time.hour + 24)
ratio = ((hour - night) * 60 + @time.min) * 255 / (60 * (day + 24 - night))
tone = Tone.new(-96, -96, 0, 0)
if ratio >= 224
tone.red = (ratio - 256) * 2
tone.green = (ratio - 256) * 2
tone.blue = 255 - ratio
elsif ratio >= 192
tone.red = ratio - 288
tone.green = ratio - 288
tone.blue = ratio - 192
elsif ATES::OVERDARKENING
if ratio >= 160
tone.red = ratio - 288
tone.green = ratio - 288
tone.blue = ratio - 192
elsif ratio >= 96
tone.red = -128
tone.green = -128
tone.blue = -32
elsif ratio >= 64
tone.red = -32 - ratio
tone.green = -32 - ratio
tone.blue = 64 - ratio
end
end
return tone
end
end
#==============================================================================
# Bitmap
#==============================================================================
class Bitmap
if $tons_version == nil || $tons_version < 1.6
alias draw_text_shaded_later draw_text
end
def draw_text_full(x2, y2, w2 = 0, h2 = 0, text2 = '', a2 = 0)
if x2.is_a?(Rect)
x, y, w, h, text, a = x2.x, x2.y, x2.width, x2.height, y2, w2
else
x, y, w, h, text, a = x2, y2, w2, h2, text2, a2
end
save_color = self.font.color.clone
self.font.color = Color.new(0, 0, 0)
draw_text_shaded_later(x - 1, y - 1, w, h, text, a)
draw_text_shaded_later(x + 1, y - 1, w, h, text, a)
draw_text_shaded_later(x - 1, y + 1, w, h, text, a)
draw_text_shaded_later(x + 1, y + 1, w, h, text, a)
self.font.color = save_color
draw_text_shaded_later(x, y, w, h, text, a)
end
end
#==============================================================================
# Clock_Sprite
#==============================================================================
class Clock_Sprite < Sprite
def initialize
super
self.x, self.y, self.z = 480, 8, 5000
self.bitmap = Bitmap.new(128, 32)
if $fontface != nil
self.bitmap.font.name = $fontface
elsif $defaultfonttype != nil
self.bitmap.font.name = $defaultfonttype
end
self.bitmap.font.size = 26
@colon = true
draw
end
def draw
self.bitmap.clear
hours, minutes = $game_system.ates.time.hour, $game_system.ates.time.min
if @colon
self.bitmap.draw_text_full(0, 0, 128, 32,
sprintf('%02d %02d', hours, minutes), 2)
else
self.bitmap.draw_text_full(0, 0, 128, 32,
sprintf('%02d:%02d', hours, minutes), 2)
end
@colon = !@colon
end
end
#==============================================================================
# Scene_Map
#==============================================================================
class Scene_Map
alias main_ates_later main
def main
@clock = Clock_Sprite.new if $game_system.show_clock
$game_system.ates.update_screen
main_ates_later
@clock.dispose if @clock != nil
end
alias update_ates_later update
def update
$game_system.ates.update
update_ates_later
if $game_system.show_clock
@clock = Clock_Sprite.new if @clock == nil
@clock.draw if ATES.active? && $game_system.ates.frame_count % 40 == 0
elsif @clock != nil
@clock.dispose
@clock = nil
end
end
alias transfer_player_ates_later transfer_player
def transfer_player
$game_system.ates.update_screen
transfer_player_ates_later
end
end
The .rb extension file
module RMXOS
def self.load_current_extension
return GlobalDNS
end
module Data
GlobalDNSTimeNow = ' > Global DNS Current Time: TIME'
end
end
#======================================================================
# module GlobalDNS
#======================================================================
module GlobalDNS
VERSION = 1.01
RMXOS_VERSION = 1.08
SERVER_THREAD = true
# START Configuration (make sure it matches the one in the ATES script)
MIDNIGHT_TIME = 0 # seconds after midnight when in game midnight starts (between 0 and 86400, use a divider of DAY_LENGTH!)
DAY_LENGTH = 86400 # how many seconds does a full day take (between 24 and 86400, use a divider of 86400!)
UPDATE_INTERVAL = 1 # how often is time data sent to clients (lower values can increase server load!)
# END Configuration
def self.initialize
@client_times = {}
self.update_time
puts RMXOS::Data::GlobalDNSTimeNow.sub('TIME') {self.time_to_timestring}
end
def self.main
while RMXOS.server.running
self.server_update
sleep(0.1)
end
end
def self.server_update
self.update_time
logged_in_clients = []
$clients.each_value {|client| logged_in_clients.push(client) if client.player.user_id > 0}
time = Time.now
@client_times.each_key {|client|
if time - @client_times[client] > UPDATE_INTERVAL
self.send_time(client, time)
end
}
(@client_times.keys - logged_in_clients).each {|key| @client_times.delete(key)}
(logged_in_clients - @client_times.keys).each {|key| @client_times[key] = time}
end
def self.client_update(client)
case client.message
when /\ALRQ\Z/, /\AENT\Z/, /\AMEX\Z/ # send DNS time on load request, enter server and exit map
self.send_time(client)
end
return false
end
def self.send_time(client, time = Time.now)
client.send("DNS\t#{@time}")
@client_times[client] = time
end
def self.update_time
time = Time.now
seconds = time.hour * 3600 + time.min * 60 + time.sec
@time = (seconds - MIDNIGHT_TIME) % DAY_LENGTH
end
def self.time_to_timestring(time = @time)
hour_length = DAY_LENGTH / 24.0
hours = (hour_length > 0 ? (time / hour_length) : 0)
minute_length = hour_length / 60.0
minutes = (minute_length > 0 ? (time % hour_length / minute_length) : 0)
return sprintf('%02d:%02d', hours.to_i, minutes.to_i)
end
end
Please help this poor soul.
DAY_START and NIGHT_START are in hour time. As in 8 and 20 hours. -____________-
Oh that is just not nice and should be specified in the script pl0x >..>
Default settings are 8 and 20 and length is 360. It's kinda obvious. -_-
Well the code itself says time of day for day/night to start and the default length is 36 so it seemed reasonable.
EDIT: GRAH I'M AN IDIOT, 36 is not 24... Guh, well now it should work. Thanks.
EDIT 2: Yeah, I was just being stupid, it works now, thanks a ton.
Quote from: Lost King on February 10, 2010, 09:42:49 am
EDIT: GRAH I'M AN IDIOT, 36 is not 24... Guh, well now it should work. Thanks.
What did you set the day/night start to fix the tinting? I've been trying for like a week and can't figure out. I changed 36 to 86400.
DAY_START and NIGHT_START are in hours. So if you set them to 8 and 20 respectively and test the game during the day, you will never get to see a darkened screen because it's day at your place. :P
That maybe true but my screen is always darkened unless i take off tint. Not sure why.
Turning off tinting does not remove the tint, it only makes ATES not control it. You have to reset the tint manually.
Back to reading!
Well i'm just going to leave tint off for now. Mess around with it later lol.
A good way to test is to just make another game and mess around with ATES in there without the plugin. Just make sure when you implement it in your RMX-OS game to set the extension's Day_length variable to 86400 or whatever you use in the ATES script.
In order to fix it, your 3 variables in the ATES script should be: Day_Length = 86400, Day_Start = 8, Night_Start = 20. And to see if it's working just make a quick little event that uses the ATES.advance(0,1) to go ahead hour by hour.
Ok so i think i figured out what is wrong. Because the script works just fine without the plugin. I do believe it has something to with converting it to 12 hour format. Thanks for the tip blizzard but for some reason it makes it night when its suppose to be day for me. I guess I'm stuck on the 24 hour clock. Thanks for the help guys.
i seem to have a Slight Problem, when i try to run the server with the Extention in the config file, it opens then almost immediately closes itself out... any reason?
Edit: I went back and looked at the help file...
i feel like an idiot... lol
Are you using any other extensions? If so do you have them properly listed, I think it'd be like
Extensions{
'ATES', 'Some other extension'
}
You messed up the configuration file.
im getting this error
2010-05-24 05:00:22 UTC; false - Extension:
Error: 'false' caused an error.
Connection reset by peer - send(2)
./Data/Sender.rb:20:in `send'
./Data/Sender.rb:20:in `send'
./Data/Client.rb:873:in `send'
./Extensions/GlobalDNS.rb:64:in `send_time'
./Extensions/GlobalDNS.rb:48:in `block in server_update'
./Extensions/GlobalDNS.rb:46:in `each_key'
./Extensions/GlobalDNS.rb:46:in `server_update'
./Extensions/GlobalDNS.rb:37:in `main'
./Data/Server.rb:214:in `block (2 levels) in run'
I put up a piece of security code for that. That shouldn't happen anymore.
ok kool well ill check it out later now i need to copy both scripts on just the rb portion
Actually only the RB portion, but best you get the extension as well because of the version variables.
awsom it works now thx blizzard
How exactly do I set this up?
I am getting this error: "Script ATES line 486: NoMethodError occured"... "undefined method 'updated_screen' RMX-OS-Main 46"
This is roughly my load order:
(RMX-OS) Options
(RMX-OS) Scripts
ATES
(RMX-OS) Global Day & Night
Quote from: ATES topic
Compatibility
99% compatible with SDK v1.x. 90% compatible with SDK 2.x. WILL corrupt old savegames. Can cause incompatibilty issues with DNS-es.
That means that you have to wipe your database after adding/removing ATES and this plugin.
Great :) I will try this. Also, what do you think of RMX-OS/RPG Maker XP Creating a full-scale MMORPG?
I am considering this, and Genesis2D, just don't want to run into many limitations.
As far as I know there are other fullscale RMXP MMOs out there and they are using Netplay+ or some derivative. RMX-OS was designed to be better than Netplay+. So if they could make a game with Netplay+, you should be able to make one with RMX-OS.
Other than that, I'm actually against MMOs made in RMXP because RMXP isn't really the right engine for an MMO. But suit yourself. If you want to use RMXP, by all means, good luck. :)
Well I suppose it's really all up to the person.
I myself like RMXP, maybe not for an MMO, but I know and have used RPG Maker 98, 2000, 2003, XP, and VX.
PS: VX Sucks, they removed very important features in that version....
I only used RMXP and I liked it. When I saw VX, I hated it, too. xD
Hello! For some reason, the controller is causing an error when passing some certain arguments.The script works fine on its own (not globally of course, but no errors either) and will cycle through an entire day/night no problem. But when I add the extension and the RMX-OS Controller, I get this error.
QuoteScript 'ATES RMX-OS Controller' line 68: ArgumentError occurred.
Wrong number of arguments(2 for 6)
ATES RMX-OS Controller:68:in 'initialize'
ATES RMX-OS Controller:68:in 'new'
ATES RMX-OS Controller:68:in 'check_game_blizzabsrmxos_later'
Blizz-ABS RMX-OS Controller:490:in 'check_game'
(RMX-OS) Script:845:in 'listen'
844:in 'each'
844:in 'listen'
6080:in 'update'
5336:in 'main'
5333:in 'loop'
5338:in 'main'
-<:::RMX-OS Main:::>-:46
I went through and made sure that the day length in the script and extension are the same, cleared my rmx-os database, and still cant figure out what's causing it.
Edit :: Here's my script order, but I'm pretty sure it should be fine.
RMX-OS Options
RMX-OS Script
Global Switches and Variables for RMX-OS
ATES
ATES RMX-OS controller
Blizz ABS 1
BABS 2
BABS 3
BABS RMX-OS Controller
RMX-OS Main
QuoteHere's my script order, but I'm pretty sure it should be fine.
This (http://forum.chaos-project.com/index.php/topic,23.0.html) says otherwise.
I switched it so ATES is below BABS, and cleared the database again, but Im getting the same error. And when I say cleared the database, I actually drop it and re-query the whole thing.
Which ATES version are you using? Because it's been updated recently and I never actually updated this script to work with it.
Ahh, didnt even think to look at that.
I'm using ATES v1.0 - which is actually dated 12.2.2013 xD - and the controller is v1.03: 24.5.2010.
Looks like the controller was written for version 0.4, at least that's what it checks for.
Yeah, Thallion finished ATES and I haven't updated this script. I completely forgot about that. I'll do it tomorrow or on Saturday when I find some free time.
EDIT: Oh wait, I forgot that this script is laughably short. I'll do it right away.
:w00t:
Thanks, Blizz! I was worried. I need to learn RGSS so I don't have to bug other people when these things pop up. On that side note, im headed to the programming forum. Any tips to learning RGSS?
I just realized that the new ATES has a completely different handling and display of time. It'll take a bit longer to update this script so I'll leave it for tomorrow or Saturday after all.
My best tip for learning RGSS is that you take other people's scripts and start messing with them. Change stuff and see what happens. Try to figure out how code changes reflect on the script, what each part does and how it's structured. Other than that, this is a good place to start: http://forum.chaos-project.com/index.php/topic,57.0.html
Sounds good, I'll look into that. Any luck so far? 8)
Sorry, I was really busy the past few days. But I'll see if I can get it done by Wednesday as I have finished most of the other urgent stuff as I should have more free time. I was going to do it today, but the other things stretched out too much and I ended working on it until 22h so I was too tired to work on this, too.
No worries :D
There you go, it works now with ATES v1.x. Just keep in mind that this only controls the day and night (and also the calender obviously), but not the weather or other environmental stuff.
Awesome, thank you!
Updated to work with RMX-OS 2.0.
Anyone have still the right ates to make this work, the one in list of rmxp scripts doenst work with this , thank you in advance
You're referring to this script? https://forum.chaos-project.com/index.php/topic,12869.0.html
What about it doesn't work? You need to provide more context for anyone to give you help.
i had an error on the ates and said its was not the right version so i changed this $ates = 1.0 to $ates = 1.1 on line 409 but on the server side extension the clock stays at 00:00
Loading extensions...
> Global DNS Current Time: 00:00
'Ates.rb' v1.2 loaded and initialized.
Stays at 00:00 forever? Did you change the configurations? From what I remember, the script doesn't take the current time; you can make up your own calendar and define how long a day is represented in-game. Think the script always starts you at midnight.
Changing the global variable for ates version makes sense. Honestly surprising it's still 1.0 in ATES despite Blizz claiming he made this RMXOS script compatible with it.
ok i got currently so far the server takes my current time but the hud clock keeps staying on 00:00
also when i set a night time nothing happens
the scripts i currently use now are as follow
ates now :
:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Advanced Time and Environment System (ATES) by Blizzard
# Version: 0.4
# Type: Autonomous Timeflow and Environment Controller
# Date v0.3: 11.3.2008
# Date v0.31: 8.4.2009
# Date v0.32: 13.4.2009
# Date v0.33: 4.5.2009
# Date v0.34: 5.5.2009
# Date v0.4: 28.12.2009
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# This work is protected by the following license:
# #----------------------------------------------------------------------------
# #
# # Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# # ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# #
# # You are free:
# #
# # to Share - to copy, distribute and transmit the work
# # to Remix - to adapt the work
# #
# # Under the following conditions:
# #
# # Attribution. You must attribute the work in the manner specified by the
# # author or licensor (but not in any way that suggests that they endorse you
# # or your use of the work).
# #
# # Noncommercial. You may not use this work for commercial purposes.
# #
# # Share alike. If you alter, transform, or build upon this work, you may
# # distribute the resulting work only under the same or similar license to
# # this one.
# #
# # - For any reuse or distribution, you must make clear to others the license
# # terms of this work. The best way to do this is with a link to this web
# # page.
# #
# # - Any of the above conditions can be waived if you get permission from the
# # copyright holder.
# #
# # - Nothing in this license impairs or restricts the author's moral rights.
# #
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Compatibility:
#
# 99% compatible with SDK v1.x. 90% compatible with SDK 2.x. WILL corrupt old
# savegames. Can cause incompatibilty issues with DNS-es.
#
#
# Features:
#
# - complete control over and easy manipulating of time
# - nice day and night tinting
# - HUD clock optional
# - easier to control and more powerful than DDNS
#
#
# IMPORTANT NOTES:
#
# - This system has a working preconfiguration, be aware that a custom setup
# will need you to understand what each option does, so please read the
# configuration instructions.
# - Why does this system use switches to determine whether it's day or night?
# Simple: You can use conditions in enemy attacks to determine whether an
# attack should be used only at night or only at day.
#
#
# Instructions:
#
# - Explanation:
#
# This Time System will make your game have daytime and nighttime periods.
# The screen will be tinted accordingly. You can set up the length of the
# day. Other features are explained below. Please be sure to configure this
# system appropriately.
#
#
# - Basic manipulation of ATES:
#
# This system is based upon your eventing. It will work basically if you
# want, but with a little bit of using the "Call Script" event command you
# are able to control this system fully. You can call following commands:
#
# ATES.on
# Turns ATES on.
#
# ATES.off
# Turns ATES off.
#
# ATES.tint_on
# Turns ATES's screen tinting on.
#
# ATES.tint_off
# Turns ATES's screen tinting off.
#
# ATES.clock_on
# Turns ATES's clock display on.
#
# ATES.clock_off
# Turns ATES's clock display off.
#
# ATES.active?
# Returns true if ATES is turned on, otherwise false.
#
# ATES.tinting?
# Returns true if ATES tinting is turned on, otherwise false.
#
# ATES.day?
# Returns true if it's day, otherwise false. Alternatively you can check the
# assigned switch instead.
#
# ATES.night?
# Returns true if it's night, otherwise false. Alternatively you can check
# the assigned switch instead.
#
# ATES.advance(M, H)
# This will make the time advanced by M minutes and H hours. Any negative
# value used will cancel the execution of this command.
#
# ATES.make_it_day
# This is a feature from DDNS which allows you to quickly jump to the
# daytime.
#
# ATES.make_it_night
# This is a feature from DDNS which allows you to quickly jump to the
# nighttime.
#
#
# - Enhancement hints:
#
# If you wish to implement the DDNS further into your game and e.g. allow
# different behavious of monsters during day and night, you only need to
# check the the state of the appropriate switch. e.g. If NSWITCH is turned
# on inflict "Sleep" on one enemy.
#
#
# Additional info:
#
# The daytime and nighttime tintings were tested appropriately and optimal
# tinting is being used.
# Keep in mind that ATES is initially turned off, you need to turn it on by
# using the ATES.on and ATES.tint_on commands together.
#
#
# If you find any bugs, please report them here:
# http://forum.chaos-project.com
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
module ATES
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# switch ID of the "day" switch
DSWITCH = 51
# switch ID of the "night" switch
NSWITCH = 52
# length of a day in seconds in-game, can't be less than 36, is being
# quantized into intervals of 36 seconds
LENGTH = 86400
# how much time is it when the "day" starts
DAY_START = 8
# how much time is it when the "night" starts
NIGHT_START = 43200
# makes the screen brighter during "summer" days
OVERLIGHTING = true
# makes the screen darker during the night, not recommended
OVERDARKENING = false
# display HUD clock
SHOW_CLOCK = true
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
$ates = 0.4
#============================================================================
# ATES::Time
#============================================================================
class Time
attr_accessor :hour
attr_accessor :min
def initialize(m = 0, h = 0)
@hour, @min = h, m
end
end
def self.on
$game_system.ates.active = true
return true
end
def self.off
$game_system.ates.active = false
return true
end
def self.tint_on
$game_system.ates.tinting = true
return true
end
def self.tint_off
$game_system.ates.tinting = false
return true
end
def self.clock_on
$game_system.show_clock = true
return true
end
def self.clock_off
$game_system.show_clock = false
return true
end
def self.active?
return $game_system.ates.active
end
def self.tinting?
return $game_system.ates.tinting
end
def self.day?
$game_system.ates.day?
end
def self.night?
$game_system.ates.night?
end
def self.make_it_day
$game_system.ates.time.hour = DAY_START
$game_system.ates.time.min = 0
return true
end
def self.make_it_night
$game_system.ates.time.hour = NIGHT_START
$game_system.ates.time.min = 0
return true
end
def self.day_start
return DAY_START
end
def self.night_start
return NIGHT_START
end
def self.advance(m = 1, h = 0)
return false if m < 0 || h < 0
h += ($game_system.ates.time.min + m) / 60
$game_system.ates.time.hour = ($game_system.ates.time.hour + h) % 24
$game_system.ates.time.min = ($game_system.ates.time.min + m) % 60
return true
end
end
if ATES::DAY_START > ATES::NIGHT_START
raise 'ATEScfgError: A night can\'t start earlier than a day.'
elsif ATES::LENGTH < 36
raise 'ATEScfgError: A day\'s length must be equal to or greater than 36 seconds!'
end
#==============================================================================
# Game_System
#==============================================================================
class Game_System
attr_accessor :ates
attr_accessor :show_clock
alias init_ates_later initialize
def initialize
init_ates_later
@ates = Game_ATES.new
@show_clock = ATES::SHOW_CLOCK
end
end
#==============================================================================
# Game_ATES
#==============================================================================
class Game_ATES
attr_accessor :time
attr_accessor :frame_count
attr_accessor :active
attr_accessor :tinting
def initialize
@time = ATES::Time.new(0, 0)
@frame_count = 0
@active = false
@tinting = false
end
def update
if @active
update_progress
update_ates_progress
end
update_switches
update_screen
end
def update_progress
@frame_count += 1
end
def update_ates_progress
ATES.advance if @frame_count % (ATES::LENGTH / 36) == 0
end
def update_switches
if ATES.day?
$game_map.need_refresh = true if $game_switches[ATES::NSWITCH]
$game_switches[ATES::DSWITCH] = true
$game_switches[ATES::NSWITCH] = false
else
$game_map.need_refresh = true if $game_switches[ATES::DSWITCH]
$game_switches[ATES::DSWITCH] = false
$game_switches[ATES::NSWITCH] = true
end
end
def update_screen
$game_screen.start_tone_change(self.get_tint, 0) if @tinting
end
def day?
return (@time.hour.between?(ATES::DAY_START, ATES::NIGHT_START - 1))
end
def night?
return (!self.day)
end
def get_tint
return (self.day? ? self.get_day_tint : self.get_night_tint)
end
def get_day_tint
day, night = (ATES.day_start / 3600), (ATES.night_start / 3600)
ratio = ((@time.hour - day) * 60 + @time.min) * 255 / (60 * (night - day))
tone = Tone.new(0, 0, 0, 0)
if ratio >= 224
tone.red = (232 - ratio) * 4
tone.green = (208 - ratio) * 2
elsif ratio >= 192
tone.red = ratio - 192
tone.green = 192 - ratio
elsif ATES::OVERLIGHTING
if ratio >= 160
tone.red = tone.green = tone.blue = 192 - ratio
elsif ratio >= 96
tone.red = tone.green = tone.blue = 32
elsif ratio >= 64
tone.red = tone.green = tone.blue = ratio - 64
end
end
return tone
end
def get_night_tint
day, night = (ATES.day_start / 3600), (ATES.night_start / 3600)
hour = (@time.hour >= night ? @time.hour : @time.hour + 24)
ratio = ((hour - night) * 60 + @time.min) * 255 / (60 * (day + 24 - night))
tone = Tone.new(-96, -96, 0, 0)
if ratio >= 224
tone.red = (ratio - 256) * 2
tone.green = (ratio - 256) * 2
tone.blue = 255 - ratio
elsif ratio >= 192
tone.red = ratio - 288
tone.green = ratio - 288
tone.blue = ratio - 192
elsif ATES::OVERDARKENING
if ratio >= 160
tone.red = ratio - 288
tone.green = ratio - 288
tone.blue = ratio - 192
elsif ratio >= 96
tone.red = -128
tone.green = -128
tone.blue = -32
elsif ratio >= 64
tone.red = -32 - ratio
tone.green = -32 - ratio
tone.blue = 64 - ratio
end
end
return tone
end
end
#==============================================================================
# Bitmap
#==============================================================================
class Bitmap
if $tons_version == nil || $tons_version < 1.6
alias draw_text_shaded_later draw_text
end
def draw_text_full(x2, y2, w2 = 0, h2 = 0, text2 = '', a2 = 0)
if x2.is_a?(Rect)
x, y, w, h, text, a = x2.x, x2.y, x2.width, x2.height, y2, w2
else
x, y, w, h, text, a = x2, y2, w2, h2, text2, a2
end
save_color = self.font.color.clone
self.font.color = Color.new(0, 0, 0)
draw_text_shaded_later(x - 1, y - 1, w, h, text, a)
draw_text_shaded_later(x + 1, y - 1, w, h, text, a)
draw_text_shaded_later(x - 1, y + 1, w, h, text, a)
draw_text_shaded_later(x + 1, y + 1, w, h, text, a)
self.font.color = save_color
draw_text_shaded_later(x, y, w, h, text, a)
end
end
#==============================================================================
# Clock_Sprite
#==============================================================================
class Clock_Sprite < Sprite
def initialize
super
self.x, self.y, self.z = 480, 8, 5000
self.bitmap = Bitmap.new(128, 32)
if $fontface != nil
self.bitmap.font.name = $fontface
elsif $defaultfonttype != nil
self.bitmap.font.name = $defaultfonttype
end
self.bitmap.font.size = 26
@colon = true
draw
end
def draw
self.bitmap.clear
hours, minutes = $game_system.ates.time.hour, $game_system.ates.time.min
if @colon
self.bitmap.draw_text_full(0, 0, 128, 32,
sprintf('%02d %02d', hours, minutes), 2)
else
self.bitmap.draw_text_full(0, 0, 128, 32,
sprintf('%02d:%02d', hours, minutes), 2)
end
@colon = !@colon
end
end
#==============================================================================
# Scene_Map
#==============================================================================
class Scene_Map
alias main_ates_later main
def main
@clock = Clock_Sprite.new if $game_system.show_clock
$game_system.ates.update_screen
main_ates_later
@clock.dispose if @clock != nil
end
alias update_ates_later update
def update
$game_system.ates.update
update_ates_later
if $game_system.show_clock
@clock = Clock_Sprite.new if @clock == nil
@clock.draw if ATES.active? && $game_system.ates.frame_count % 40 == 0
elsif @clock != nil
@clock.dispose
@clock = nil
end
end
alias transfer_player_ates_later transfer_player
def transfer_player
$game_system.ates.update_screen
transfer_player_ates_later
end
end
server exstension
module RMXOS
def self.load_current_extension
return GlobalDNS
end
module Data
GlobalDNSTimeNow = ' > Global DNS Current Time: TIME'
end
end
#======================================================================
# module GlobalDNS
#======================================================================
module GlobalDNS
VERSION = 1.01
RMXOS_VERSION = 2.00
SERVER_THREAD = true
# START Configuration (make sure it matches the one in the ATES script)
MIDNIGHT_TIME = 0 # seconds after midnight when in game midnight starts (between 0 and 86400, use a divider of DAY_LENGTH!)
DAY_LENGTH = 86400 # how many seconds does a full day take (between 24 and 86400, use a divider of 86400!)
UPDATE_INTERVAL = 1 # how often is time data sent to clients (lower values can increase server load!)
# END Configuration
def self.initialize
@mutex = Mutex.new
@client_times = {}
self.update_time
puts RMXOS::Data::GlobalDNSTimeNow.sub('TIME') {self.time_to_timestring}
end
def self.mutex
return @mutex
end
def self.main
while RMXOS.server.running
self.server_update
sleep(0.1)
end
end
def self.server_update
self.update_time
logged_in_clients = []
$clients.each_value {|client| logged_in_clients.push(client) if client.player.user_id > 0}
time = Time.now
@client_times.each_key {|client|
if time - @client_times[client] > UPDATE_INTERVAL
self.send_time(client, time)
end
}
(@client_times.keys - logged_in_clients).each {|key| @client_times.delete(key)}
(logged_in_clients - @client_times.keys).each {|key| @client_times[key] = time}
end
def self.client_update(client)
case client.message
when /\ALRQ\Z/, /\AENT\Z/, /\AMEX\Z/ # send DNS time on load request, enter server and exit map
self.send_time(client)
end
return false
end
def self.send_time(client, time = Time.now)
client.send("DNS\t#{@time}")
@client_times[client] = time
end
def self.update_time
time = Time.now
seconds = time.hour * 3600 + time.min * 60 + time.sec
@time = (seconds - MIDNIGHT_TIME) % DAY_LENGTH
end
def self.time_to_timestring(time = @time)
hour_length = DAY_LENGTH / 24.0
hours = (hour_length > 0 ? (time / hour_length) : 0)
minute_length = hour_length / 60.0
minutes = (minute_length > 0 ? (time % hour_length / minute_length) : 0)
return sprintf('%02d:%02d', hours.to_i, minutes.to_i)
end
end
So now you're using an older version of the script and removed the version check? :???:
Can't really help you anymore without installing RMX-OS myself, which I'm not going to do.