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 with this simple script

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 40
Moogle Master
I am test playing a modification to a script I have that creates a help HUD for an ABS. The unmodded scripts works great, but the modded version I created (to add a HUD for MP as well) as soon as I click new game crashes and gives me RGSS3 player has stopped working. I will post my modded script here and see if you can get it working please. It is a simple script.

Here is the unmodded script. Can someone help me get this to include a MP HUD as well done just as the heart system is.
Spoiler for:
module Cache
  #--------------------------------------------------------------------------
  # * Get Hud Graphic
  #--------------------------------------------------------------------------
  def self.hud(filename, hue=0)
    load_bitmap("Graphics/System/Hud/", filename, hue)
  end
end
 
class ZeldaHearts < Window_Base
  #--------------------------------------------------------------------------
  # * Changeable Area
  #--------------------------------------------------------------------------
  def switch
    90
  end
 
  def hud_x
    0
  end
 
  def hud_y
    0
  end
 
  def hud_width
    400
  end
 
  def hud_height
    240
  end
 
  def heart_file
    "hearts"
  end
 
  def heart_width
    24
  end
 
  def heart_padding
    -10
  end
 
  def heart_rowheight
    -10
  end
 
  def heart_row
    10
  end
 
  def hp_per_heart
    4
  end
 
  def heart_pieces
    4
  end
 
  #--------------------------------------------------------------------------
  # * Fixed Area
  #--------------------------------------------------------------------------
  def initialize
    super(hud_x, hud_y, hud_width, hud_height)
    self.windowskin = nil
    @bitmap = Cache.hud(heart_file)
    @switch = $game_switches[switch]
    if @switch
      draw_hearts
    end
  end
 
  def draw_hearts
    @lhearts = @hearts
    @lmaxHearts = @maxHearts
    @hearts = calc_hearts(get_hp)
    @maxHearts = calc_hearts(get_maxhp).to_i
   
    fullHearts = @hearts.to_i
    partHearts = @hearts - fullHearts
    i = 0
    if fullHearts
      for i in 0..@maxHearts-1 do     
        if i < fullHearts
          get_heart_image(i, heart_pieces)
        elsif i == fullHearts
          get_heart_image(i, (partHearts*heart_pieces).round(0))
        else
          get_heart_image(i,0)
        end
      end
    end
  end
 
  def get_heart_image(heartIndex, fileIndex)   
    rect = Rect.new(fileIndex * heart_width, 0, @bitmap.width/(heart_pieces+1), @bitmap.height)
    contents.blt(heartIndex.modulo(heart_row)*(heart_width+heart_padding), (heartIndex/heart_row)*(@bitmap.height+heart_rowheight), @bitmap, rect, 255)
  end
 
  def get_hp
    $game_party.members[0].hp
  end
 
  def get_maxhp
    $game_party.members[0].mhp
  end
 
  def calc_hearts(hp)
    Float hearts = hp.to_f / hp_per_heart
    hearts.round(2)
  end
 
  def refresh
    self.contents.clear
    contents.clear
    draw_hearts
  end
  def update
    super   
    if @switch
      refresh
    end
  end
 
  def change 
    if @switch != $game_switches[switch]
      if $game_switches[switch]
        update
      else
        contents.clear
        self.contents.clear
      end
      @switch = $game_switches[switch]
    end
    if @lhearts == @hearts && @lmaxHearts == @maxHearts
      return
    else
      update
    end
  end
 
  def dispose
    super
    @bitmap.dispose
  end
end
 
class Scene_Map < Scene_Base
  alias start_window start
  alias term_window terminate
  alias update_window update
 
  def start
    start_window
    @hearthud = ZeldaHearts.new 
    update
  end
 
  def terminate
    @hearthud.dispose
    term_window
  end
 
  def update
    update_window
    @hearthud.change
  end
end

*
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Rep:
Level 96
&&&&&&&&&&&&&&&&&&&&&&&&&&&
GIAW 14: 2nd Place (Hard Mode)2013 Biggest Drama Whore2013 Zero to HeroParticipant - GIAW 11Secret Santa 2013 ParticipantFor taking arms in the name of your breakfast.
i can give it a shot lol :D :D ;D
check back in a lttle bit :D ^_^ :0

EDIT: I can't even try to help. The reason for this, is that I can't even get the script to work unmodified without the required images.

Please upload the images, or post a link to the original script.
« Last Edit: September 24, 2013, 06:14:00 AM by Cuttershy »
&&&&&&&&&&&&&&&&

**
Rep: +0/-0Level 46
Evented AI
I have created a quick solution for DarthVollis, after he has pm'd me.  :)

Just in case (unpolished version):
Spoiler for:
Code: [Select]
module Cache
  #--------------------------------------------------------------------------
  # * Get Hud Graphic
  #--------------------------------------------------------------------------
  def self.hud(filename, hue=0)
    load_bitmap("Graphics/System/Hud/", filename, hue)
  end
end


class ZeldaHearts < Window_Base
  #--------------------------------------------------------------------------
  # * Changeable Area
  #--------------------------------------------------------------------------
  def switch
    90
  end
 
  def hud_x
    0
  end
 
  def hud_y
    0
  end
 
  def hud_width
    400
  end
 
  def hud_height
    240
  end
 
  def heart_file
    "hearts"
  end
 
  def heart_width
    24
  end
 
  def heart_padding
    -10
  end
 
  def heart_rowheight
    -10
  end
 
  def heart_row
    10
  end
 
  def hp_per_heart
    4
  end
 
  def heart_pieces
    4
  end
 
  #--------------------------------------------------------------------------
  # * Fixed Area
  #--------------------------------------------------------------------------
  def initialize
    super(hud_x, hud_y, hud_width, hud_height)
    self.windowskin = nil
    @bitmap = Cache.hud(heart_file)
    @switch = $game_switches[switch]
    if @switch
      draw_hearts
    end
  end
 
  def draw_hearts
    @lhearts = @hearts
    @lmaxHearts = @maxHearts
    @hearts = calc_hearts(get_hp)
    @maxHearts = calc_hearts(get_maxhp).to_i
   
    fullHearts = @hearts.to_i
    partHearts = @hearts - fullHearts
    i = 0
    if fullHearts
      for i in 0..@maxHearts-1 do     
        if i < fullHearts
          get_heart_image(i, heart_pieces)
        elsif i == fullHearts
          get_heart_image(i, (partHearts*heart_pieces).round(0))
        else
          get_heart_image(i,0)
        end
      end
    end
  end
 
  def get_heart_image(heartIndex, fileIndex)   
    rect = Rect.new(fileIndex * heart_width, 0, @bitmap.width/(heart_pieces+1), @bitmap.height)
    contents.blt(heartIndex.modulo(heart_row)*(heart_width+heart_padding), (heartIndex/heart_row)*(@bitmap.height+heart_rowheight), @bitmap, rect, 255)
  end
 
  def get_hp
    $game_party.members[0].hp
  end
 
  def get_maxhp
    $game_party.members[0].mhp
  end
 
  def calc_hearts(hp)
    Float hearts = hp.to_f / hp_per_heart
    hearts.round(2)
  end
 
  def refresh
    self.contents.clear
    contents.clear
    draw_hearts
  end
  def update
    super   
    if @switch
      refresh
    end
  end
 
  def change 
    if @switch != $game_switches[switch]
      if $game_switches[switch]
        update
      else
        contents.clear
        self.contents.clear
      end
      @switch = $game_switches[switch]
    end
    if @lhearts == @hearts && @lmaxHearts == @maxHearts
      return
    else
      update
    end
  end
 
  def dispose
    super
    @bitmap.dispose
  end
end


class Scene_Map < Scene_Base
  alias start_window start
  alias term_window terminate
  alias update_window update
 
  def start
    start_window
    @hearthud = ZeldaHearts.new 
    @manahud = ZeldaMana.new
    update
  end


  def terminate
    @hearthud.dispose
    @manahud.dispose
    term_window
  end


  def update
    update_window
    @hearthud.change
    @manahud.change
  end
end


#~ Mana Addon:
class ZeldaMana < Window_Base
  #--------------------------------------------------------------------------
  # * Changeable Area
  #--------------------------------------------------------------------------
  def switch
    90
  end
 
  def hud_x
    0
  end
 
  def hud_y
    0
  end
 
  def hud_width
    400
  end
 
  def hud_height
    240
  end
 
  def mana_file
    "mana"
  end
 
  def mana_width
    24
  end
 
  def mana_padding
    -10
  end
 
  def mana_rowheight
    -10
  end
 
  def mana_row
    10
  end
 
  def mp_per_mana
    4
  end
 
  def mana_pieces
    4
  end
 
  #--------------------------------------------------------------------------
  # * Fixed Area
  #--------------------------------------------------------------------------
  def initialize
    super(hud_x, hud_y, hud_width, hud_height)
    self.windowskin = nil
    @bitmap = Cache.hud(mana_file)
    @switch = $game_switches[switch]
    if @switch
      draw_mana
    end
  end
 
  def draw_mana
    @lmana = @mana
    @lmaxMana = @maxMana
    @mana = calc_mana(get_mp)
    @maxMana = calc_mana(get_maxmp).to_i
   
    fullMana = @mana.to_i
    partMana = @mana - fullMana
    i = 0
    if fullMana
      for i in 0..@maxMana-1 do     
        if i < fullMana
          get_mana_image(i, mana_pieces)
        elsif i == fullMana
          get_mana_image(i, (partMana*mana_pieces).round(0))
        else
          get_mana_image(i,0)
        end
      end
    end
  end
 
  def get_mana_image(manaIndex, fileIndex)   
    rect = Rect.new(fileIndex * mana_width, 0, @bitmap.width/(mana_pieces+1), @bitmap.height)
    contents.blt(manaIndex.modulo(mana_row)*(mana_width+mana_padding), (manaIndex/mana_row)*(@bitmap.height+mana_rowheight), @bitmap, rect, 255)
  end
 
  def get_mp
    $game_party.members[0].mp
  end
 
  def get_maxmp
    $game_party.members[0].mmp
  end
 
  def calc_mana(mp)
    Float mana = mp.to_f / mp_per_mana
    mana.round(2)
  end
 
  def refresh
    self.contents.clear
    contents.clear
    draw_mana
  end
  def update
    super   
    if @switch
      refresh
    end
  end
 
  def change 
    if @switch != $game_switches[switch]
      if $game_switches[switch]
        update
      else
        contents.clear
        self.contents.clear
      end
      @switch = $game_switches[switch]
    end
    if @lmana == @mana && @lmaxMana == @maxMana
      return
    else
      update
    end
  end
 
  def dispose
    super
    @bitmap.dispose
  end
end

**
Rep: +0/-0Level 40
Moogle Master
Thanks for the help everyone! Jester solved it.