Ajuda com Script de lanterna (VX Ace)

2 Respostas   238 Visualizações

0 Membros e 1 Visitante estão vendo este tópico.

Magic D

Tópico criado em: 28/09/2015 às 14:30 - Última modificação por Magic D em 08/10/2015 às 14:08

Salve galera!! Estou usando um Script de lanterna que apesar de ter um pequeno lag ele funciona exatamente como eu queria, porem, sempre que eu mudo de mapa a lanterna se desliga forçando o jogador a apertar a tecla Q (:L)
O Script é esse aqui:
Código: [Selecionar]
#=============================================================================#
#======================#                               #======================#
#======================#         Flashlight BG         #======================#
#======================#              by               #======================#
#======================#          Gousenfire           #======================#
#======================#          Versão: 1.2          #======================#
#=============================================================================#
#=============================================================================#
#                                                                             #
#                                Configurações                                #
#                                                                             #
#=============================================================================#
module FlashlightModule
 
# Opacidade da imagem da lanterna 0 = Transparente / 255 = Preto
  Opacity = 180
# Switch que mostra que está de noite
  Switch1 = 100
# Nome da imagem na pasta pictures
  Image = "Lantern"
# ID, no database, do item que representa as pilhas
  Batery = 18
# ID, no database, do item que representa a lanterna
  FlashL = 17
# Botão que liga a lanterna
  Buttom = :L # Aperte F1 ao iniciar o jogo para ver a lista de botoes
# Tempo (em frames) para se perder uma pilha
  Time = 120 # 60 framses = 1 segundo
# SE tocada quando ocorre algum erro
  SEE = "Buzzer1"
# SE tocada quando liga a lanterna
  SET = "Cursor2"
# Ficar escuro quando a Switch1 estiver ligada?
  Dark = true
 
end
 
#=============================================================================#
#                                                                             #
#                                Código Fonte                                 #
#               (Não altere essa parte sem a permissão do criador)            #
#=============================================================================#
class Spriteset_Map
 
  include FlashlightModule
  alias fl_initialize initialize
  alias fl_update update
  alias fl_dispose dispose
 
  def initialize
   
    @laternIMG, @laternIMG.bitmap = Sprite.new, Cache.picture(Image)
    @laternIMG.z = 998
    @laternIMG.opacity = Opacity
    @laternIMG.visible = false
   
    @darkBM, @darkBM.bitmap = Sprite.new
    @darkBM.bitmap = Bitmap.new(1088,1200)
    @darkBM.x = 0
    @darkBM.y = 0
    @darkBM.z = 999
    @darkBM.bitmap.fill_rect(@darkBM.bitmap.rect, Color.new(0, 0, 0))
    @darkBM.opacity = Opacity
    @darkBM.visible = false
    @darkBM.update
   
    @lanterOnOrOff = false # variable that controlls if the lantern is on or off
    @isDark = false # variable that controlls if is dark or not
    @haveEnoughtBaterys = false # variable that controll if the player have enought baterys to turn on the lantern
    @haveTheLanter # variable that check if the player has the item Lanter
   
    fl_initialize
   
  end
 
  def update
   
    # if the buttun is pressed change the variable to the opisit
    if Input.trigger?(Buttom)
      if @lanterOnOrOff
        @lanterOnOrOff = false
        Audio.se_play("Audio/SE/" + SET, 70, 100)
      else
        if @isDark && @haveEnoughtBaterys && @haveTheLanter
          @lanterOnOrOff = true
          Audio.se_play("Audio/SE/" + SET, 70, 100)
        else
          Audio.se_play("Audio/SE/" + SEE, 70, 100)
        end
      end
    end
    if @lanterOnOrOff && (!@isDark || !@haveEnoughtBaterys || !@haveTheLanter)
      @lanterOnOrOff = false
      Audio.se_play("Audio/SE/" + SET, 70, 100)
    end
 
    # check if the player has the item lanter in the inventory
    if $game_party.item_number($data_items[FlashL]) > 0
      @haveTheLanter = true
    else
     @haveTheLanter = false
    end
 
    # Check if the player has batery in the inventory
    if $game_party.item_number($data_items[Batery]) > 0
      @haveEnoughtBaterys = true
    else
      @haveEnoughtBaterys = false
    end
   
    # transform the switch in a variable
    if $game_switches[Switch1]
      @isDark = true
      if Dark
        if !@lanterOnOrOff
          dark_the_sky
        else
          light_up_yhe_sky
        end
      end
    else
      @isDark = false
      if Dark
        light_up_yhe_sky
      end
    end
 
    # call the right met
    if @lanterOnOrOff
      lanter_is_on
    else
      latern_is_off
    end
   
    fl_update # call update
   
  end
 
  def lanter_is_on
   
    @laternIMG.visible = true
 
    if Graphics.frame_count % Time == 0
      $game_party.lose_item($data_items[Batery], 1)
    end
 
    case $game_player.direction
      when 2
        @laternIMG.angle, @coord = 0, [544, 586]
      when 8
        @laternIMG.angle, @coord = 180, [-544, -565]
      when 6
        @laternIMG.angle, @coord = 90, [576, -522] 
      when 4
        @laternIMG.angle, @coord = 270, [-576, 570]
    end
 
    @laternIMG.x = $game_player.screen_x - @coord[0]
    @laternIMG.y = $game_player.screen_y - @coord[1]
    @laternIMG.update
 
  end
 
  def latern_is_off
   
    @laternIMG.visible = false
    @lanterOnOrOff = false
    @laternIMG.update
   
  end
 
  def dark_the_sky
    @darkBM.visible = true
    @darkBM.update
  end
 
  def light_up_yhe_sky
    @darkBM.visible = false
    @darkBM.update
  end
 
   def dispose
   
    latern_is_off
    light_up_yhe_sky
   
    fl_dispose
   
  end
end


Imagem da lantern


E minha duvida é: como eu faço para que a lanterna não apague ao me teleportar?
Se alguém poder me ajudar eu agradeço :ok:

Raizen

  • Administrador
  • *
  • Posts: 3224
  • Ouros: 3192
  • Medalhas Vencedor do Protótipo Premiado Participante notável do evento "A Estação das Luzes do Norte" Vencedor CRM Awards - Melhor Scripter Vencedores das edições do Concurso Projeto Rickas!
Resposta 1: 28/09/2015 às 16:08

Tenta isso aqui xD

Código: [Selecionar]
#=============================================================================#
#======================#                               #======================#
#======================#         Flashlight BG         #======================#
#======================#              by               #======================#
#======================#          Gousenfire           #======================#
#======================#          Versão: 1.2          #======================#
#=============================================================================#
#=============================================================================#
#                                                                             #
#                                Configurações                                #
#                                                                             #
#=============================================================================#
module FlashlightModule
 
# Opacidade da imagem da lanterna 0 = Transparente / 255 = Preto
  Opacity = 180
# Switch que mostra que está de noite
  Switch1 = 100
# Nome da imagem na pasta pictures
  Image = "Lantern"
# ID, no database, do item que representa as pilhas
  Batery = 18
# ID, no database, do item que representa a lanterna
  FlashL = 17
# Botão que liga a lanterna
  Buttom = :L # Aperte F1 ao iniciar o jogo para ver a lista de botoes
# Tempo (em frames) para se perder uma pilha
  Time = 120 # 60 framses = 1 segundo
# SE tocada quando ocorre algum erro
  SEE = "Buzzer1"
# SE tocada quando liga a lanterna
  SET = "Cursor2"
# Ficar escuro quando a Switch1 estiver ligada?
  Dark = true
 
end
 
#=============================================================================#
#                                                                             #
#                                Código Fonte                                 #
#               (Não altere essa parte sem a permissão do criador)            #
#=============================================================================#
class Spriteset_Map
 
  include FlashlightModule
  alias fl_initialize initialize
  alias fl_update update
  alias fl_dispose dispose
 
  def initialize
   
    @laternIMG, @laternIMG.bitmap = Sprite.new, Cache.picture(Image)
    @laternIMG.z = 998
    @laternIMG.opacity = Opacity
    @laternIMG.visible = false
   
    @darkBM, @darkBM.bitmap = Sprite.new
    @darkBM.bitmap = Bitmap.new(1088,1200)
    @darkBM.x = 0
    @darkBM.y = 0
    @darkBM.z = 999
    @darkBM.bitmap.fill_rect(@darkBM.bitmap.rect, Color.new(0, 0, 0))
    @darkBM.opacity = Opacity
    @darkBM.visible = false
    @darkBM.update
   
    @lanterOnOrOff = false # variable that controlls if the lantern is on or off
    @isDark = false # variable that controlls if is dark or not
    @haveEnoughtBaterys = false # variable that controll if the player have enought baterys to turn on the lantern
    @haveTheLanter # variable that check if the player has the item Lanter
   
    fl_initialize
   
  end
 
  def update
   
    # if the buttun is pressed change the variable to the opisit
    if Input.trigger?(Buttom)
      if @lanterOnOrOff
        @lanterOnOrOff = false
        Audio.se_play("Audio/SE/" + SET, 70, 100)
      else
        if @isDark && @haveEnoughtBaterys && @haveTheLanter
          @lanterOnOrOff = true
          Audio.se_play("Audio/SE/" + SET, 70, 100)
        else
          Audio.se_play("Audio/SE/" + SEE, 70, 100)
        end
      end
    end
    if @lanterOnOrOff && (!@isDark || !@haveEnoughtBaterys || !@haveTheLanter)
      @lanterOnOrOff = false
      Audio.se_play("Audio/SE/" + SET, 70, 100)
    end
 
    # check if the player has the item lanter in the inventory
    if $game_party.item_number($data_items[FlashL]) > 0
      @haveTheLanter = true
    else
     @haveTheLanter = false
    end
 
    # Check if the player has batery in the inventory
    if $game_party.item_number($data_items[Batery]) > 0
      @haveEnoughtBaterys = true
    else
      @haveEnoughtBaterys = false
    end
   
    # transform the switch in a variable
    if $game_switches[Switch1]
      @isDark = true
      if Dark
        if !@lanterOnOrOff
          dark_the_sky
        else
          light_up_yhe_sky
        end
      end
    else
      @isDark = false
      if Dark
        light_up_yhe_sky
      end
    end
 
    # call the right met
    if @lanterOnOrOff
      lanter_is_on
    else
      latern_is_off
    end
   
    fl_update # call update
   
  end
 
  def lanter_is_on
   
    @laternIMG.visible = true
 
    if Graphics.frame_count % Time == 0
      $game_party.lose_item($data_items[Batery], 1)
    end
 
    case $game_player.direction
      when 2
        @laternIMG.angle, @coord = 0, [544, 586]
      when 8
        @laternIMG.angle, @coord = 180, [-544, -565]
      when 6
        @laternIMG.angle, @coord = 90, [576, -522] 
      when 4
        @laternIMG.angle, @coord = 270, [-576, 570]
    end
 
    @laternIMG.x = $game_player.screen_x - @coord[0]
    @laternIMG.y = $game_player.screen_y - @coord[1]
    @laternIMG.update
 
  end
 
  def latern_is_off
   
    @laternIMG.visible = false
    @lanterOnOrOff = false
    @laternIMG.update
   
  end
 
  def dark_the_sky
    @darkBM.visible = true
    @darkBM.update
  end
 
  def light_up_yhe_sky
    @darkBM.visible = false
    @darkBM.update
  end
 
   def dispose
   
    #latern_is_off
    light_up_yhe_sky
   
    fl_dispose
   
  end
end

Não consigo testar para você agora D:

Magic D

Resposta 2: 28/09/2015 às 16:16 - Última modificação por Magic D em 08/10/2015 às 14:08

Não mudou nada Raizen..

Edit:
O problema nao foi solucionado, mas resolvi fazer o sistema por eventos :ok: