Sujet n°14319
Posté par Xyrram le 3 Jan - 20:43 (2015)
Titre : Problemme de script
Bon voila j'ai un script en cours de codage mais j'ai une erreur de Syntaxe à la dernière ligne que je n'arrive pas à comprendre
(Le script fait crash tout le projet à chaque fois.)
Code:

#==========================================================================
# ■ Annuaire
# Projet Rise - Xyrram
# 02/01/15
#------------------------------------------------------------------------------
class ANNUAIRE 
  attr_accessor :index 
  def initialize(index = 0) 
    @index = index 
    @fond = Sprite.new 
    @fond.bitmap = RPG::Cache.picture("1.png")
   
      def main
@spriteset = Spriteset_Map.new
        s1 = "Personnages Principaux"
        s2 = "Personnages Secondaires"
        s3 = "Quitter"
        @command_window = Window_Command.new(160, [s1, s2, s3])
        @command_window.index = @menu_index
        @command_window.x = 480 - 3
        @command_window.y = 3
      end

            Graphics.transition
      loop do
        Graphics.update
        Input.update
        update
        if $scene != self
          break
        end
       
  def update
     self.contents.clear
     # Boucle pour afficher chaque commande
     for i in 0...@item_max
       # Position X selon i
      x = 4 + i * 160
      # Taille du texte
      text_size = self.contents.text_size(@commands[i]).width
      # Affichage du texte.
     self.contents.draw_text(x, 0, text_size, 32, @commands[i])
       @command.update 
  @item_max.update 
  @column_max.update
      def update_command
      # B ボタンが押された場合
      if Input.trigger?(Input::B)
        # キャンセル SE を演奏
        $game_system.se_play($data_system.cancel_se)
        # マップ画面に切り替え
        $scene = Scene_Map.new
        return

    if Input.trigger?(Input::C)
          case @command_window.index
        when 0 #Personnage Principaux
          if not($data_pokedex[0])
            $game_system.se_play($data_system.buzzer_se)
            return
          end
          $game_system.se_play($data_system.decision_se)
          $scene = Pokemon_Pokedex.new
        when 1 #Personnages secondaires
          if $pokemon_party.size == 0
            $game_system.se_play($data_system.buzzer_se)
            return
          end
          $game_system.se_play($data_system.decision_se)
          $scene = Pokemon_Party_Menu.new
        when 2 #Quitter
          $game_system.se_play($data_system.decision_se)
          $scene = Pokemon_Map.new
          end
        return
          end
        end
        end
    end
end
 

Posté par Schneitizel le 3 Jan - 20:47 (2015)
Xyrram a écrit:
erreur de Syntaxe à la derniere ligne (...)


Ou bien le end de fin est en trop ou bien il y'a un end manquant

Et le "attr accesor :index", ça sert a rien dans ce cas hein

Posté par Xyrram le 3 Jan - 20:54 (2015)
Ok je devais en ajouter 3 Oo mais maintenant j'ai une erreur dans windows selectable à la ligne 22
Code:
 def update_cursor_rect
    # Redéfinition
    if @index < 0
      self.cursor_rect.empty
      return
    end
    row = @index / @column_max
    if row < self.top_row
      self.top_row = row
    end


la ligne 22 c'est if @index < 0

Posté par Zohran le 3 Jan - 21:06 (2015)
C'est quoi exactement l'erreur qui s'affiche, tu ne donnes pas assez de détail...

Posté par Pαlвσlѕку le 3 Jan - 21:10 (2015)
Je te conseille de bien vérifier ce que tu mets, tu as écrit des horreurs et utiliser des variables même pas définies.

Code:
#==========================================================================
# ■ Annuaire
# Projet Rise - Xyrram
# 02/01/15
#------------------------------------------------------------------------------
class ANNUAIRE 
  def initialize(index = 0)   
    @fond = Sprite.new 
    @fond.bitmap = RPG::Cache.picture("1.png")     
    @spriteset = Spriteset_Map.new
    s1 = "Personnages Principaux"
    s2 = "Personnages Secondaires"
    s3 = "Quitter"
    @command_window = Window_Command.new(320, [s1, s2, s3])
    @command_window.index = index
    @command_window.x = 480 -  @command_window.width/2 - 3
    @command_window.y = 3
  end
   
  def main
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze 
    @command_window.dispose
    @spriteset.dispose
  end
     
  def update
    update_command
    @command_window.update
  end
   
  def update_command
    # B ボタンが押された場合
    if Input.trigger?(Input::B)
      # キャンセル SE を演奏
      $game_system.se_play($data_system.cancel_se)
      # マップ画面に切り替え
      $scene = Scene_Map.new
      return
    end
    if Input.trigger?(Input::C)
      case @command_window.index
      when 0 #Personnage Principaux
        if not($data_pokedex[0])
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Pokemon_Pokedex.new
      when 1 #Personnages secondaires
        if $pokemon_party.size == 0
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Pokemon_Party_Menu.new
      when 2 #Quitter
        $game_system.se_play($data_system.decision_se)
        $scene = Pokemon_Map.new
      end
      return
    end     
  end   
end

Je n'ai pas touché à la partie à l'intérieur de la condition Input.trigger?(Input::C).