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.
Small Scripting Problem

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2010 Best Use Of Avatar And Signature Space2010 Favourite Staff Member
To practice with Ruby, I decided I would rearrange my Status Screen, and include a picture of a battler. This went pretty well, but when I input my battler, the sprite picture disappeard. I thought at first this was because I defined the battler image as draw_actor_graphic, i.e. the same as the sprite, but when I change it, the sprite comes back but the battler disappears. This is a screenshot:


The part in red is approximately where the sprite should be. And the code is:

Code: [Select]
#==============================================================================
# ** Window_Status
#------------------------------------------------------------------------------
#  This window displays full status specs on the status screen.
#==============================================================================

class Window_Status < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 0, 640, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_actor_graphic(@actor, 40, 112)
    draw_actor_name(@actor, 4, 0)
    draw_actor_class(@actor, 195 + 80, 0)
    draw_actor_state(@actor, 85, 0)
    draw_actor_hp(@actor, 0, 112, 172)
    draw_actor_sp(@actor, 0, 144, 172)
    draw_actor_parameter(@actor, 0, 192, 0)
    draw_actor_parameter(@actor, 0, 224, 1)
    draw_actor_parameter(@actor, 0, 256, 2)
    draw_actor_parameter(@actor, 0, 304, 3)
    draw_actor_parameter(@actor, 0, 336, 4)
    draw_actor_parameter(@actor, 0, 368, 5)
    draw_actor_parameter(@actor, 0, 400, 6)
    self.contents.font.color = system_color
    self.contents.draw_text(195, 0, 80, 32, "Class")
    self.contents.font.color = system_color
    self.contents.draw_text(400, 0, 80, 32, "Experience")
    self.contents.font.color = normal_color
    self.contents.draw_text(400 + 80, 0, 84, 32, @actor.exp_s, 2)
    self.contents.font.color = system_color
    self.contents.draw_text(400, 64, 96, 32, "Equipment")
    draw_item_name($data_weapons[@actor.weapon_id], 400 + 16, 112)
    draw_item_name($data_armors[@actor.armor1_id], 400 + 16, 160)
    draw_item_name($data_armors[@actor.armor2_id], 400 + 16, 208)
    draw_item_name($data_armors[@actor.armor3_id], 400 + 16, 256)
    draw_item_name($data_armors[@actor.armor4_id], 400 + 16, 304)
  end
  def dummy
    self.contents.font.color = system_color
    self.contents.draw_text(320, 112, 96, 32, $data_system.words.weapon)
    self.contents.draw_text(320, 176, 96, 32, $data_system.words.armor1)
    self.contents.draw_text(320, 240, 96, 32, $data_system.words.armor2)
    self.contents.draw_text(320, 304, 96, 32, $data_system.words.armor3)
    self.contents.draw_text(320, 368, 96, 32, $data_system.words.armor4)
    draw_item_name($data_weapons[@actor.weapon_id], 320 + 24, 144)
    draw_item_name($data_armors[@actor.armor1_id], 320 + 24, 208)
    draw_item_name($data_armors[@actor.armor2_id], 320 + 24, 272)
    draw_item_name($data_armors[@actor.armor3_id], 320 + 24, 336)
    draw_item_name($data_armors[@actor.armor4_id], 320 + 24, 400)
  end
  def draw_actor_graphic(actor, x, y, opacity = 255)
  bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
  cw = bitmap.width
  ch = bitmap.height
  src_rect = Rect.new(0, 0, cw, ch)
  x = 230
  y = 100
  self.contents.blt(x, y, bitmap, src_rect, opacity)
  end
end

I'm really bad at scripting, so the problem is probably just a slight oversight on my part because of my limited knowledge of Ruby. Anyway, help would be appreciated.

******
Revolution is not a bed of roses.
Rep:
Level 91
Project of the Month winner for July 2009
Code: [Select]
Try this:
#==============================================================================
# ** Window_Status
#------------------------------------------------------------------------------
#  This window displays full status specs on the status screen.
#==============================================================================

class Window_Status < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 0, 640, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    refresh
  end
  def draw_actor_battler(actor, x, y, opacity = 255)
  bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
  cw = bitmap.width
  ch = bitmap.height
  src_rect = Rect.new(0, 0, cw, ch)
  x = 230
  y = 100
  self.contents.blt(x, y, bitmap, src_rect, opacity)
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_actor_graphic(@actor, 40, 112)
    draw_actor_battler(@actor, 40, 112)
    draw_actor_name(@actor, 4, 0)
    draw_actor_class(@actor, 195 + 80, 0)
    draw_actor_state(@actor, 85, 0)
    draw_actor_hp(@actor, 0, 112, 172)
    draw_actor_sp(@actor, 0, 144, 172)
    draw_actor_parameter(@actor, 0, 192, 0)
    draw_actor_parameter(@actor, 0, 224, 1)
    draw_actor_parameter(@actor, 0, 256, 2)
    draw_actor_parameter(@actor, 0, 304, 3)
    draw_actor_parameter(@actor, 0, 336, 4)
    draw_actor_parameter(@actor, 0, 368, 5)
    draw_actor_parameter(@actor, 0, 400, 6)
    self.contents.font.color = system_color
    self.contents.draw_text(195, 0, 80, 32, "Class")
    self.contents.font.color = system_color
    self.contents.draw_text(400, 0, 80, 32, "Experience")
    self.contents.font.color = normal_color
    self.contents.draw_text(400 + 80, 0, 84, 32, @actor.exp_s, 2)
    self.contents.font.color = system_color
    self.contents.draw_text(400, 64, 96, 32, "Equipment")
    draw_item_name($data_weapons[@actor.weapon_id], 400 + 16, 112)
    draw_item_name($data_armors[@actor.armor1_id], 400 + 16, 160)
    draw_item_name($data_armors[@actor.armor2_id], 400 + 16, 208)
    draw_item_name($data_armors[@actor.armor3_id], 400 + 16, 256)
    draw_item_name($data_armors[@actor.armor4_id], 400 + 16, 304)
  end
  def dummy
    self.contents.font.color = system_color
    self.contents.draw_text(320, 112, 96, 32, $data_system.words.weapon)
    self.contents.draw_text(320, 176, 96, 32, $data_system.words.armor1)
    self.contents.draw_text(320, 240, 96, 32, $data_system.words.armor2)
    self.contents.draw_text(320, 304, 96, 32, $data_system.words.armor3)
    self.contents.draw_text(320, 368, 96, 32, $data_system.words.armor4)
    draw_item_name($data_weapons[@actor.weapon_id], 320 + 24, 144)
    draw_item_name($data_armors[@actor.armor1_id], 320 + 24, 208)
    draw_item_name($data_armors[@actor.armor2_id], 320 + 24, 272)
    draw_item_name($data_armors[@actor.armor3_id], 320 + 24, 336)
    draw_item_name($data_armors[@actor.armor4_id], 320 + 24, 400)
  end
end

After the refresh method you changed the graphic method so it switched the one with the other.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2010 Best Use Of Avatar And Signature Space2010 Favourite Staff Member
Thanks, that worked well. Is there a way to close a topic?

********
EXA
Rep:
Level 92
Pikachu on a toilet
Project of the Month winner for April 2007
Yeah, you can lock your own topics. There is a button at the bottom that says Lock/Unlock. But I'll lock this one myself, so no worries.
Get King of Booze for Android, for iOS, for OUYA or for Windows!
Visit our website.
You can also love/hate us on Facebook or the game itself.


Get DropBox, the best free file syncing service there is!