Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: elmangakac on April 10, 2011, 11:14:13 pm

Title: Help with this Day&Night simple script...
Post by: elmangakac on April 10, 2011, 11:14:13 pm
Hello people...

Well this script its in spanish..... the author is Falcao... its a script that creates a virtual clock and let you change into morning, day, sunset and night, with some sounds and with a picture of light rays...

Like --- (http://i627.photobucket.com/albums/tt357/falcao99/Luzss.png)


Its looks like very simple... Let you set the maps id where the light ray image dont appear.... well im going to  translate a little the script comments for you...


#=======================================================================#
#=======================================================================#
#  #*****************#          ADVANCED_TIME_FALMT                     #
#  *  By Falcao y    *          Noche, dia, atardecer y sol real script #
#  *  mondo_trasho   *          Permite diferentes efectos segun        #     
#  #*****************#          transcurra un reloj virtual.            #
#         RMXP                          V 1.1                           #
# makerpalace.onlinegoo.com                                             #
#=======================================================================#

#------------------------------------------------------------------------
# * Instructions
# Put above Main, save the image called "Luz" in your picture folder
# , with Q button the counter dissapear
#-----------------------------------------------------------------------

module FALMT_time

#------------------------------------------------------------------------
# Configuration
#--------------------

# Star Year
ANOS = 2000

# Night hour
HoraOscurece = 19     

# Morning Hour
HoraAmanece = 1

# Sunset Hour
HoraOcaso = 14

# ID to enable counter (ON = Disable, OFF = Enable)
WindowDisable = 50

# ID of maps where the light image dissapear.
# Example: LuzDisable = [2,4,7,9]

LuzDisable = [ ]

#----------------------
# * Sounds & Image
#----------------------

# Morning Sound
SonidoAmanecer = "075-Small02"

# Night Sound
SonidoAnochecer = "076-Small03"

# Image in Pictures
Picture = "Luz"

WindowBoton = Input::L

#-----------------------------------------------------------------------------
# Day, Month, Year config (Optional)
#---

DIAS = 7 # Days at week
DIA_1 = "Domingo"
DIA_2 = "Lunes"
DIA_3 = "Martes"
DIA_4 = "Miércoles"
DIA_5 = "Jueves"
DIA_6 = "Viernes"
DIA_7 = "Sábado"

#
#----
# MES
#----
MESES = 12 # Month at year
MES_1 = "Enero"
MES_2 = "Febrero"
MES_3 = "Marzo"
MES_4 = "Abril"
MES_5 = "Mayo"
MES_6 = "Junio"
MES_7 = "Julio"
MES_8 = "Agosto"
MES_9 = "Septiembre"
MES_10 = "Octubre"
MES_11 = "Noviembre"
MES_12 = "Diciembre"

#----
#
#----.
DIAS_POR_MES = 30 # Days in a month
HORAS = 24 # Hours in a Day
MINUTOS = 2 # Minutes in a Hour
SEGUNDOS = 5 # Seconds in a Minute

end

class Window_AdvancedMapTime < Window_Base

  def initialize
    super(505, 0, 135, 105)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 100
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    @total_sec = Graphics.frame_count / Graphics.frame_rate
    $hora = @total_sec / FALMT_time::SEGUNDOS / FALMT_time::MINUTOS % FALMT_time::HORAS
    $minuto = @total_sec / FALMT_time::SEGUNDOS % FALMT_time::MINUTOS
    $segundo = @total_sec % FALMT_time::SEGUNDOS

# CAMBIOS DE DÍA SEGÚN LAS HORAS PASADAS (contador automático):
#-----------------
if $hora == 0 and $hora_cambio == nil
$dia_cantidad = FALMT_time::DIAS
if $dia_numero == nil or $dia_numero == $dia_cantidad
$dia_numero = 1
if $dias_por_mes == nil
  $dias_por_mes = 1
else
$dias_por_mes +=1
end
else
$dia_numero+=1
$dias_por_mes +=1
end
#MODIFICACIÓN DE LOS DÍAS (cantidad 7 por defecto):
case $dia_numero
when 1 # Cuando es el día número 1
$dia = FALMT_time::DIA_1 # Es Domingo
when 2 # Día número 2
$dia = FALMT_time::DIA_2 # Es lunes
when 3 # Etcétera...
$dia = FALMT_time::DIA_3
when 4
$dia = FALMT_time::DIA_4
when 5
$dia = FALMT_time::DIA_5
when 6
$dia = FALMT_time::DIA_6
when 7
$dia = FALMT_time::DIA_7
end
end

if $hora == 0
$hora_cambio = false
else $hora != 0
$hora_cambio = nil
end

#-----------------
# CAMBIOS DE MES SEGÚN LOS DÍAS PASADOS (contador automático):
#-----------------
if $mes_cambio == nil
$meses_cantidad = FALMT_time::MESES
if $mes_numero == nil or $mes_numero == $meses_cantidad
$mes_numero = 1
if $ano == nil
$ano = FALMT_time::ANOS
else
$ano += 1
end
else
$mes_numero+=1
end
#MODIFICACIÓN DE LOS MESES (cantidad 12 por defecto):
case $mes_numero
when 1 # Cuando es el día número 1
$mes = FALMT_time::MES_1 # Es Domingo
when 2 # Día número 2
$mes = FALMT_time::MES_2 # Es lunes
when 3 # Etcétera...
$mes = FALMT_time::MES_3
when 4
$mes = FALMT_time::MES_4
when 5
$mes = FALMT_time::MES_5
when 6
$mes = FALMT_time::MES_6
when 7
$mes = FALMT_time::MES_7
when 8
$mes = FALMT_time::MES_8
when 9
$mes = FALMT_time::MES_9
when 10
$mes = FALMT_time::MES_10
when 11
$mes = FALMT_time::MES_11
when 12
$mes = FALMT_time::MES_12
end
end

$dias_pormes = FALMT_time::DIAS_POR_MES

if $mes_cambiando == true
$mes_cambio = false
$dias_por_mes = 1
end

if $dias_pormes != $dias_por_mes
$mes_cambio = false
$mes_cambiando = nil
else $dias_pormes == $dias_por_mes
if $mes_cambiando == nil
$mes_cambio = nil
$mes_cambiando = true
end
end

#-----------------

dia = ["Día: ",$dia]
mes = ["Mes: ",$mes]
ano = ["Año: ",$ano]
   
    hora_minuto_segundo = sprintf("%02d:%02d:%02d", $hora, $minuto, $segundo)
    self.contents.font.color = normal_color
    self.contents.font.size = 19
    self.contents.font.name = "Times New Roman"
    self.contents.draw_text(0, -9, 120, 32, dia.to_s,0)
    self.contents.draw_text(0, 10, 150, 32, mes.to_s,0)
    self.contents.draw_text(0, 29, 150, 32, ano.to_s,0)
    self.contents.draw_text(50, 50, 120, 32, hora_minuto_segundo)
  end

  def update
    super
    if Graphics.frame_count / Graphics.frame_rate != @total_sec
    refresh
  end
    end
  end
 
class Game_System
  attr_accessor :opa
  attr_accessor :ocaso
  attr_accessor :fshow
  alias falcaoluz_initialize initialize
  def initialize
    falcaoluz_initialize
    @opa = 0
    @ocaso = 0
    @fshow = 0
  end
end

class Scene_Map
  include FALMT_time
  alias falcaotrasho_main main
  def main
    @AMT = Window_AdvancedMapTime.new
    if $game_system.fshow == 0
      @AMT.x = 505
      @AMT.y = -104
      $game_system.fshow = 1
    end
    if $game_switches[WindowDisable] == false
      @AMT.visible = true
    else
      @AMT.visible = false
    end
    #$game_screen.start_tone_change(Tone.new(-110, -110, -110, 0), 20)
    falcaotrasho_main
    @AMT.dispose
  end
  alias falcaotrasho_update update
  def update
    @AMT.refresh
    # Nuevo update
    if Input.trigger?(WindowBoton)
      if @AMT.y == -104
        $game_system.fshow = 1
      elsif @AMT.y == 0
         $game_system.fshow = 2
      end
    end
    if $game_system.fshow == 1
      @AMT.y += 2 if @AMT.y < 0
    elsif $game_system.fshow == 2
        @AMT.y -= 2 if @AMT.y > -104
    end
    if $game_switches[WindowDisable] == false
      @AMT.visible = true
    else
      @AMT.visible = false
    end
    if $hora >= HoraAmanece  and $hora <= HoraOscurece - 1
      command_amanece
    elsif $hora <= HoraAmanece or $hora >= HoraOscurece - 1
      command_oscurece
    end
    command_ocaso if $hora >= HoraOcaso and $hora <= HoraOscurece - 1
    falcaotrasho_update
  end
  # comando amanece
  def command_amanece
    if $game_system.opa < 75
      $game_system.opa += 1
      unless FALMT_time::LuzDisable.include?($game_map.map_id)
        $game_screen.start_tone_change(Tone.new(0, 0, 0, 0),200)
        $game_screen.pictures[50].show(Picture,0,0, 0,100,100,$game_system.opa,0)
      end
      Audio.se_play("Audio/Se/" + SonidoAmanecer) if $game_system.opa == 75
    end
  end
  #comando oscurece
  def command_oscurece
    if $game_system.opa > 0
      $game_system.opa -= 1
      unless FALMT_time::LuzDisable.include?($game_map.map_id)
        $game_screen.start_tone_change(Tone.new(-110, -110, -110, 0), 200)
        $game_screen.pictures[50].show(Picture,0,0,0,100,100, $game_system.opa, 0)
      else
        $game_screen.pictures[50].show(Picture,0 , 0, 0, 100, 100,0, 0)
      end
      Audio.se_play("Audio/Se/" + SonidoAnochecer) if $game_system.opa == 0
    end
  end
  #-comando ocaso
  def command_ocaso
    if $game_system.ocaso < 10
      $game_system.ocaso += 1
      $game_screen.start_tone_change(Tone.new(10, -17, -17, 0), 100)
      $game_system.ocaso = 0 if $game_system.ocaso == 10
    end
  end
  #------------
  # Housing system
  alias falcaotrasho_transfer_player transfer_player
  def transfer_player
    falcaotrasho_transfer_player
    if FALMT_time::LuzDisable.include?($game_map.map_id)
      $game_screen.pictures[50].erase
      $game_screen.start_tone_change(Tone.new(0, 0, 0, 0),10)
      ## si esta de dia
    elsif $hora >= HoraAmanece  and $hora <= HoraOscurece
      $game_screen.pictures[50].show(Picture,0,0,0,100,100, $game_system.opa, 0)
      if $hora >= HoraOcaso
        $game_screen.start_tone_change(Tone.new(0, -17, -17, 0), 10)
      end
    elsif $hora <= HoraAmanece  or $hora >= HoraOscurece
      $game_screen.start_tone_change(Tone.new(-110, -110, -110, 0), 10)
    end
  end
end

class Scene_Save 
  alias falcaotrasho_write_data write_save_data
  def write_save_data(file)
    falcaotrasho_write_data(file)
    Marshal.dump($hora, file)
    Marshal.dump($minuto, file)
    Marshal.dump($segundo, file)
    Marshal.dump($mes, file)
    Marshal.dump($dia, file)
  end
end

class Scene_Load
  alias falcaotrasho_read_data read_save_data
  def read_save_data(file)
    falcaotrasho_read_data(file)
    $hora    = Marshal.load(file)
    $minuto    = Marshal.load(file)
    $segundo    = Marshal.load(file)
    $mes    = Marshal.load(file)
    $dia    = Marshal.load(file)
  end
end



Heres a Demo (In Spanish)

http://www.4shared.com/file/122985152/a43eb762/NocheDia_atardecer_FalTras.html

QUESTIONS:

- Anyone knows how to edit this script to also disable the tint (in night & sunset) when you are inside a house with some kinf of switch or with the...

# ID of maps where the light image dissapear.
# Example: LuzDisable = [2,4,7,9]
LuzDisable = [ ]


O_O ????. Please help me.... This Day&Night script its the only that works good with my game...

THANKS TO ALL... AGAIN


Title: Re: Help with this Day&Night simple script...
Post by: Apidcloud on August 26, 2011, 06:32:22 am
Well, basically you just have to add this:

unless FALMT_time::LuzDisable.include?($game_map.map_id)
  #tint code, which I believe it's a tone.new xD
end