Notice: fwrite(): Write of 483 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96

Notice: fwrite(): Write of 59 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96

Notice: fwrite(): Write of 1714 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96

Notice: fwrite(): Write of 44 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96

Notice: fwrite(): Write of 8192 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96
Print Page - Filling the Gauge?

The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: Kalacious on November 01, 2012, 05:28:08 PM

Title: Filling the Gauge?
Post by: Kalacious on November 01, 2012, 05:28:08 PM
So I have the code listed bellow - the whole script works except for the fil_rate. It works if your max variable is 10, cause 0.1 * 10 = 1

So what should I change to allow people to have max variables for thier variables of say 675 or 324 or 15 or even 1?

If your looking to set this up your self to test it:

event script

$game_gauge.set_var_id(id of variable)
$game_gauge.set_var_max(the max amount a variable should be)
$game_gauge.set_show(true)

then in your event set up your variable as:

if v[id - should match variable_id] == max (should match variable_max)
    $game_gauge.set_show(false)
else
    v[id] += 1
end

For testing I used Variable id 10 with a max of ten to watch the gauge fill up.


module VP
  module Config
    WINDOW_WIDTH = 180
    WINDOW_HEIGHT = 0
    WINDOW_X = 0
    WINDOW_Y = 0
   
    GAUGE_X = 0
    GAUGE_Y = 0
    GAUGE_WIDTH = 160
    GAUGE_COLOR_ONE = 10
    GAUGE_COLOR_TWO = 6
  end
end


module DataManager
  class << self
    alias create_gameobjects_vp_hdsfy45 create_game_objects
  end

  def self.create_game_objects
    create_gameobjects_vp_hdsfy45
    $game_gauge = Game_Gauge.new
  end
   
end
 
class Game_Gauge
  attr_accessor :variable_id
  attr_accessor :variable_max
  attr_accessor :show
 
  def set_var_id(id)
    @variable_id = id
  end
 
  def set_var_max(max)
    @variable_max = max
  end
 
  def set_show(show)
    @show = show
  end
end

class Scene_Map
 
  alias create_all_windows_vp_fhhjse5 create_all_windows
  def create_all_windows
    create_all_windows_vp_fhhjse5
    create_gauge
  end
 
  def create_gauge
    @gauge = Window_Gauge.new()
  end
 
end

class Window_Gauge < Window_Base
 
  def initialize
    super(0, 0, window_width, window_height)
    refresh
  end

  def window_width
    if VP::Config::WINDOW_WIDTH == 0
      return 180
    else
      return VP::Config::WINDOW_WIDTH
    end
  end
 
   
  def window_height
    if VP::Config::WINDOW_HEIGHT == 0
      return fitting_height(1)
    else
      return VP::Config::WINDOW_HEIGHT
    end
  end
   

  def refresh
    contents.clear
  end
 
  def update
    super
    if $game_gauge.show
      self.visible = true
    else
      self.visible = false
    end
    draw_gauge(0, -5, 160, fil_rate, text_color(gauge_color_one),
      text_color(gauge_color_two))
  end

  def fil_rate
    if $game_gauge.variable_id != nil
      if $game_gauge.variable_max >= $game_variables[$game_gauge.variable_id]
        return 0.1 * $game_variables[$game_gauge.variable_id]
      end
    else
      return 0
    end
  end
 
  def gauge_color_one
    return VP::Config::GAUGE_COLOR_ONE
  end
 
  def gauge_color_two
    return VP::Config::GAUGE_COLOR_TWO
  end
 
  def open
    refresh
    super
  end
end