Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

> 


———
Before you ask! Read! ;)

You must have 30+ Posts to create a topic here!

Thanks for reading!
———

 
Reply to this topicStart new topic
> Need a portuguese translator for script, Need Portuguese to English translation
Icenick99
post Apr 8 2012, 07:14 PM
Post #1


Level 3
Group Icon

Group: Member
Posts: 33
Type: None
RM Skill: Undisclosed




I found an amazing time system script, but have no idea how to use it, I was wondering if anyone could translate it to english?

Its 3 parts in the appropriate order,
BFK Core,
BFK Day/Night,
BFK Day/Night Moon Phase

If need be I can provide the site and demo.

CODE
#--------------------------------------------------------------------------
# BFK CORE (BY RAVEN) - v1.0 - WWW.RPGMENACE.COM.BR
#--------------------------------------------------------------------------
# * Arquivo com mas ferramentas para executar scripts BFK
#--------------------------------------------------------------------------
$registro = [] if $registro.nil?
$registro << ["BFK Core",1.0]  
module BFK
  DEBUG = false
  SHOW_POPUPS = true
  attr_accessor :restext
  def self.modular(nome,version)
    modulo = $registro.collect{ |x| x[0] == nome && x[1]>= version}
    if !modulo.include?(true)
      msgbox("Não foi encontrado o Script #{nome} versão maior que #{version}")
      exit
    else
      return true
    end
  end
  
  def self.calc_porcent(quant,cem)
    porcento = (quant * 100)/cem
  end
  
  #--------------------------------------------------------------------------
  # * FUNÇÃO QUE AUXILIA NA BUSCA DE TAGS (ESTA FUNÇÃO SERÁ MODIFICADA PELAS ATUALIZAÇÕES
  #--------------------------------------------------------------------------
  def self.find_map_note(rgx)
    map = $game_map.get_map
    l_note = map.note.scan(rgx)
    l_note.each{ |off|
      return true if off
    }
      return false
    end
  
  def self.search_rgx(nota,rgxstart,rgxend)
      @notecontent = ""
      @rgx_start = false
      nota.split(/[\r\n]+/).each { |line|
      next if line.empty?
      case line
        when rgxstart
          @rgx_start = true
        when rgxend
          @rgx_start = false
        else
          if @rgx_start
            @notecontent += line
          end
        end
      }
      return @notecontent
    end
  
  #--------------------------------------------------------------------------
  # * Traduz uma string de acordo com uma matiz
  #     qqvalue : texto a ser traduzido
  #     index   : matriz de tradução
  #--------------------------------------------------------------------------
  def self.trans(qqvalue,index=nil)
    return qqvalue.capitalize if !index[qqvalue] && Vocab.method_defined?(qqvalue) == false
    return index[qqvalue].capitalize if index[qqvalue]
    return Vocab::qqvalue.capitalize if Vocab::qqvalue
  end
end
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  Esta classe altera o comportamento da classe original sem modifica-la
#==============================================================================
class Game_Map
  attr_accessor :map
  def get_map
    @map
  end
  
  def set_map_steps(steps)
    @map.encounter_step = steps
  end
  def set_map_troop_freq(id,cent)
    @map.encounter_list[id].weight = cent
  end
end
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This is a superclass of all windows in the game.
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # * Desenho do nome de itens
  #     item    : objeto
  #     x       : coordenada X
  #     y       : coordenada Y
  #     enabled : habilitar flag, translucido quando false
  #     width   : largura
  #--------------------------------------------------------------------------
  alias draw_item_name_space draw_item_name
  def draw_item_name(item, x, y, enabled = true, width = 172)
    return unless item
    draw_icon(item.icon_index, x, y, enabled)
    change_color(normal_color, enabled)
    draw_text(x + 32, y, width, line_height, item.name)
  end
end


CODE
    #--------------------------------------------------------------------------
  # SISTEMA DIA E NOITE (BY RAVEN) - v3.5 - WWW.RPGMENACE.COM.BR
  #--------------------------------------------------------------------------
  # * COMO USAR O SISTEMA DE DIA E NOITE
  # - BASTA QUE ESTE SCRIPT ESTEJA ACIMA DO MAIN
  # - PARA MUDAR A HORA INICIAL BASTA ALTERAR a variavel "START_TIME_INGAME"
  # - PARA MUDAR A VELOCIDADE DO TEMPO BASTA MUDAR A VARIAVEL "SEC_MIN" (< MAIS RAPIDO)
  # - PARA ALTERAR O TEMPO DE CADA CICLO BASTA ALTERAR A VARIAVEL "CICLOS"
  # - CONFORME ORIENTAÇÃO NOS COMENTARIOS
  #
  #********************************************************************
  # COMANDOS PUBLICOS PARA SEREM USADOS NO MAPA OU EVENTOS
  #********************************************************************
  # <daynight: off> - Se colocado no espaço de notas do mapa fará com que o
  #                   script não mude a tonalidade naquele mapa
  #
  # <daynight_troop> ciclo = [tempo, id_troop, %] phase = [id_troop, %] </daynight_troop>
  #                   - Se colocado no espaço de notas do mapa fará com que a
  #                   Tropa com o id "id_troop", mude as chances de aparecer para
  #                   a porcentagem (0~100) em "frequencia", durante o periodo
  #                   especificado em "phase" (nota: so serão alterados
  #                   tropas que estiverem na lista de encontros do mapa  
  #
  # <daynight_step> ciclo = [tempo,nºstep] phase = nº_step </daynight_step>
  #                   - Se colocado no espaço de notas do mapa fará com que as
  #                   chances de acontecer um encontro "steps" (menor mais chances)
  #                   durante um periodo especifico "phase"
  #                   caso o periodo não seja especificado, o valor de steps (passos)
  #                   será mantido conforme original
  #
  # $game_daynight.altTime(["min",10],["day",-3],["mes",-20],["ano",1970,true])
  #                 - pode alterar qualquer parte do tempo com qualquer valor
  #                   positivos ou negativos, se um 3º argumento for informado
  #                   (true) o valor será exato (não somara)
  # $game_daynight.timeIngame
  #                 - Imprime no debug a hora in game atual
  # $game_daynight.dateIngame
  #                 - Imprime no debug a data in game atual
  # $game_daynight.which_phase_name?
  #                 - Retorna o nome da fase do dia
  # $game_daynight.which_phase_id?
  #                 - Retorna o id da fase do dia (para popular variaveis)
  # $game_daynight.how_many_min?
  #                 - Retorna o minuto em jogo em formato 2 digitos
  # $game_daynight.min_ingame
  #                 - Retorna o minuto em jogo (para popular variaveis)
  # $game_daynight.how_many_hour?
  #                 - Retorna a hora em jogo em formato 2 digitos
  # $game_daynight.hour_ingame
  #                 - Retorna a hora em jogo (para popular variaveis)
  # $game_daynight.how_many_day?
  #                 - Retorna o dia em jogo eem formato 2 digitos
  # $game_daynight.day_ingame
  #                 - Retorna o dia em jogo (para popular variaveis)
  # $game_daynight.how_many_month?
  #                 - Retorna os meses em jogo em formato 2 digitos
  # $game_daynight.month_ingame
  #                 - Retorna os meses em jogo (para popular variaveis)
  # $game_daynight.how_many_month_name?(abr=false)
  #                 - Retorna os meses em formato de texto, se tiver argumento
  #                   retorna a abreviação
  # $game_daynight.how_many_year?
  #                 - Retorna os anos em jogo em formato 4 digitos
  # $game_daynight.year_ingame
  #                 - Retorna os anos em jogo (para popular variaveis)
  #--------------------------------------------------------------------------
  # COMANDOS PARA MENSAGENS
  #--------------------------------------------------------------------------
  # \Data   - Exibe na janela a data atual (dd/M/yyyy)
  # \Time   - Exibe na janela a hora atual (H:m)
  # \Phase  - Exibe na janela o periodo atual atual
  # \Minute - Exibe na janela os minutos atuais
  # \Hour   - Exibe na janela as horas atuais
  # \Day    - Exibe na janela os dias atuais
  # \Month  - Exibe na janela os meses atuais
  # \Year   - Exibe na janela os anos atuais
  #--------------------------------------------------------------------------
$registro = [] if $registro.nil?
$registro << ["BFK DayNight",3.5]
class << DataManager
  #--------------------------------------------------------------------------
  # * Salvar a criação de conteúdo
  #--------------------------------------------------------------------------
  alias daynight_make_save_contents make_save_contents
  def make_save_contents
    contents = daynight_make_save_contents
    contents[:daynight] = $game_daynight
    contents
  end
  #--------------------------------------------------------------------------
  # * Extrair conteúdo salvo
  #     contents : matriz de quests
  #--------------------------------------------------------------------------
  alias daynight_extract_save_contents extract_save_contents
  def extract_save_contents(contents)
    daynight_extract_save_contents(contents)
    $game_daynight = contents[:daynight]
  end
end
#==============================================================================
# ** MODULO BKF
#------------------------------------------------------------------------------
#  Este é o modulo principal para scripts feitos por este core
#==============================================================================
module BFK
  self.modular("BFK Core",1.0)
  #--------------------------------------------------------------------------
  # * Aqui se encontra todas as variaveis para configuração e instalação
  #--------------------------------------------------------------------------
  module DayNight
    #--------------------------------------------------------------------------
    # * BFK_DayNight_Periodos = 1/Dia 2/tarde 3/Noite 4/Madrugada
    #--------------------------------------------------------------------------
    START_TIME_INGAME = [00,21,30,12,1979]   # (min,hora,dia, mes, ano) para o inicio do jogo
    SEC_MIN = 20 # quantos milesimos segundos dura o minuto em jogo?
    CICLOS = [60,24,30,12] # (minutos/hora, Horas/dias, dias/meses, meses ano)
    MONTH_NAMES =  [["Meses","abrev"],["Janeiro","Jan"],["Fevereiro","Fev"],
                    ["Março","Mar"],["Abril","Abr"],["Maio","Mai"],["Junho","Jun"],
                    ["Julho","Jul"],["Agosto","Ago"],["Setembro","Set"],
                    ["Outubro","Out"], ["Novembro","Nov"], ["Dezembro","Dez"]]
    CICLOS_NAMES = [["horas","hora"],["minutos","min"],["dias","dia"],["mêses","mês"], ["anos","ano"]]
    PHASE = [
      ["dia",Tone.new(0,0,0),[6,16]], # [ NOME_DO_CICLO, TONALIDADE, [HORA DE INICIO, HORA DO FIM]
      ["tarde",Tone.new(-32,  -96, -66),[17,20]],
      ["noite",Tone.new(-110, -110, -110),[21,3]],
      ["madrugada",Tone.new(-66, -66, -66),[4,5]]
      ]
    PHASE_CICLO = CICLOS[1]
    PHASE_D = (Graphics.frame_rate * CICLOS[0])/SEC_MIN #quanto vai demorar para a tansição completar
    MENU_NAME = "Tempo" #texto da Opção do Menu
    MENU_ACTIVE = true # Ativa a Opção de controlar o tempo no menu
    MENU_TIME = true # Ativa a janela de tempo no menu
    MENU_DATE = true # Ativa a Janela de data no menu
    MAX_DIGIT = 6 # (4 PARA SÓ AS HORAS, E 12 PARA DATA COMPLETA)
    DISPLAY_HUD = true # Exibe a Janela de hora no mapa
    DISPLAY_HUD_POS = 1 # Posição que ficará a janela de hoa no mapa,
                          # 0 para canto superior esquerdo
                          # 1 para canto superior direito
                          # 2 para canto inferior direito
                          # 3 para canto inferior esquerdo
    #--------------------------------------------------------------------------
    # * Comentando a linha a baixo, o programa não vai popular as variaveis
    # será possivel apanhalas domente atraves dos metodos how_many e which_
    #--------------------------------------------------------------------------
    VARIABLE = [1,2,3,4,5,6]  # [VAR001 = phase, VAR002 = MIN, VAR003 = HORA,
                              #  VAR004 = DIA, VAR005 = MES, VAR006 = ANO]
    SWITCH = [1,2,3,4]        # [S001 = Dia, S002=Tarde, s003=Noite, S004 = Madrugada
    #--------------------------------------------------------------------------
    # * ATENÇÃO NÃO ALTERAR AS VARIAVEIS ABAIXO (ELAS PODEM MUDAR DEPENDENDO DA ATUALIZAÇÃO
    #--------------------------------------------------------------------------
    RGXMAP = /<(?:daynight):[ ]*(?:off)>/i
    #--------------------------------------------------------------------------
    RGXMAP_STEP_ST = /<(?:DAYNIGHT_STEP|daynight step)>/i
    RGXMAP_STEP_ED = /<\/(?:DAYNIGHT_STEP|daynight step)>/i
    RGXMAP_TROOP_ST = /<(?:DAYNIGHT_TROOP|daynight troop)>/i
    RGXMAP_TROOP_ED = /<\/(?:DAYNIGHT_TROOP|daynight troop)>/i
    RGX_VALUES_STEPS = /(\w+)\s*[=]\s*\[?(\d{1,})[,]?(\d{1,})?\]?/xi
    RGX_VALUES_TROOPS = /(\w+)\s*[=]\s*\[(\d{1,})[,]?(\d{1,})?[,]?(\d{1,})?\]/xi
    MENU_SPACE = 18
    MENU_RECT = 10
    #--------------------------------------------------------------------------
  end
end
#==============================================================================
# ** DayNight
#------------------------------------------------------------------------------
#  Esta é a superclasse para todo o controle de tempo no jogo
#==============================================================================
class DayNight
  attr_accessor :minutos
  attr_accessor :phase_ingame
  attr_accessor :trans
  #--------------------------------------------------------------------------
  # * Inicia o Objeto com as configurações iniciais
  #--------------------------------------------------------------------------
  def initialize
    return if $game_map == nil
    @minutos = change_minutes(BFK::DayNight::START_TIME_INGAME) unless @minutos
    @min_seg = 0
    @trans = nil
    map = $game_map.get_map
    @step_original = map.encounter_step
    clear_daynight
    refresh
    # aqui é a saida do menu =) ele refaz o initialize
  end
  #--------------------------------------------------------------------------
  # * Verifica o estado de transição
  #--------------------------------------------------------------------------
  def trans
    @trans
  end
  #--------------------------------------------------------------------------
  # * Recupera o valor original da lista de encontro
  #--------------------------------------------------------------------------
  def bak_enconterlist(map_id,id)
    mapa = load_data(sprintf("Data/Map%03d.rvdata2",map_id))
    return mapa.encounter_list[id]
  end
  #--------------------------------------------------------------------------
  # * recupera o valor original dos passos
  #--------------------------------------------------------------------------
  def bak_enconterstep(map_id)
    mapa = load_data(sprintf("Data/Map%03d.rvdata2",map_id))
    return mapa.encounter_step
  end
  #--------------------------------------------------------------------------
  # * Aqui define o index dos comandos que serão executados
  # * Priorisa os comandos de cima para baixo.
  #--------------------------------------------------------------------------
  def index_stat_troops(conteudo)
    i = 0
    ary =[]
    conteudo.each{|value|
      if min_ingame == value[3].to_i && (value[0] == "min" || value[0] == "minute")
        ary << i
      elsif hour_ingame == value[3].to_i && (value[0] == "hour" || value[0] == "hora")
        ary << i
      elsif day_ingame == value[1].to_i && (value[0] == "day" || value[0] == "dia")
        ary << i
      elsif month_ingame == value[1].to_i && (value[0] == "month" || value[0] == "mes")
        ary << i
      elsif year_ingame == value[1].to_i && (value[0] == "year" || value[0] == "ano")
        ary << i
      elsif phase_ingame[1] == value[0]  
        ary << i
      end
      i += 1
    }
    return ary.reverse!
  end
  #--------------------------------------------------------------------------
  # * Aqui define como procede tropas nos encontros
  # * Busca o valor <daynight_troops></daynight_troops>
  # * Ira verificar se há alteração na taxa de encontros.
  #--------------------------------------------------------------------------
  def daynight_enconter_troop
    map = $game_map.get_map
    i = 0
    rgxstart = BFK::DayNight::RGXMAP_TROOP_ST
    rgxend = BFK::DayNight::RGXMAP_TROOP_ED
    notas = BFK.search_rgx(map.note,rgxstart,rgxend)
    unless notas.empty?
      arys = notas.scan(BFK::DayNight::RGX_VALUES_TROOPS)
      for troops in map.encounter_list
        comand_alt = arys.collect{|condit| condit if condit[1].to_i == troops.troop_id}.compact
        return if comand_alt.empty?
        ix_chg_fq = index_stat_troops(comand_alt)
        if ix_chg_fq.empty?
          freq = bak_enconterlist($game_map.map_id,i).weight
          $game_map.set_map_troop_freq(i,freq)
        else
          #mudar
          ix_chg_fq.each{|troop|
            freq = comand_alt[troop][2].to_i
            frq = freq.between?( 0, 100)? freq : (freq > 100) ? 100 : 0
            $game_map.set_map_troop_freq(i,frq)
          }
        end
        i += 1
      end
    end    
  end
  #--------------------------------------------------------------------------
  # * Aqui define como procede os passos nos encontros
  # * Busca o valor <daynight_steps></daynight_steps>
  # * Quanto menor o valor de passos mais encontros existirá.
  #--------------------------------------------------------------------------
  def daynight_enconter_rate
    map = $game_map.get_map
    rgxstart = BFK::DayNight::RGXMAP_STEP_ST
    rgxend = BFK::DayNight::RGXMAP_STEP_ED
    notas = BFK.search_rgx(map.note,rgxstart,rgxend)
    unless notas.empty?
      arys = notas.scan(BFK::DayNight::RGX_VALUES_STEPS)
      steps_id = index_stat_steps(arys)
      if steps_id
        steps = (arys[steps_id][2])? arys[steps_id][2].to_i : arys[steps_id][1].to_i
        $game_map.set_map_steps(steps)
      else
        $game_map.set_map_steps(bak_enconterstep(map.map_id))
      end
    end
  end
  #--------------------------------------------------------------------------
  # Ajuda na veificação do status dos steps
  #--------------------------------------------------------------------------
  def index_stat_steps(conteudo)
    return conteudo.index{|value|
        if value[0] == "min" || value[0] == "minute"
          min_ingame == value[1].to_i
        elsif value[0] == "hour" || value[0] == "hora"
          hour_ingame == value[1].to_i
        elsif (value[0] == "day" || value[0] == "dia") && value[2]
          day_ingame == value[1].to_i
        elsif value[0] == "month" || value[0] == "mes"
          month_ingame == value[1].to_i
        elsif value[0] == "year" || value[0] == "ano"
          year_ingame == value[1].to_i
        elsif phase_ingame[1] == value[0]  
          phase_ingame[1] == value[0]
      end
    }
  end
  #--------------------------------------------------------------------------
  # * Atualiza quadro a quadro as opções de tempo
  #--------------------------------------------------------------------------
  def update
    clear_daynight
    timer
    refresh
    daynight_enconter_troop
    daynight_enconter_rate
  end
  #--------------------------------------------------------------------------
  # * Inicia o timer
  #--------------------------------------------------------------------------
  def timer    
    @min_seg =  Graphics.frame_count % BFK::DayNight::SEC_MIN
    if (@min_seg +1) == BFK::DayNight::SEC_MIN
      @minutos += 1
    end
  end
  #--------------------------------------------------------------------------
  # * Atualizer de imediato as opções de tempo
  #--------------------------------------------------------------------------
  def refresh
    update_phases
    varable_refresh
  end
  #--------------------------------------------------------------------------
  # * transforma o tempo em min
  #--------------------------------------------------------------------------
  def change_minutes(ary)
    ciclos = BFK::DayNight::CICLOS
    min = 0
    min = ary[0]
    min +=  (ary[1] * ciclos[0])
    min +=  (((ary[2] - 1) * ciclos[1])*ciclos[0])
    min +=  ((((ary[3].to_i - 1) * ciclos[2])*ciclos[1])*ciclos[0])
    min +=  ((((ary[4] * ciclos[3])* ciclos[2])*ciclos[1])*ciclos[0])
    return min
  end
  #--------------------------------------------------------------------------
  # * limpa a tela caso o mapa tenha o dia e noite desligado
  #--------------------------------------------------------------------------
  def clear_daynight
    @daynight_off = $game_map.daynight_off?
    return if @daynight_off == false
    set_trans(false)
    $game_map.screen.start_tone_change(Tone.new(0, 0, 0), 0)
  end
  #--------------------------------------------------------------------------
  # * Atualiza os periodos do dis (phases)
  #--------------------------------------------------------------------------
  def update_phases
    max_hora = BFK::DayNight::PHASE_CICLO
    p_phase = 0
    BFK::DayNight::PHASE.each { |index|
      hora = index[2]
      if hora[0] > hora[1] # se for transição de 24h para 0h
        if hour_ingame.between?( 0, hora[1] ) || hour_ingame.between?( hora[0] ,max_hora )
          @phase_ingame = [p_phase,index[0]]
          transitor_phase(index,p_phase) if @daynight_off == false
        end
      else
        # se NÃO for transição de 24h para 0h
        if hour_ingame.between?( hora[0], hora[1] )
          @phase_ingame = [p_phase,index[0]]
          transitor_phase(index,p_phase) if @daynight_off == false
        end
      end
      p_phase += 1
    } #do
    $game_variables[BFK::DayNight::VARIABLE[0]] = @phase_ingame[0] if BFK::DayNight::VARIABLE
    switch_refresh(@phase_ingame[0],BFK::DayNight::SWITCH)
  end
  #--------------------------------------------------------------------------
  # * Atualiza a tela para as transições de tela dos periodos (phases)
  #--------------------------------------------------------------------------
  def transitor_phase(index,p_phase)
    hora = index[2]
    phase = BFK::DayNight::PHASE
    duration = 0
    duration =  (Graphics.frame_rate * BFK::DayNight::SEC_MIN)/3
    rew = ((p_phase -1) < 0) ? (phase.count)-1 : (p_phase -1)
    if hour_ingame == hora[0] && @trans == nil
      #transição no começo da hora
      $game_map.screen.start_tone_change(phase[rew][1], 0)
      @trans = true
      $game_map.screen.start_tone_change(index[1], duration)
    elsif @trans == true
      @trans = false if @tone_duration == 0
    else
      #fora da hora de transição
      @trans = nil if @trans == false && hour_ingame != hora[0]
      $game_map.screen.start_tone_change(index[1], 0)
    end
  end
  #--------------------------------------------------------------------------
  # * retorna os minutos em suas variaveis
  #--------------------------------------------------------------------------
  def min_ingame(min=nil)
    unless min
      return @minutos % BFK::DayNight::CICLOS[0]
    else
      return min % BFK::DayNight::CICLOS[0]
    end
  end
  #--------------------------------------------------------------------------
  # * retorna as horas em suas variaveis
  #--------------------------------------------------------------------------
  def hour_ingame(min=nil)
    ciclos = BFK::DayNight::CICLOS
    unless min
      return  hour = (@minutos / ciclos[0]) % ciclos[1]
    else
      return  hour = (min / ciclos[0]) % ciclos[1]
    end
  end
  #--------------------------------------------------------------------------
  # * retorna os dias em suas variaveis
  #--------------------------------------------------------------------------
  def day_ingame(min=nil)
    ciclos = BFK::DayNight::CICLOS
    unless min
      return day = (((@minutos / ciclos[0]) / ciclos[1])% ciclos[2]) +1
    else
      return day = (((min / ciclos[0]) / ciclos[1])% ciclos[2]) +1
    end
  end
  #--------------------------------------------------------------------------
  # * retorna os meses em suas variaveis
  #--------------------------------------------------------------------------
  def month_ingame(min=nil)
    ciclos = BFK::DayNight::CICLOS
    unless min
      return month = ((((@minutos / ciclos[0]) / ciclos[1]) / ciclos[2]) % ciclos[3])+1
    else
      return month = ((((min / ciclos[0]) / ciclos[1]) / ciclos[2]) % ciclos[3])+1
    end
  end
  #--------------------------------------------------------------------------
  # * retorna os anos em suas variaveis
  #--------------------------------------------------------------------------
  def year_ingame(min=nil)
    ciclos = BFK::DayNight::CICLOS
    unless min
      return year = ((((@minutos / ciclos[0]) / ciclos[1]) / ciclos[2]) / ciclos[3])
    else
      return year = ((((min / ciclos[0]) / ciclos[1]) / ciclos[2]) / ciclos[3])
    end
  end
  #--------------------------------------------------------------------------
  # * Atualiza as variaveis dos periodos
  #--------------------------------------------------------------------------
  def varable_refresh
    if BFK::DayNight::VARIABLE
      $game_variables[BFK::DayNight::VARIABLE[1]] = min_ingame
      $game_variables[BFK::DayNight::VARIABLE[2]] = hour_ingame
      $game_variables[BFK::DayNight::VARIABLE[3]] = day_ingame
      $game_variables[BFK::DayNight::VARIABLE[4]] = month_ingame
      $game_variables[BFK::DayNight::VARIABLE[5]] = year_ingame
    end
  end
  #--------------------------------------------------------------------------
  # * Atualiza as Switchs dos periodos do dias (phases)
  #--------------------------------------------------------------------------
  def switch_refresh(value,id_switch)
    for id in id_switch
      $game_switches[id.to_i] = (id_switch.index(id) == value.to_i) ? true : false
    end
  end
  #--------------------------------------------------------------------------
  # * define se a transição esta ocorrendo
  #--------------------------------------------------------------------------
  def set_trans(transition=nil)
     @trans = transition
  end
  #--------------------------------------------------------------------------
  # * Altera o tempo usar um array [tempo,valor,fixo] fixo é sempre true
  #--------------------------------------------------------------------------
  def altTime(*arg)
    ciclos = BFK::DayNight::CICLOS
    allmin= 0
    arg.each{|value|
      allmin = @minutos unless value[2]
      case value[0]
        when "min" , "minute" , "minuto"
          allmin += value[1]
        when "h" , "hour" , "hora"
          allmin += (value[1] * ciclos[0])
        when "d" , "day" , "dia"
          allmin += (((value[1] -1) * ciclos[1])*ciclos[0])
        when "m" , "mouth" , "mes"
          allmin += ((((value[1] -1) * ciclos[2])*ciclos[1])*ciclos[0])
        when "y" , "year" , "ano"
          allmin += ((((value[1] * ciclos[3])* ciclos[2])*ciclos[1])*ciclos[0])
      end
    }
    @minutos = allmin
    set_trans(false)
  end
  #--------------------------------------------------------------------------
  # * retorna uma String com a Hora do jogo
  #--------------------------------------------------------------------------
  def timeIngame
    sprintf("%02d:%02d",hour_ingame,min_ingame )
  end
  #--------------------------------------------------------------------------
  # * Retorna uma string com a data do jogo
  #--------------------------------------------------------------------------
  def dateIngame
    mes = how_many_month_name?(true)
    sprintf("%02d/%s/%s",day_ingame,mes,year_ingame )
  end
  #--------------------------------------------------------------------------
  # * Retorna o nome do periodo (dia, tarde, noite, etc.)
  #--------------------------------------------------------------------------
  def which_phase_name?
    @phase_ingame[1].capitalize
  end
  #--------------------------------------------------------------------------
  # * Retorna o id da variavel do periodo (bom para usar com variaveis)
  #--------------------------------------------------------------------------
  def which_phase_id?
    @phase_ingame[0].to_i
  end
  #--------------------------------------------------------------------------
  # * Retorna o minuto atual (bom para usar com variaveis)
  #--------------------------------------------------------------------------
  def how_many_min?
    sprintf("%02d",min_ingame )
  end
  #--------------------------------------------------------------------------
  # * Retorna a hora atual (bom para usar com variaveis)
  #--------------------------------------------------------------------------
  def how_many_hour?
    sprintf("%02d",hour_ingame )
  end
  #--------------------------------------------------------------------------
  # * Retorna o dis atual (bom para usar com variaveis)
  #--------------------------------------------------------------------------
  def how_many_day?
    sprintf("%02d",day_ingame )
  end
  #--------------------------------------------------------------------------
  # * Retorna o mês atual (bom para usar com variaveis)
  #--------------------------------------------------------------------------
  def how_many_month?
    sprintf("%02d",month_ingame )
  end
  #--------------------------------------------------------------------------
  # * Retorna o mês atual (bom para usar com variaveis)
  #--------------------------------------------------------------------------
  def how_many_month_name?(abr=false)
    if abr == false
      BFK::DayNight::MONTH_NAMES[month_ingame.to_i][0]
    else
      BFK::DayNight::MONTH_NAMES[month_ingame.to_i][1]
    end
  end
  #--------------------------------------------------------------------------
  # * Retorna o ano atual (bom para usar com variaveis)
  #--------------------------------------------------------------------------
  def how_many_year?
    sprintf("%04d",year_ingame )
  end
end
#==============================================================================
# ** Display_Phase
#------------------------------------------------------------------------------
#  Esta é a classe que controla o grsfico de periodo no relogio.
#==============================================================================
class Display_Phase < Sprite_Base
  #--------------------------------------------------------------------------
  # * Inicializa o sprite
  #--------------------------------------------------------------------------
  def initialize(x,y)
    super(nil)
    self.x = x+4
    self.y = y +4
    self.z = 2
    self.bitmap = Cache.system("weather_mini")
    refresh
  end
  #--------------------------------------------------------------------------
  # * Atualiza o sprite no mapa
  #--------------------------------------------------------------------------
  def update_phase
    @phase = $game_daynight.which_phase_id?
    @index_phase_picy = @phase
    @index_phase_picx = 0
  end
  #--------------------------------------------------------------------------
  # * Inicializa o sprite
  #--------------------------------------------------------------------------
  def update_phase_pic
    self.src_rect.set(64*@index_phase_picx, 64*@index_phase_picy, 64, 64)
    self.zoom_x = 0.5
    self.zoom_y = 0.5
  end
  #--------------------------------------------------------------------------
  # * Metodo utilizado pela Scane para atualizar a imagem
  #--------------------------------------------------------------------------
  def refresh
    update_phase
    update_phase_pic
  end  
end
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  Esta é a superclasse para todas as janelas no jogo.
#==============================================================================
class Window_Base < Window
  alias daynight_convert_escape_characters convert_escape_characters
  def convert_escape_characters(text)
    result = daynight_convert_escape_characters(text)
    result.gsub!(/\eDate/i)          { $game_daynight.dateIngame }
    result.gsub!(/\eTime/i)          { $game_daynight.timeIngame }
    result.gsub!(/\ePhase/i)          { $game_daynight.which_phase_name? }
    result.gsub!(/\eMinute/i)          { $game_daynight.how_many_min? }
    result.gsub!(/\eHour/i)          { $game_daynight.how_many_hour? }
    result.gsub!(/\eDay/i)          { $game_daynight.how_many_day? }
    result.gsub!(/\eMonth/i)          { $game_daynight.how_many_month? }
    result.gsub!(/\eYear/i)          { $game_daynight.how_many_year? }
    result
  end
end
#==============================================================================
# ** Window_Display_Time
#------------------------------------------------------------------------------
#  Janela do relogio do mapa
#==============================================================================
class Window_Display_HUD < Window_Base
  #--------------------------------------------------------------------------
  # * Inicialização do objeto
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, window_width, fitting_height(1))
    self.opacity = 0
    refresh
  end  
  #--------------------------------------------------------------------------
  # * define o tamanho da janela
  #--------------------------------------------------------------------------  
  def window_width
    return 128
  end
  #--------------------------------------------------------------------------
  # * Metodo utilizado pela Scane para atualizar a imagem
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_background(contents.rect)
    draw_text(contents.rect, hora, 1)
  end
  #--------------------------------------------------------------------------
  # * Metodo para construir o Background do relogio
  #--------------------------------------------------------------------------
  def draw_background(rect)
    temp_rect = rect.clone
    temp_rect.width /= 2
    contents.gradient_fill_rect(temp_rect, back_color2, back_color1)
    temp_rect.x = temp_rect.width
    contents.gradient_fill_rect(temp_rect, back_color1, back_color2)
  end
  #--------------------------------------------------------------------------
  # * Metodo para definir a posição do  relogio
  #--------------------------------------------------------------------------
  def pos_window_time
    x = 0
    y = 0
    case BFK::DayNight::DISPLAY_HUD_POS
    when 1
      x = Graphics.width - self.width
    when 2
      x = Graphics.width - self.width
      y = Graphics.height - self.height
    when 3
      y = Graphics.height - self.height
    end
    self.x = x
    self.y = y
  end
  #--------------------------------------------------------------------------
  # * Aquisição do valor das horas
  #--------------------------------------------------------------------------
  def hora
    $game_daynight.timeIngame
  end
  #--------------------------------------------------------------------------
  # * Aquisição da cor do plano de fundo 1
  #--------------------------------------------------------------------------
  def back_color1
    Color.new(0, 0, 0, 192)
  end
  #--------------------------------------------------------------------------
  # * Aquisição da cor do plano de fundo 2
  #--------------------------------------------------------------------------
  def back_color2
    Color.new(0, 0, 0, 0)
  end
  #--------------------------------------------------------------------------
  # * Abertura da janela
  #--------------------------------------------------------------------------
  def open
    refresh
    super
  end
end
#==============================================================================
# ** Window_DayNight_Time
#------------------------------------------------------------------------------
#  Esta é a classe para a janela de tempo do jogo.
#==============================================================================

class Window_DayNight_Time < Window_Base
  #--------------------------------------------------------------------------
  # * Inicialização do objeto
  #--------------------------------------------------------------------------
  def initialize
    @n = 0
    @n += 1 if BFK::DayNight::MENU_DATE
    @n += 1 if BFK::DayNight::MENU_TIME
    super(0, 0, window_width, fitting_height(@n))
    refresh
  end
  #--------------------------------------------------------------------------
  # * Aquisição da largura da janela
  #--------------------------------------------------------------------------
  def window_width
    return 160
  end
  #--------------------------------------------------------------------------
  # * Desenho do tempo
  #     hora   : hora
  #     phase  : Periodo (phase)
  #     x      : coordenada X
  #     y      : coordenada Y
  #     width  : largura
  #--------------------------------------------------------------------------
  def draw_daynight_time(hora, phase, x, y, width)
    cx = text_size(hora).width
    change_color(system_color)
    draw_text(x, y, width -cx -2, line_height, phase, 1)
    change_color(normal_color)
    draw_text(x, y, width , line_height, hora,2)
  end
  #--------------------------------------------------------------------------
  # * Desenho do tempo
  #     hora   : hora
  #     phase  : Periodo (phase)
  #     x      : coordenada X
  #     y      : coordenada Y
  #     width  : largura
  #--------------------------------------------------------------------------
  def draw_daynight_date(date, x, y, width)
    change_color(normal_color)
    draw_text(x, y, width - 5, line_height, date,1)
  end
  #--------------------------------------------------------------------------
  # * Renovação
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    ny = (@n >1) ?  line_height : 0
    $game_daynight.update_phases
    draw_daynight_time(hora,dayNight_Phase,0, 0, contents.width - 8) if BFK::DayNight::MENU_TIME
    draw_daynight_date(date,4,ny, contents.width - 8) if BFK::DayNight::MENU_DATE
  end
  #--------------------------------------------------------------------------
  # * Aquisição do valor das horas
  #--------------------------------------------------------------------------
  def hora
    $game_daynight.timeIngame
  end
  #--------------------------------------------------------------------------
  # * Aquisição do nome da Phase
  #--------------------------------------------------------------------------
  def dayNight_Phase
    $game_daynight.which_phase_name?
  end  
  #--------------------------------------------------------------------------
  # * Aquisição do valor da data
  #--------------------------------------------------------------------------
  def date
    $game_daynight.dateIngame
  end
  #--------------------------------------------------------------------------
  # * Abertura da janela
  #--------------------------------------------------------------------------
  def open
    refresh
    super
  end
end
#==============================================================================
# ** Window_NumberInput
#------------------------------------------------------------------------------
#  Esta janela é utilizada para o comando de eventos [Armazenar Número]
#==============================================================================
class Window_TimeInput < Window_Selectable
  def initialize
    super(0, 0, 0, 0)
    @digits_max = BFK::DayNight::MAX_DIGIT #( 4 para alterar apenas hora - 12 para alteração completa )
    @index = 0
    @number = 0
    @handler = {}
    @matriz = define_matriz
    self.z +=1
  end
  #--------------------------------------------------------------------------
  # * Define um array com os digitos divididos que será
  #--------------------------------------------------------------------------
  def define_matriz
    min = sprintf("%02d",$game_daynight.min_ingame)
    hour = sprintf("%02d",$game_daynight.hour_ingame)
    day = sprintf("%02d",$game_daynight.day_ingame)
    month = sprintf("%02d",$game_daynight.month_ingame)
    year = sprintf("%04d",$game_daynight.year_ingame)
    return a =[
    hour[0].to_i,hour[1].to_i,
    min[0].to_i,min[1].to_i,
    day[0].to_i,day[1].to_i,
    month[0].to_i,month[1].to_i,
    year[0].to_i,year[1].to_i,year[2].to_i,year[3].to_i
    ]
  end
  #--------------------------------------------------------------------------
  # * Define inicia a janela e seu conteudo
  #--------------------------------------------------------------------------
  def start
    update_placement
    create_contents
    open
    refresh
    draw_labels
    @index = 0
  end
  #--------------------------------------------------------------------------
  # * Atualiza a caixa
  #--------------------------------------------------------------------------
  alias daynight_update update
  def update
    if open? && active
      daynight_process_cursor_move
      process_digit_change
      update_cursor
      refresh
    end
    daynight_update
  end
  #--------------------------------------------------------------------------
  # * Renovação
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_labels
    change_color(normal_color)
    @digits_max.times do |i|
      rect = item_rect(i)
      rect.x += 1
      contents.font.size = 32
      draw_text(rect, @matriz[i],1)
      non_item_rect(i)
    end
  end
   #--------------------------------------------------------------------------
  # * Movimento do cursor para direita
  #     wrap : cursor retornar a primeira ou ultima posição
  #--------------------------------------------------------------------------
  def daynight_cursor_right(wrap)
    if @index < @digits_max - 1 || wrap
      @index = (@index + 1) % @digits_max
    end
  end
  #--------------------------------------------------------------------------
  # * Movimento do cursor para esquerda
  #     wrap : cursor retornar a primeira ou ultima posição
  #--------------------------------------------------------------------------
  def daynight_cursor_left(wrap)
    if @index > 0 || wrap
      @index = (@index + @digits_max - 1) % @digits_max
    end
  end
  #--------------------------------------------------------------------------
  # * Atualização do cursor
  #--------------------------------------------------------------------------
  alias dynight_update_cursor update_cursor
  def update_cursor
    cursor_rect.set(item_rect(@index))
  end
  #--------------------------------------------------------------------------
  # * Execução do movimento do cursor
  #--------------------------------------------------------------------------
  def daynight_process_cursor_move
    return unless active
    last_index = @index
    daynight_cursor_right(Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT)
    daynight_cursor_left (Input.trigger?(:LEFT))  if Input.repeat?(:LEFT)
    Sound.play_cursor if @index != last_index
  end
  #--------------------------------------------------------------------------
  # * Aquisição do retangulo para desenhar o item
  #     index : índice do item
  #--------------------------------------------------------------------------
  def item_rect(index)
    a = 0
    space = BFK::DayNight::MENU_SPACE
    space2 = BFK::DayNight::MENU_RECT * 2
    a = 1 if index > 1
    a = 2 if index > 3
    a = 3 if index > 5
    a = 4 if index > 7
    Rect.new(((index + a) * 20)+ space,space2, 20, line_height * 1.5)
  end
  #--------------------------------------------------------------------------
  # * Definição das caixas de numeros para edição
  #--------------------------------------------------------------------------
  def non_item_rect(index)
    space = BFK::DayNight::MENU_SPACE
    space2 = BFK::DayNight::MENU_RECT * 2
    draw_text((index  * 20)+ space, space2, 20, line_height * 1.5, ":",1) if index == 2
    draw_text((index  * 20)+ space, space2, 20, line_height * 1.5, "-",1) if index == 5
    draw_text((index  * 20)+ space, space2, 20, line_height * 1.5, "/",1) if index == 8
    draw_text((index  * 20)+ space, space2, 20, line_height * 1.5, "/",1) if index == 11
  end
  #--------------------------------------------------------------------------
  # * Execução da mudança de digito
  #--------------------------------------------------------------------------
  def process_digit_change()
    return unless active
    ciclo = [
            BFK::DayNight::CICLOS[1].to_s,BFK::DayNight::CICLOS[1].to_s,
            BFK::DayNight::CICLOS[0].to_s,BFK::DayNight::CICLOS[0].to_s,
            BFK::DayNight::CICLOS[2].to_s,BFK::DayNight::CICLOS[2].to_s,
            BFK::DayNight::CICLOS[3].to_s,BFK::DayNight::CICLOS[3].to_s
            ]
    if Input.repeat?(:UP) || Input.repeat?(:DOWN)
      Sound.play_cursor
      case @index
        when 0,6
          r = ciclo[@index][0].to_i + 1; u = 1; d = ciclo[@index][0].to_i
        when 1,5
          r = (@matriz[@index -1]< ciclo[@index][0].to_i) ? 10 :
          (ciclo[@index][1].to_i < 1)? 1 : ciclo[@index][1].to_i; u = 1
          d = (@matriz[@index -1]< ciclo[@index][0].to_i) ? 9 :
          ciclo[@index][1].to_i - 1
        when 2
          r = (ciclo[@index][0].to_i < 1)? 1 : ciclo[@index][0].to_i; u = 1
          d = ciclo[@index][1].to_i - 1
        when 4
          r = ciclo[@index][0].to_i + 1; u = 1;
          d = (ciclo[@index][0].to_i > 0)? ciclo[@index][0].to_i - 1 : 9
        when 7
          r = (@matriz[@index -1]< ciclo[@index][0].to_i) ? 10 :
          (ciclo[@index][1].to_i < 1)? 1 : ciclo[@index][1].to_i + 1; u = 1
          d = (@matriz[@index -1]< ciclo[@index][0].to_i) ? 9 :
          ciclo[@index][1].to_i - 1
        else
          r = 10; u = 1; d = 9
      end
      @matriz[@index] = (@matriz[@index] + u) % r  if Input.repeat?(:UP)
      @matriz[@index] = (@matriz[@index] + d) % r if Input.repeat?(:DOWN)
      #if numero quebrado resetar no maximo
      @matriz[1] = 0 if @matriz[0] >= ciclo[0][0].to_i && @matriz[1] >= ciclo[0][1].to_i
      @matriz[5] = 0 if @matriz[4] >= ciclo[4][0].to_i && @matriz[5] >= ciclo[4][1].to_i
      @matriz[5] = 1 if @matriz[4] == 0 && @matriz[5]==0
      @matriz[7] = 0 if @matriz[6] >= ciclo[6][0].to_i && @matriz[7] > ciclo[6][1].to_i
    end
  end
  #--------------------------------------------------------------------------
  # * Define os Labeis do tempo
  #--------------------------------------------------------------------------
  def draw_labels
    names = BFK::DayNight::CICLOS_NAMES
    contents.font.size = 20
    change_color(system_color)
    space = BFK::DayNight::MENU_SPACE
    names.each_index do |i|
      return if @digits_max/2 == i
      w = text_size(names[i][0])
      draw_text( (i * 63)+space,0,w.width + space,line_height, names[i][1].capitalize)
    end
  end
  #--------------------------------------------------------------------------
  # * Atualização da posição da janela
  #--------------------------------------------------------------------------
  def update_placement
    self.width = @digits_max * 20 + padding * 2 +  BFK::DayNight::MENU_SPACE * 6
    self.height = fitting_height(3)
    self.x = (Graphics.width - width) / 2
    self.y = (Graphics.height - height) / 2
  end
  #--------------------------------------------------------------------------
  # * Atualização com ok da janela
  #--------------------------------------------------------------------------
  def daynight_ok_process
    Sound.play_ok
    a = [@matriz[2].to_s + @matriz[3].to_s, @matriz[0].to_s + @matriz[1].to_s, @matriz[4].to_s + @matriz[5].to_s,
    @matriz[6].to_s + @matriz[7].to_s, @matriz[8].to_s + @matriz[9].to_s + @matriz[10].to_s + @matriz[11].to_s]
    return a.collect!{|x| x.to_i}
    end
end
#==============================================================================
# ** Window_MenuCommand
#------------------------------------------------------------------------------
#  Esta janela exibe os comandos do menu.
#==============================================================================

class Window_MenuCommand < Window_Command
  #--------------------------------------------------------------------------
  # * Adição de comandos próprios
  #--------------------------------------------------------------------------
  alias dn_add_original_commands add_original_commands
  def add_original_commands
    dn_add_original_commands
    add_command(BFK::DayNight::MENU_NAME, :daynight, daynight_enabled)
  end
  #--------------------------------------------------------------------------
  # * Verifica se o mnu dia e noite pode ser exibido no menu
  #--------------------------------------------------------------------------
  def daynight_enabled
    BFK::DayNight::MENU_ACTIVE
  end
end
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  Esta classe altera o comportamento da classe original sem modifica-la
#==============================================================================
class Game_Map
  attr_reader :original_list
  attr_reader :original_step
  attr_reader :daynight_off
  #--------------------------------------------------------------------------
  # * FUNÇÃO QUE AUXILIA NA BUSCA DE TAGS (ESTA FUNÇÃO SERÁ MODIFICADA PELAS ATUALIZAÇÕES
  #--------------------------------------------------------------------------
  def find_map_note(rgx)
    l_note = @map.note.scan(rgx)
    l_note.each{ |off|
      return true if off
    }
      return false
    end
  #--------------------------------------------------------------------------
  # * Aqui verifica se o mapa aceita as transições
  #--------------------------------------------------------------------------
  def daynight_off?
    @daynight_off = BFK.find_map_note(BFK::DayNight::RGXMAP)
  end  
  #--------------------------------------------------------------------------
  # * Aqui faz as configurações original do mapa
  #--------------------------------------------------------------------------  
  alias daynight_setup setup
  def setup(map_id)
    daynight_setup(map_id)
    daynight_off?
    @original_step = @map.encounter_step
  end
end
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  Esta classe executa o processamento da tela de menu.
#==============================================================================

class Scene_Menu < Scene_MenuBase
  alias daynight_start start
  def start
    daynight_start
    create_window_daynight
    create_status_daynight_time if BFK::DayNight::MENU_TIME || BFK::DayNight::MENU_DATE
  end
  #--------------------------------------------------------------------------
  # * Criação da janela de atributos
  #--------------------------------------------------------------------------
  def create_window_daynight
    @window_daynight = Window_TimeInput.new
  end
  #--------------------------------------------------------------------------
  # * Cria a janela de tempo
  #--------------------------------------------------------------------------
  def create_status_daynight_time
    @daynight_window_time = Window_DayNight_Time.new
    @daynight_window_time.x = 0
    @daynight_window_time.y = @command_window.height
  end
  #--------------------------------------------------------------------------
  # * Criação da janela de comando
  #--------------------------------------------------------------------------
  alias daynight_create_command_window create_command_window
  def create_command_window
    daynight_create_command_window
    @command_window.set_handler(:daynight,  method(:command_daynight))
  end
  #--------------------------------------------------------------------------
  # * Comando [Tempo]
  #--------------------------------------------------------------------------
  def command_daynight
    @window_daynight.activate
    @window_daynight.start
    @window_daynight.set_handler(:ok,     method(:on_daynight_ok))
    @window_daynight.set_handler(:cancel, method(:on_daynight_cancel))
  end
  #--------------------------------------------------------------------------
  # * Comandos individuais [Confirmação]
  #--------------------------------------------------------------------------
  def on_daynight_ok
    Sound.play_ok
    $game_daynight.set_trans(false)
    $game_daynight.minutos = $game_daynight.change_minutes( @window_daynight.daynight_ok_process)
    @daynight_window_time.refresh
    @window_daynight.unselect
    @window_daynight.close
    @command_window.activate
  end
  #--------------------------------------------------------------------------
  # * Comandos individuais [Cancelamento]
  #--------------------------------------------------------------------------
  def on_daynight_cancel
    Sound.play_cancel
    @window_daynight.unselect
    @window_daynight.deactivate
    @window_daynight.close
    @command_window.activate
  end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  Esta classe executa o processamento da tela de mapa.
#==============================================================================
class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Inicialização do processo
  #--------------------------------------------------------------------------
  def initialize
    if $game_daynight
      $game_daynight.trans = false
      $game_daynight.refresh
    end
  end
  #--------------------------------------------------------------------------
  # * inicializa as janelas do menu, hud e o contador de tempo
  #--------------------------------------------------------------------------
  alias start_daynight start
  def start
    $game_daynight = DayNight.new unless $game_daynight
    if BFK::DayNight::DISPLAY_HUD
      @window_display_hud =  Window_Display_HUD.new
      @window_display_hud.pos_window_time
      @window_phase_hud = Display_Phase.new(@window_display_hud.x, @window_display_hud.y)
      @window_phase_hud.viewport = @window_display_hud.viewport
    end
    start_daynight
  end
  #--------------------------------------------------------------------------
  # * Atualiza o script
  #--------------------------------------------------------------------------
  alias daynight_update update
  def update
    $game_daynight.update
    if BFK::DayNight::DISPLAY_HUD
      @window_display_hud.refresh
      @window_phase_hud.refresh
    end
    daynight_update
  end
  #--------------------------------------------------------------------------
  # * Atualiza o a transição antes do fadeout
  #--------------------------------------------------------------------------
  alias post_transfer_daynight post_transfer
  def post_transfer
    $game_daynight.clear_daynight
    $game_daynight.refresh
    post_transfer_daynight
  end
  #--------------------------------------------------------------------------
  # * termina a scene
  #--------------------------------------------------------------------------
  alias pre_terminate_daylight pre_terminate
  def pre_terminate
    pre_terminate_daylight
    @window_phase_hud.dispose if @window_phase_hud
  end
  
  #--------------------------------------------------------------------------
  # * termina a scene
  #--------------------------------------------------------------------------
  alias terminate_daylight terminate
  def terminate
    terminate_daylight
    @window_phase_hud.dispose if @window_phase_hud
  end
end


CODE
  #--------------------------------------------------------------------------
  # SISTEMA DIA E NOITE AddOn(BY RAVEN) - v1.2 - WWW.RPGMENACE.COM.BR
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  # AddOn - Fases da Lua
  #--------------------------------------------------------------------------
  # * COMO USAR O SISTEMA DE DIA E NOITE - Fases da Lua
  # - BASTA QUE ESTE SCRIPT ESTEJA ACIMA DO MAIN E ABAIXO DO SCRIPT DE DIA E NOITE
  #
  #********************************************************************
  # COMANDOS PUBLICOS PARA SEREM USADOS NO MAPA OU EVENTOS
  #********************************************************************
  # <daynight_troop> moonphase = [id_troop, %] </daynight_troop>
  #                   - Se colocado no espaço de notas do mapa fará com que a
  #                   Tropa com o id "id_troop", mude as chances de aparecer para
  #                   a porcentagem (0~100) em "frequencia", durante o periodo
  #                   especificado em "phase" (nota: so serão alterados
  #                   tropas que estiverem na lista de encontros do mapa  
  #
  # <daynight_step> moonphase = nº_step </daynight_step>
  #                   - Se colocado no espaço de notas do mapa fará com que as
  #                   chances de acontecer um encontro "steps" (menor mais chances)
  #                   durante um periodo especifico "phase"
  #                   caso o periodo não seja especificado, o valor de steps (passos)
  #                   será mantido conforme original
  # $game_daynight.which_phase_moon?
  #                 - Retorna em forma te Texto a fase atual da lua
  # $game_daynight.which_phase_moon_id?(phase=atual)
  #                 - Retorna o id da fase atual da lua
  #--------------------------------------------------------------------------
  # COMANDOS PARA MENSAGENS
  #--------------------------------------------------------------------------
  # \Moon   - Exibe na janela a fase da lua
  #--------------------------------------------------------------------------
$registro = [] if $registro.nil?
$registro << ["BFK DayNight MoonFase",1.2]
#==============================================================================
# ** MODULO BKF
#------------------------------------------------------------------------------
#  Este é o modulo principal para scripts feitos por este core
#==============================================================================
module BFK
  self.modular("BFK Core",1.0)
  self.modular("BFK DayNight",3.3)
  #--------------------------------------------------------------------------
  # * Aqui se encontra todas as variaveis para configuração e instalação
  #--------------------------------------------------------------------------
  module DayNight
    PHASE_MOON_PHASE = 2 # variavel que indica em que fase a lua é visivel
    PHASE_MOON_PHASE_INVERT = false  #inverter fase da lua por hemisferio
    PHASE_MOON_CICLO = CICLOS[2] ## O ciclo da lua se completa no ciclo do Mês.
    PHASE_MOON = ["lua nova", "lua crescente", "lua cheia", "lua minguante"]
    PHASE_MOON_SWITCH = [5,6,7,8] ## As outras Switchs de 1 a 4 são para as phases do sol
    #--------------------------------------------------------------------------
  end
end
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  Esta é a superclasse para todas as janelas no jogo.
#==============================================================================
class Window_Base < Window
  alias dnmoon_convert_escape_characters convert_escape_characters
  def convert_escape_characters(text)
    result = dnmoon_convert_escape_characters(text)
    result.gsub!(/\eMoon/i)          { $game_daynight.which_phase_moon? }
    result
  end
end
#==============================================================================
# ** DayNight
#------------------------------------------------------------------------------
#  Esta é a superclasse para todo o controle de tempo no jogo
#==============================================================================
class DayNight
  attr_accessor :phase_moon
  #--------------------------------------------------------------------------
  # * Inicializa o processo acrecentando as fases da lua
  #--------------------------------------------------------------------------
  alias initialize_moon initialize
  def initialize
    initialize_moon
    get_phase_moon(day_ingame)
  end
  #--------------------------------------------------------------------------
  # * Faz o calculo da fase lunar e ativa as switchs
  #--------------------------------------------------------------------------
  def get_phase_moon(day)
    fase = day /(BFK::DayNight::PHASE_MOON_CICLO/BFK::DayNight::PHASE_MOON.count)
    @phase_moon = BFK::DayNight::PHASE_MOON[fase-1]
    value = BFK::DayNight::PHASE_MOON.index(@phase_moon)
    switch_refresh(value,BFK::DayNight::PHASE_MOON_SWITCH)
  end
  #--------------------------------------------------------------------------
  # * Retonra o nome da fase lunar atual
  #--------------------------------------------------------------------------
  def which_phase_moon?
    @phase_moon.capitalize
  end
  #--------------------------------------------------------------------------
  # * retona o id da fase da lua
  # :ohase_moon = nil para fase atual, outro nome para pegar seu ID
  #--------------------------------------------------------------------------
  def which_phase_moon_id?(phase_moon=nil)
    moon = (phase_moon == nil) ? @phase_moon : phase_moon
    return BFK::DayNight::PHASE_MOON.index(moon)
  end
  #--------------------------------------------------------------------------
  # * atualiza as fases da lua
  #--------------------------------------------------------------------------
  alias refresh_moon refresh
  def refresh
    refresh_moon
    get_phase_moon(day_ingame)
  end
  
  #--------------------------------------------------------------------------
  # Ajuda na veificação do status dos steps
  #--------------------------------------------------------------------------
  alias index_stst_moon_steps index_stat_steps
  def index_stat_steps(conteudo)
    return conteudo.index{|value|
        if value[0] == "min" || value[0] == "minute"
          min_ingame == value[1].to_i
        elsif value[0] == "hour" || value[0] == "hora"
          hour_ingame == value[1].to_i
        elsif (value[0] == "day" || value[0] == "dia") && value[2]
          day_ingame == value[1].to_i
        elsif value[0] == "month" || value[0] == "mes"
          month_ingame == value[1].to_i
        elsif value[0] == "year" || value[0] == "ano"
          year_ingame == value[1].to_i
        elsif phase_ingame[1] == value[0]  
          phase_ingame[1] == value[0]
        elsif which_phase_moon_id? == value[0]  
          which_phase_moon_id? == value[0]
      end
    }
  end
  #--------------------------------------------------------------------------
  # * Aqui define o index dos comandos que serão executados
  # * Priorisa os comandos de cima para baixo.
  #--------------------------------------------------------------------------
  alias index_stat_moon_troops index_stat_troops
  def index_stat_troops(conteudo)
    i = 0
    ary =[]
    conteudo.each{|value|
      if min_ingame == value[3].to_i && (value[0] == "min" || value[0] == "minute")
        ary << i
      elsif hour_ingame == value[3].to_i && (value[0] == "hour" || value[0] == "hora")
        ary << i
      elsif day_ingame == value[1].to_i && (value[0] == "day" || value[0] == "dia")
        ary << i
      elsif month_ingame == value[1].to_i && (value[0] == "month" || value[0] == "mes")
        ary << i
      elsif year_ingame == value[1].to_i && (value[0] == "year" || value[0] == "ano")
        ary << i
      elsif phase_ingame[1] == value[0]  
        ary << i
      elsif which_phase_moon_id? == value[0]  
        ary << i
      end
      i += 1
    }
    return ary.reverse!
  end
end

#==============================================================================
# ** Display_Phase
#------------------------------------------------------------------------------
#  Esta é a classe que controla o grsfico de periodo no relogio.
#==============================================================================

class Display_Phase < Sprite_Base
  #--------------------------------------------------------------------------
  # * Atualiza o sprite no mapa
  #--------------------------------------------------------------------------
  alias update_phase_moon update_phase
  def update_phase
    update_phase_moon
    if BFK::DayNight::PHASE_MOON_PHASE == @phase
      @index_phase_picx = $game_daynight.which_phase_moon_id?
    end
  end
  #--------------------------------------------------------------------------
  # * Inicializa o sprite
  #--------------------------------------------------------------------------
  alias update_phase_pic_moon update_phase_pic
  def update_phase_pic
    update_phase_pic_moon
    self.mirror = true if BFK::DayNight::PHASE_MOON_PHASE_INVERT
  end
end


This post has been edited by Icenick99: Apr 8 2012, 07:29 PM
Go to the top of the page
 
+Quote Post
   
dartdaman
post Apr 8 2012, 07:49 PM
Post #2


Level 6
Group Icon

Group: Member
Posts: 77
Type: Developer
RM Skill: Skilled




you could just use google translate and translate it yourself


__________________________
Go to the top of the page
 
+Quote Post
   
Icenick99
post Apr 8 2012, 08:07 PM
Post #3


Level 3
Group Icon

Group: Member
Posts: 33
Type: None
RM Skill: Undisclosed




QUOTE (dartdaman @ Apr 8 2012, 07:49 PM) *
you could just use google translate and translate it yourself


Tried and failed sad.gif
Getting errors on almost every line.
Go to the top of the page
 
+Quote Post
   
Night_Runner
post Apr 10 2012, 06:15 AM
Post #4


Level 50
Group Icon

Group: +Gold Member
Posts: 1,525
Type: Scripter
RM Skill: Undisclosed




When you put the script in your game sections will appear in green, these are comments for people to read and don't affect the code (comments always start after a # symbol).

If you translate all the comments then you can read what's going on, but don't translate the code, since it works.


__________________________
K.I.S.S.
Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.

Most important guide ever: Newbie's Guide to Switches
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 24th May 2013 - 10:08 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker