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 Changing Script From XP To VX

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 84
I am trying to take MOG's skill menu script from XP and move it over to VX. I've done pretty well for myself, except I am being stumped on one error. The error it gives me is "On line 98 of Windows_Selectable, undefined method `width' for nil:NilClass". Now I am completely unsure where in the script (MOG_Menu_Skill Nami) the error is coming from or how to solve it. This is the only issue I am having and want fixed. If you could take a look at it and if possible solve it, I would be greatful. Also if you could add an explanation of what was causing the error. I know that in solving this one I will probably lead into another error, but I would like to transfer this game over myself and just need help getting through this hurdle.
Thanks.

http://rapidshare.com/files/150999240/Ques...l_Demo.zip.html

For Those without VX:
Spoiler for:
#_________________________________________________
# MOG_Menu Skill Nami V1.0
#_________________________________________________
# By Moghunter
#_________________________________________________
module MOG
  # Defini? de tempo de transi?.
  MSK_TT = 20
  # Tipo de transi?.
  MSK_TTT = "004-Blind04"
end
##############
# Game_Actor #
##############
class Game_Actor < Game_Battler
  def now_exp
    return @exp - @exp_list[@level]
  end
  def next_exp
    return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
  end
end
###############
# Window_Base #
###############
class Window_Base < Window
  def draw_lay(x,y)
    lay = Cache.menu("Menu_Status_OBJ")
    #lay = RPG::Cache.picture("MSK_Status")
    cw = lay.width
    ch = lay.height
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x , y - ch, lay, src_rect)
  end
  def draw_maphp3(actor, x, y)
    back = Cache.menu("MeterBack")
    cw = back.width
    ch = back.height
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x+65, y - ch +30, back, src_rect)
    meter = Cache.menu("HPMeter")
    cw = meter.width * actor.hp / actor.maxhp
    ch = meter.height
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x+65, y - ch +30, meter, src_rect)
    self.contents.font.color = Color.new(0,0,0,255)
    self.contents.draw_text(x + 66, y - 1, 100, 32, actor.hp.to_s + "/" + actor.maxhp.to_s, 1)
    self.contents.font.color = Color.new(250,255,255,255)
    self.contents.draw_text(x+65, y - 2, 100, 32, actor.hp.to_s + "/" + actor.maxhp.to_s, 1)
  end
  def draw_mapsp3(actor, x, y)
    back = Cache.menu("MeterBack")
    cw = back.width
    ch = back.height
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x+ 65 , y - ch +30, back, src_rect)
    meter = Cache.menu("MPMeter")
    cw = meter.width * actor.mp / actor.maxmp
    ch = meter.height
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x +65 , y - ch+ 30, meter, src_rect)
    self.contents.font.color = Color.new(0,0,0,255)
    self.contents.draw_text(x + 66, y - 1, 100, 32, actor.mp.to_s + "/" + actor.maxmp.to_s, 1)
    self.contents.font.color = Color.new(250,255,255,255)
    self.contents.draw_text(x + 65, y - 2, 100, 32, actor.mp.to_s + "/" + actor.maxmp.to_s, 1)
  end
  ####
  def draw_mexp2(actor, x, y)
    bitmap2 = Cache.menu("MeterBack")
    cw = bitmap2.width
    ch = bitmap2.height
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x + 60 , y - ch + 30, bitmap2, src_rect)
    rate = actor.now_exp.to_f / actor.next_exp
    bitmap = Cache.menu("EXPMeter")
    if actor.level < 99
      cw = bitmap.width * rate
    else
      cw = bitmap.width
    end
    ch = bitmap.height
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x + 60 , y - ch + 30, bitmap, src_rect)
    self.contents.font.color = Color.new(0,0,0,255)
    self.contents.draw_text(x + 55, y + 1, 84, 32, "Exp",0)
    self.contents.font.color = Color.new(255,255,255,255)
    self.contents.draw_text(x + 54, y, 84, 32, "Exp",0)
    self.contents.font.color = Color.new(0,0,0,255)
    self.contents.draw_text(x + 190, y - 125, 60, 32,"LV "+ actor.level.to_s, 1)
    self.contents.font.color = Color.new(255,255,255,255)
    self.contents.draw_text(x  +191, y - 124, 60, 32,"LV "+ actor.level.to_s, 1)
  end
  ####
end
#######################
# Window_SkillStatus2 #
#######################
class Window_SkillStatus2 < Window_Base
  def initialize(actor)
    super(350, 75, 290, 340)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    self.opacity = 0
    refresh
  end
  def refresh
    self.contents.clear
    draw_lay(0,300)
    draw_actor_face(@actor, 50, 140)
    draw_actor_name(@actor, 15, 10)
    draw_actor_state(@actor, 120, 140)
    draw_maphp3(@actor, 5, 195)
    draw_mapsp3(@actor, 5, 240)
    draw_mexp2(@actor, -30, 135)
  end
end
#################
# Window_Skill2 #
#################
class Window_Skill2 < Window_Selectable
  def initialize(actor)
    super(0, 95, 335, 290)
    @actor = actor
    @column_max = 1
    refresh
    self.index = 0
  end
  def skill
    return @data[self.index]
  end
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 0...@actor.skills.size
      skill = $data_skills[@actor.skills]
      if skill != nil
        @data.push(skill)
      end
    end
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  def draw_item(index)
    skill = @data[index]
    if @actor.skill_can_use?(skill.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    self.contents.font.name = "Georgia"
    x = index % 1 * (288)
    y = index / 1 * 32
    width = self.width + 32 / @column_max - 32
    rect = Rect.new(x, y, width, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = Cache.icon(skill.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
    self.contents.draw_text(x + 232, y, 48, 32, skill.mp_cost.to_s, 2)
    self.contents.font.color = Color.new(200,200,0,255)
    self.contents.draw_text(x + 170, y, 48, 32, "MP", 2)
  end
  def update_help
    @help_window.set_text(self.skill == nil ? "" : self.skill.description)
  end
end

###############
# Scene_Skill #
###############
class Scene_Skill
  def initialize(actor_index = 0, equip_index = 0)
    @actor_index = actor_index
  end
  def main
    @actor = $game_party.members[@actor_index]
    @msk_lay = Sprite.new
    @msk_lay.bitmap = Cache.menu("Menu_Status_Layout")
    @msk_lay.z = 100
    @msk_back1 = Plane.new
    @msk_back1.bitmap = Cache.menu("Background")
    @msk_back1.z = 10
    @help_window = Window_Help.new
    @help_window.y = 500
    @status_window = Window_SkillStatus2.new(@actor)
    @status_window.z = 110
    @status_window.x = 640
    @skill_window = Window_Skill2.new(@actor)
    @skill_window.help_window = @help_window
    @skill_window.help_window.y = 500
    @target_window = Window_Target.new
    @target_window.x = 304
    @target_window.visible = false
    @target_window.active = false
    @skill_window.opacity = 0
    @help_window.opacity = 0
    @target_window.opacity = 190
    Graphics.transition(10, "Graphics/System/BattleStart", 80)     
    #Graphics.transition(MOG::MSK_TT, "Graphics/Transitions/" MOG::MSK_TTT,80)
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    for i in 0..30
      @status_window.x = 25
      Graphics.update
    end
    Graphics.freeze
    @help_window.dispose
    @status_window.dispose
    @skill_window.dispose
    @target_window.dispose
    @msk_lay.dispose
    @msk_back1.dispose
  end
  def update
    @help_window.update
    @status_window.update
    @skill_window.update
    @target_window.update
    @msk_back1.ox = 1
    @msk_back1.oy = 1
    if @status_window.x > 350
      @status_window.x -= 15
    elsif @status_window.x 425
      @skill_window.help_window.y -= 5
    elsif @skill_window.help_window.y = 3
      @skill_window.active = false
      @target_window.visible = true
      @target_window.active = true
      if @skill.scope == 4 || @skill.scope == 6
        @target_window.index = -1
      elsif @skill.scope == 7
        @target_window.index = @actor_index - 10
      else
        @target_window.index = 0
      end
    else
      if @skill.common_event_id > 0
        $game_temp.common_event_id = @skill.common_event_id
        $game_system.se_play(@skill.menu_se)
        @actor.mp -= @skill.mp_cost
        @status_window.refresh
        @skill_window.refresh
        @target_window.refresh
        $scene = Scene_Map.new
        return
      end
    end
    return
    end
    if Input.trigger?(Input::R) or Input.trigger?(Input::RIGHT)
      $game_system.se_play($data_system.cursor_se)
      @actor_index = 1
      @actor_index %= $game_party.actors.size
      $scene = Scene_Skill.new(@actor_index)
      return
    end
    if Input.trigger?(Input::L) or Input.trigger?(Input::LEFT)
      $game_system.se_play($data_system.cursor_se)
      @actor_index = $game_party.actors.size - 1
      @actor_index %= $game_party.actors.size
      $scene = Scene_Skill.new(@actor_index)
      return
    end
  end
  def update_target
    if Input.trigger?(Input::X)
      $game_system.se_play($data_system.cancel_se)
      @skill_window.active = true
      @target_window.visible = false
      @target_window.active = false
      return
    end
    if Input.trigger?(Input::C)
      unless @actor.skill_can_use?(@skill.id)
      $game_system.se_play($data_system.buzzer_se)
      return
    end
    if @target_window.index == -1
      used = false
      for i in $game_party.actors
        used |= i.skill_effect(@actor, @skill)
      end
    end
    if @target_window.index = 0
      target = $game_party.actors[@target_window.index]
      used = target.skill_effect(@actor, @skill)
    end
    if used
      $game_system.se_play(@skill.menu_se)
      @actor.sp -= @skill.sp_cost
      @status_window.refresh
      @skill_window.refresh
      @target_window.refresh
      if $game_party.all_dead?
        $scene = Scene_Gameover.new
        return
      end
    if @skill.common_event_id > 0
      $game_temp.common_event_id = @skill.common_event_id
      $scene = Scene_Map.new
      return
    end
  end
  unless used
    $game_system.se_play($data_system.buzzer_se)
  end
  return
  end
  end

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
The link doesn't work :(

My initial guess is that self.contents has not been defined.?

**
Rep: +0/-0Level 84
Hey Modern, A few of us figured out wat was going on, it was some if statement that was throwing the error, kinda wierd. But anyways, I figured that the script doesn't actually add any functionality to the skill menu, but just rearranges some windows, so I could instead of trying to convert this script, I can just try to rearrange the existing skill script from VX.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Mmm, yeah - my guess was that the if contents.width ... condition was throwing the error as a result of contents being nil at the time the method was run. Anyway, I'm glad you figured it out and good luck with the project.

**
Rep: +0/-0Level 84
Actually it was this line which caused the error, found in the Window_Skill2 portion: if @item_max > 0

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Yes, it caused the error because you define self.contents in that condition. If there is a case, where @item_max is not > 0, then self.contents would remain undefined. Thus, when the item_rect method is called in the course of updating the window,  there is no self.contents defined and that is why you get the error occurring in Window_Selectable.

Removing the condition @item_max > 0 made it so that self.contents would be defined even when @item_max was 0 and thus no error would occur under that circumstance.