RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
HELP ME [RMXP] Window_BattleResult Error Line 88

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 76
RMRK Junior
Script 'Window_BattleResult' line 88: NoMethodError occurred.

undefined method '[]' for nil:NilClass
(It happens if I finish a battle with a Knocked Out Char.)

Other Scripts I use are...

SDK I
SDK V1.4
SDK 2.2 - Part II
SDK 2.2 - Part III
SDK 2.2 - Part IV

 'GnD' & 'LBMenu' Patch

GROUPIND & DETAILS
 1- Configuration
 2- Mechanics & Error Checking
 3- Modules
 4- Window
 5- Scene

 HP/SP/EXP Gauge Script V1.0
 Limit Break (DVV)
 'Attack' Option Replacer
 Limit Break Menu Pt. 1
 Limit Break Menu Pt. 2
 HP/MP/ATB (Seph Slant)

Enemy Life Bar
UMS
Extra Modifications
Configuration
Scene_Battle#Edits
Window_BattleResults
File Error Fix & Report
Anti-Lag Script

Window_BattleResults
Code: [Select]
#==============================================================================
# ** Window_BattleResult
#------------------------------------------------------------------------------
#  This window displays amount of gold and EXP acquired at the end of a battle.
#==============================================================================

#--------------------------------------------------------------------------
# Begin SDK Enabled Check
#--------------------------------------------------------------------------
if SDK.state('Lufia Style Battle Report') == true
 
class Window_BattleResult < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     exp       : EXP
  #     gold      : amount of gold
  #     treasures : treasures
  #--------------------------------------------------------------------------
  def initialize(exp, gold, treasures, level_flags)
    # Call Window_Base#initialize and setup window
    super(80, 0, 480, 256)
    # Setup Instance Variables
    @exp = exp
    @gold = gold
    @treasures = treasures
    @level_flags = level_flags
    # Setup Contents
    self.contents = Bitmap.new(width - 32, height - 32)
    # Setup Background Opacity
    self.back_opacity = 160
    # Invisible
    self.visible = false
    # Setup Index
    @index = 0
    # Setup Wait count
    @wait_count = LufiaII_Result::Wait_Count
    # Setup Data
    @data = []
    # Setup Text
    setup_text
    # Dispose Contents
    self.contents.dispose
    # Remake Contents
    self.contents = Bitmap.new(width - 32, @data.size * 32)
  end
  #--------------------------------------------------------------------------
  # * Setup Text
  #--------------------------------------------------------------------------
  def setup_text
    # Get Exp Text
    exp_text = LufiaII_Result::Get_Exp_Text.dup
    # Replace [exp] with exp gained
    exp_text.gsub!(/\[exp\]/, "#{@exp}")
    # Replace [words] with the word for Exp
    exp_text.gsub!(/\[words\]/, LufiaII_Result::Words_Exp)
    # Push Text
    @data << exp_text
    # Get Gold Text
    gold_text = LufiaII_Result::Get_Gold_Text.dup
    # Replace [gold] with gold gained
    gold_text.gsub!(/\[gold\]/, "#{@gold}")
    # Replace [words] with the word for gold
    gold_text.gsub!(/\[words\]/, $data_system.words.gold)
    # Push Text
    @data << gold_text
    # Get Treasure Text
    @treasures.each_with_index do |treasure, index|
      # Get Item Text
      item_text = LufiaII_Result::Get_Item_Text.dup
      # Replace [icon] with \001[index]
      item_text.gsub!(/\[icon\]/, "\001[#{index}]")
      # Replace [name] with Item Name
      item_text.gsub!(/\[name\]/, "#{treasure.name}")
      # Push Text
      @data << item_text
    end
    # Blank Line
    @data << ''
    # Run Through Each Actor with index
    $game_party.actors.each_with_index do |actor, actor_index|
      # Get Next Level Text
      level_text = LufiaII_Result::Next_Level_Text.dup
      # Replace [name] with actor name
      level_text.gsub!(/\[name\]/, actor.name)
      # Replace [amount] with exp left
      level_text.gsub!(/\[amount\]/, "#{actor.next_exp - actor.now_exp}")
      # If Level Up Flag is False
    ---  if @level_flags[actor_index][0] == false ---  <---- LINE 88 ERROR
        # Push Text
        @data << level_text
      else
        # Get Level Up Text
        levelup_text = LufiaII_Result::Level_Up_Text.dup
        # Replace [name] with the actor name
        levelup_text.gsub!(/\[name\]/, actor.name)
        # Replace [level] with the actor's level
        levelup_text.gsub!(/\[level\]/, "#{actor.level}")
        # Push Level up text
        @data << levelup_text
        # Get Learned Skills for level
        skills = $data_classes[actor.class_id].learn_skills(actor.level)
        # Run through each skill with index
        skills.each_with_index do |skill_id, index|
          # Get Skill Learn Text
          skill_learn_text = LufiaII_Result::Get_Skill_Text.dup
          # Replace [icon] with \003|skill_id|
          skill_learn_text.gsub!(/\[icon\]/, "\003|#{skill_id}|")
          # Replace [name] with skill name
          skill_learn_text.gsub!(/\[name\]/, $data_skills[skill_id].name)
          # Push Text
          @data << skill_learn_text
        end
        # Run Through Stats Defined with index
        LufiaII_Result::Stats.each_with_index do |stat, index|
          # Get Stat Text
          stat_text = LufiaII_Result::Stat_Up_Text.dup
          # Replace [stat] with Stat name
          stat_text.gsub!(/\[stat\]/, LufiaII_Result::Stat_Names[index])
          # Get Stat Change
          amount = actor.stat_change(index, @level_flags[actor_index][1])
          # Replace [amount] with the stat change amount
          stat_text.gsub!(/\[amount\]/, "#{amount}")
          # Push Stat Text
          @data << stat_text
        end
        # Push Level Text
        @data << level_text
        # Push Blank if not last actor
        @data << '' if actor_index != $game_party.actors.size - 1
      end
    end
    # Push Blank
    @data << ''
    # Get Current Gold Text
    cgold_text = LufiaII_Result::Gold_Text.dup
    # Replace [gold] with the current gold
    cgold_text.gsub!(/\[gold\]/, "#{$game_party.gold}")
    # Replace [words] with the word for gold
    cgold_text.gsub!(/\[words\]/, $data_system.words.gold)
    # Push Current Gold Text
    @data << cgold_text
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
    # If Scrolling
    if @scrolling
      # Reduce Scroll Time
      @scroll_time -= 1
      # Increase Oy
      self.oy += LufiaII_Result::Speeds[LufiaII_Result::Scroll_Speed]
      # If Scroll time is 0 set scrolling to false else true
      @scrolling = @scroll_time != 0
      # Return
      return
    end
    # If Wait Count is not nil
    if LufiaII_Result::Wait_Count != nil
      # Decrease Wait Count
      @wait_count -= 1
      # If Wait Count is zero
      if @wait_count == 0
        # Reset Wait Count
        @wait_count = LufiaII_Result::Wait_Count
        # If Index is less than or equal to text sizes - 1
        if @data.size - 1 >= @index
          # If A Blank Line
          if @data[@index] == ''
            # Window is Scrolling
            @scrolling = true
            # Get Scroll Speed
            scroll_speed = LufiaII_Result::Scroll_Speed
            # Get Scroll Time
            @scroll_time = 32 / LufiaII_Result::Speeds[scroll_speed]
            # Increase Index
            @index += 1
            # Return
            return
          end
          # Refresh Window
          refresh
          # Increase Index
          @index += 1
          # If Index is > 7
          if @index > 7
            # We Are Scrolling
            @scrolling = true
            # Get Scroll Speed
            scroll_speed = LufiaII_Result::Scroll_Speed
            # Get Scroll Time
            @scroll_time = 32 / LufiaII_Result::Speeds[scroll_speed]
          end
        # Else case
        else
          # Dispose Window
          dispose
        end
        # Return
        return
      end
    end
    # If Push Button Option and C has been triggered
    if LufiaII_Result::Push_Button and Input.trigger?(Input::C)
      # Reset Wait Count
      @wait_count = LufiaII_Result::Wait_Count
      # If Index is less than or equal to text sizes - 1
      if @data.size - 1 >= @index
        # If A Blank Line
        if @data[@index] == ''
          # Set Scrolling to True
          @scrolling = true
          # Get Scroll Speed
          scroll_speed = LufiaII_Result::Scroll_Speed
          # Get Scroll Time
          @scroll_time = 32 / LufiaII_Result::Speeds[scroll_speed]
          # Increase Index
          @index += 1
          # Return
          return
        end
        # Refresh
        refresh
        # Increase Index
        @index += 1
        # If index is greater than 7
        if @index > 7
          # Set Scrolling to true
          @scrolling = true
          # Get Scroll Speed
          scroll_speed = LufiaII_Result::Scroll_Speed
          # Get Scroll Time
          @scroll_time = 32 / LufiaII_Result::Speeds[scroll_speed]
        end
      # Else
      else
        # Dispose
        dispose
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # Setup X
    x = 0
    # Get Text
    text = @data[@index]
    # Replace [right] with \002
    text.gsub!(/\[right\]/, "\002")
    # Split into two parts
    text = text.split("\002")
    # Return if empty
    return if text.empty?
    # Split Left Aligned Text at \001 \003 and space and run through
    text[0].split(/\001|\003|\s/).each do |string|
      # If Matched Against [any number of digits]
      if string.sub!(/\[([0-9]+)\]/, "") != nil
        # Get Matched, item_id
        index = $1.to_i
        # Get Bitmap
        bitmap = RPG::Cache.icon(@treasures[index].icon_name)
        # Draw Bitmap
        self.contents.blt(x, @index * 32, bitmap, bitmap.rect)
        # Increase By width
        x += bitmap.width
      # Else If Matched by |any number of digits|
      elsif string.sub!(/\|([0-9]+)\|/, "") != nil
        # Get Matched, skill_id
        skill_id = $1.to_i
        # Get Bitmap
        bitmap = RPG::Cache.icon($data_skills[skill_id].icon_name)
        # Draw Bitmap
        self.contents.blt(x, @index * 32, bitmap, bitmap.rect)
        # Increase By Width
        x += bitmap.width       
      # Else
      else
        # Draw The String
        self.contents.draw_text(x, @index * 32, width - 32, 32, string)
        # Increase By Width
        x += contents.text_size(string).width
      end
      # Increase by Space Width
      x += contents.text_size(' ').width
    end
    # If Right Text is not nil
    if text[1] != nil
      # Draw Right Aligned Text
      self.contents.draw_text(0, @index * 32, width - 32, 32, text[1], 2)
    end
  end
end
#--------------------------------------------------------------------------
# End SDK Enabled Check
#--------------------------------------------------------------------------
end
« Last Edit: August 24, 2010, 04:34:51 AM by Cedricsawall2 »
Now Your nightmare comes to life.

[RMXP] CRYSTaL KNigHTS: The First Dawn - 20%
[RMXP] White Ruins - 10 %

***
Rep:
Level 76
RMRK Junior
still looking for some kind of help.
Now Your nightmare comes to life.

[RMXP] CRYSTaL KNigHTS: The First Dawn - 20%
[RMXP] White Ruins - 10 %

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
Use a codebox, BBCode gets in the way of scripts.

***
Rep:
Level 76
RMRK Junior
how do you make a codebox?
Now Your nightmare comes to life.

[RMXP] CRYSTaL KNigHTS: The First Dawn - 20%
[RMXP] White Ruins - 10 %

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
[code][/code]