Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Loading script

Loading Script


Script Title:Loading Script
Description:
I was wondwering if somebody could either show me one that allready exists or make one for me please.
what i am looking for is a loading scene..so when i call a scriptt like
scene = load$.... or something.. OR when the player changes mapps there is a short loading scene with Loading... in the middle..
Other Scripts I am using (in order):
Prexus Crafting script
and cocas AMS
Ring Menu.. thats it

thank you for your time =)
 
I made this real quick. Should only have to modify settings in the Loading module (for basic setup).
[rgss]module Loading
  Background = 'Loading'
  Time_Between_Load = 4
  Load_Range = 1..5
  Bar_Rect = Rect.new(320, 240, 128, 12)
  Bar_Color1 = Color.new(255, 0, 0)
  Bar_Color2 = Color.new(0, 0, 255)
  Bar_Color3 = Color.new(128, 128, 128)
  Loading_Scenes = [Scene_Map, Scene_Battle]
end
 
class Loading::Bar < Sprite
  include Loading
  attr_reader :percent
  def initialize
    viewport = Viewport.new(Bar_Rect.x, Bar_Rect.y, Bar_Rect.width + 48, Bar_Rect.height)
    super(viewport)
    self.bitmap = Bitmap.new(Bar_Rect.width + 48, Bar_Rect.height)
    self.bitmap.font.size = Bar_Rect.height
    @percent = 0
    refresh
  end
  def refresh
    self.bitmap.clear
    draw_gradient_bar(0, 0, @percent, 100, Bar_Rect.width, Bar_Rect.height)
    self.bitmap.draw_text(Bar_Rect.width + 4, 0, 42, self.bitmap.height,
      "#{@percent} %")
  end
  def update
    if Graphics.frame_count % Time_Between_Load == 0
      @percent = [@percent + Load_Range.random, 100].min
      refresh
    end
  end
  def draw_gradient_bar(x, y, cur, max, width = 152, height = 8,
      s_color = Bar_Color1, e_color = Bar_Color2, b_color = Bar_Color3)
    self.bitmap.fill_rect(x, y, width, height, b_color)
    for i in 1...((cur / max.to_f) * (width - 1))
      c = Color.color_between(s_color, e_color, (i / width.to_f))
      self.bitmap.fill_rect(x + i, y + 1, 1, height - 2, c)
    end
  end
end
 
class Range
  def random
    return self.to_a.random
  end
end
 
class Array
  def random
    return self[rand(size)]
  end
end  
 
class Scene_Loading
  def initialize(next_scene = Scene_Map)
    @next_scene = next_scene
  end
  def main
    @sprite = Sprite.new
    @sprite.bitmap = RPG::Cache.picture('Loading')
    @bar = Loading::Bar.new
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      break if $scene != self
    end
    Graphics.freeze
    @sprite.dispose
    @bar.dispose
  end
  def update
    @bar.update
    if @bar.percent == 100
      if Input.trigger?(Input::C)
        $scene = @next_scene.new
      end
    end
  end
end
 
for class_name in Loading::Loading_Scenes
  s  = "class #{class_name};"
  unless Module.const_defined?:)SDK)
    s += "  alias_method :seph_loading_#{class_name.to_s.downcase}_init, :initialize;"
    s += "  def initialize(*args);"
    s += "    @previous_scene = $scne.class;"
    s += "    seph_loading_#{class_name.to_s.downcase}_init(*args);"
    s += "  end;"
  end
  s += "  alias_method :seph_loading_#{class_name.to_s.downcase}_main, :main;"
  s += "  def main;"
  s += "    unless @previous_scene == Scene_Loading;"
  s += "      $scene = Scene_Loading.new(#{class_name});"
  s += "      return;"
  s += "    end;"
  s += "    seph_loading_#{class_name.to_s.downcase}_main;"
  s += "  end;"
  s += "end;"
  eval s
end
 
[/rgss]
 

VCA

Member

ScreenHunter_01Feb282326.jpg


What does this mean. i got this error while testing this script. can anyone tell me how to fix it? please?
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top