PDA

View Full Version : Realtime + Tint Screen


Blizzy
February 23rd, 2006, 10:00 AM
i know this isn't a toturial,
but i don't know where to post it else.

paste this above main,
and edit the tones / durations to whatever you want.


module Realtime
#-------------------------------------------
# * Object Initialization
#-------------------------------------------
def self.initialize
# integers
@time = Time.now
@second = @time.sec
@minute = @time.min
@hour = @time.hour
@day = @time.day
@week = @time.strftime("%W").to_i
@month = @time.month
@year = @time.year
# strings
@dayame = @time.strftime("%A")
@monthname = @time.strftime("%B")
@timezone = @time.strftime("%Z")
@meridian = @time.strftime("%p")
end

#-------------------------------------------
# * Second ( 0...59 )
#-------------------------------------------
def self.second
return @second
end
#-------------------------------------------
# * Minute ( 0...59 )
#-------------------------------------------
def self.minute
return @minute
end
#-------------------------------------------
# * Hour ( 0...24 )
#-------------------------------------------
def self.hour
return @hour
end
#-------------------------------------------
# * Day ( 1...366 )
#------------------------------------------
def self.day
return @day
end
#-------------------------------------------
# * Week ( 0...53 )
#-------------------------------------------
def self.week
return @week
end
#-------------------------------------------
# * Month ( 1...12 )
#-------------------------------------------
def self.month
return @month
end
#-------------------------------------------
# * Year ( current year )
#-------------------------------------------
def self.year
return @year
end

#-------------------------------------------
# * Day Name ( Monday...Sunday )
#------------------------------------------
def self.dayname
return @dayname.capitalize!
end
#-------------------------------------------
# * Month Name ( January...December )
#-------------------------------------------
def self.monthname
return @monthname.capitalize!
end
#-------------------------------------------
# * Timezone ( GTM / CST )
#-------------------------------------------
def self.timezone
return @timezone
end
#-------------------------------------------
# * Meridian ( AM / PM )
#-------------------------------------------
def self.meridian
return @meridian
end
#-------------------------------------------
# * Now
#-------------------------------------------
def self.now
return @time
end

#-------------------------------------------
# * Time Update
#-------------------------------------------
def self.update
# integers
@time = Time.now
@second = @time.sec
@minute = @time.min
@hour = @time.hour
@day = @time.day
@week = @time.strftime("%W").to_i
@month = @time.month
@year = @time.year
# strings
@dayame = @time.strftime("%A")
@monthname = @time.strftime("%B")
@timezone = @time.strftime("%Z")
@meridian = @time.strftime("%p")

tint_screen
end

#-------------------------------------------
# * Tint screen
#-------------------------------------------
def self.tint_screen
if !$scene.is_a?(Scene_Map)
@tone = $game_screen.tone
return
end
if $scene.is_a?(Scene_Map)
# added.
# tint screen only works if map has '*' in the name
if !$game_map.name.include?("*")
@tone = Tone.new(0,0,0,0)
@duration = 0
$game_screen.start_tone_change(@tone, duration)
return
end

# change tone and duration here depending on times
# tone : screen tone
# duration : duration of tone change
if @hour >= 0
tone = Tone.new(-187, -119, -17, 68)
duration = 600
end
if @hour >= 5
tone = Tone.new(17, -51, -102, 0)
duration = 600
end
if @hour >= 10
tone = Tone.new(0, 0, 0, 0)
duration = 600
end
if @hour >= 15
tone = Tone.new(-68, -136, -34, 0)
duration = 600
end
if @hour >= 20
tone = Tone.new(-187, -119, -17, 68)
duration = 600
end
@tone = tone
$game_screen.start_tone_change(@tone, duration)
end
end
end

module Graphics
class << self
unless @reboot_fix == 1
alias realtime_update update
@reboot_fix = 1
end

def update
Realtime.update if $game_screen != nil
realtime_update
end
end
end

class Game_Map
def name
$map_infos = load_data("Data/MapInfos.rxdata")
return $map_infos[@map_id].name
end
end

exteradude
February 24th, 2006, 12:10 AM
Cool script! It works! Nice job!

tdata
February 24th, 2006, 02:03 AM
I would add a way to disable it while in a building.

Blizzy
March 3rd, 2006, 12:47 PM
well, you can easy do that :O
this makes it only appear in the maps with * in the name

if $game_map.name.include?("*")
# code block
end

tdata
March 5th, 2006, 03:02 AM
lol, undefined function. I'm using a switch.

Blizzy
March 5th, 2006, 04:20 PM
oh yeah, i forgot that.
there should be a function on rmxp.net forums,
but i can't find it at the moment.

Krazy_Meerkat
March 5th, 2006, 06:36 PM
What about the windows of houses.. Is there some way to make them illuminate in darkness? (Assuming the window's background is transparent)
Anyway great tutorial blizzy ;) Excellent work as always. I thought about trying this once, but it was just too long to script. Yours is nice, short and straight to the point :)

Falnax
March 5th, 2006, 06:47 PM
Is there a way to make a realtime switch for area teleports? In the game I'm working on I just have different areas for night and day, because that way there's nothing effecting the inside, I can light up the windows, and the NPCs are different at night as they are in the day...I just need the switch to make them work...

tdata
March 5th, 2006, 08:38 PM
You can do that by calling using the time part of the script.

Krazy_Meerkat
March 6th, 2006, 01:23 AM
Yeah you could add some code to the script to turn on a switch if it night-time..
It has been so long since I used rgss, so this won't be right at all but it has to be something like this:
In the *Time update part, it needs to do this.
if @hour>=18
if game_switch.[0] = false
game_switch.[0] == true
end
end
The game switch will result true if the time is past 6pm.. You would have to do the actual code yourself..

Blizzy
March 6th, 2006, 08:08 AM
first post is updated.

Tint screen only works if a mapname has a '*' in the name

tdata
March 6th, 2006, 06:30 PM
^_^ Still doesn't work with the * . it has a problem with [@map_id] It says that [] is undefined...

Eversoquiet
March 17th, 2006, 06:25 PM
can someone tell me how can i use this script? (can i use it in pkmn sapphire?)

Space Guard
March 28th, 2006, 02:59 AM
can someone tell me how can i use this script? (can i use it in pkmn sapphire?)
No you can't use this script in your Pokémon Sapphire Game.
This script will only work on a game making program called RMXP.

Anyway about your scrpit
Well Done! I might attempt to use it in my new game
You are one of the best RMXP scripters I have seen around
But I've never used RMXP before so I am a complete nOOb!

Well Done!
SG06

Adam_148
March 28th, 2006, 07:13 AM
actually you can use real time on RM2K3, an easier game maker in my opinion, I use it sometimes for my comic,

[_DarkDragon_]
March 30th, 2006, 12:55 PM
yay, this saves me time since I don't have to write my own xD

Shaneypoo17
April 1st, 2006, 08:45 AM
this is Great! although it changes abit too quickly but that can easily be fixed ^^

a week in kanto
June 28th, 2006, 07:44 PM
????? 'Realtime' ? ??? NameError undefined local variable or method duration for Realtime:Module

What do I have to do to fix that

Kronos
July 3rd, 2006, 11:34 AM
You must add an @ before duration - the only problem now is tint screen doesn't work.

rebellee1187
July 6th, 2006, 08:27 PM
I'm having the same problems. Actually, I'm having a whole host of them...

Where do I paste this? My tint screen command doesn't work AT ALL in my version of the starter kit. How would I edit it *is a RMXP n00b*





Thanks in advance for any help I may get...

Minorthreat0987
July 6th, 2006, 09:40 PM
I'm having the same problems. Actually, I'm having a whole host of them...

1. Where do I paste this?
2. My tint screen command doesn't work AT ALL in my version of the starter kit.
3. How would I edit it *is a RMXP n00b*




Thanks in advance for any help I may get...
1. Create a new sript above Main and paste it there
2. The tint screen doesnt work because of the Anti-Lag script you can suffer lag or not use the tint screen funtion/ Day nightg sys.
3. Edit it, what do you mean edit it.

~Minorthreat