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.

Anything wrong with this script? Why's it not working???????

Hi. Found this script to display pics before the opening menu (eg. company ads etc.)

This is the script I found and changed slightly for my picture:

Code:
class Scene_Intro

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     actor_index : actor index

  #--------------------------------------------------------------------------

  def initialize

      $ads = 0

  end

  #--------------------------------------------------------------------------

  # * Main Processing

  #--------------------------------------------------------------------------

  def main

    # Load database

    $data_actors        = load_data("Data/Actors.rxdata")

    $data_classes       = load_data("Data/Classes.rxdata")

    $data_skills        = load_data("Data/Skills.rxdata")

    $data_items         = load_data("Data/Items.rxdata")

    $data_weapons       = load_data("Data/Weapons.rxdata")

    $data_armors        = load_data("Data/Armors.rxdata")

    $data_enemies       = load_data("Data/Enemies.rxdata")

    $data_troops        = load_data("Data/Troops.rxdata")

    $data_states        = load_data("Data/States.rxdata")

    $data_animations    = load_data("Data/Animations.rxdata")

    $data_tilesets      = load_data("Data/Tilesets.rxdata")

    $data_common_events = load_data("Data/CommonEvents.rxdata")

    $data_system        = load_data("Data/System.rxdata")

    $game_system = Game_System.new

    @window = Window_Intro.new

    @frame = 0

    Audio.me_stop

    Audio.bgs_stop

    Graphics.transition

    loop do

      Graphics.update

      Input.update

      update

      if $scene != self

        break

      end

    end

    # Prepare for transition

    Graphics.freeze

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    if Graphics.frame_count / Graphics.frame_rate != @total_sec

      @frame += 1

      @total_sec = Graphics.frame_count / Graphics.frame_rate

    end

    if @frame >= 5

      @window.contents_opacity -= 10

      if @window.contents_opacity < 1

         if $ads == 1

         @window.dispose

         $scene = Scene_Title.new

         else

         $ads +=1

         @window.contents_opacity = 255

         @frame = 0

         @window.refresh

         end

      end

    end

  end

end

 

class Window_Intro < Window_Base

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    super(-16, -16, 672, 512)

    self.contents = Bitmap.new(width - 32, height - 32)

    self.opacity = 0

    refresh

  end

  #--------------------------------------------------------------------------

  # * Refresh

  #--------------------------------------------------------------------------

  def refresh

    bitmap1 = RPG::Cache.picture("digibeet production.jpg")

    bitmap = [bitmap1]

    self.contents.blt(0, 0, bitmap[$ads], Rect.new(0, 0, 640, 480))

  end

end

 

So why is it not working???!!!!!! Is there something wrong with it??!!!

Thanks
 

EOG

Member

It is set to show 2 pictures before Scene_Title and you gave it only one image.

Ways to fix:
1. Set to one picture:
Change line 55 to
Code:
if $ads == 0

2. Put another picture:
Add new line in line 84
Code:
bitmap2 = RPG::Cache.picture("2ndpicture")
and in change line
Code:
bitmap = [bitmap1]
to
Code:
bitmap = [bitmap1,bitmap2]
 
Thanks for replying.

I went for the first method as i only have 1 image to display. This is the new code I used:

Code:
class Scene_Intro

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     actor_index : actor index

  #--------------------------------------------------------------------------

  def initialize

      $ads = 0

  end

  #--------------------------------------------------------------------------

  # * Main Processing

  #--------------------------------------------------------------------------

  def main

    # Load database

    $data_actors        = load_data("Data/Actors.rxdata")

    $data_classes       = load_data("Data/Classes.rxdata")

    $data_skills        = load_data("Data/Skills.rxdata")

    $data_items         = load_data("Data/Items.rxdata")

    $data_weapons       = load_data("Data/Weapons.rxdata")

    $data_armors        = load_data("Data/Armors.rxdata")

    $data_enemies       = load_data("Data/Enemies.rxdata")

    $data_troops        = load_data("Data/Troops.rxdata")

    $data_states        = load_data("Data/States.rxdata")

    $data_animations    = load_data("Data/Animations.rxdata")

    $data_tilesets      = load_data("Data/Tilesets.rxdata")

    $data_common_events = load_data("Data/CommonEvents.rxdata")

    $data_system        = load_data("Data/System.rxdata")

    $game_system = Game_System.new

    @window = Window_Intro.new

    @frame = 0

    Audio.me_stop

    Audio.bgs_stop

    Graphics.transition

    loop do

      Graphics.update

      Input.update

      update

      if $scene != self

        break

      end

    end

    # Prepare for transition

    Graphics.freeze

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    if Graphics.frame_count / Graphics.frame_rate != @total_sec

      @frame += 1

      @total_sec = Graphics.frame_count / Graphics.frame_rate

    end

    if @frame >= 5

      @window.contents_opacity -= 10

      if @window.contents_opacity < 1

         if $ads == 0

         @window.dispose

         $scene = Scene_Title.new

         else

         $ads +=1

         @window.contents_opacity = 255

         @frame = 0

         @window.refresh

         end

      end

    end

  end

end

 

class Window_Intro < Window_Base

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    super(-16, -16, 672, 512)

    self.contents = Bitmap.new(width - 32, height - 32)

    self.opacity = 0

    refresh

  end

  #--------------------------------------------------------------------------

  # * Refresh

  #--------------------------------------------------------------------------

  def refresh

    bitmap1 = RPG::Cache.picture("digibeet production.jpg")

    bitmap = [bitmap1]

    self.contents.blt(0, 0, bitmap[$ads], Rect.new(0, 0, 640, 480))

  end

end

 

Still not working - any ideas? Or should i try it with 2 pics and then see if it works?
 

EOG

Member

Your problem is here:
Code:
bitmap1 = RPG::Cache.picture("digibeet production.jpg")
RPG Maker automatically finds the extention so change this line to
Code:
bitmap1 = RPG::Cache.picture("digibeet production")
If this still does not work check if you've imported the picture and if the name is exactly the same.
 
Changed name so it doesn't have an extension, also renamed file so it does not have a space (just in case) in both the script and the pictures folder. Both definately match each other. Code:

Code:
class Scene_Intro

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     actor_index : actor index

  #--------------------------------------------------------------------------

  def initialize

      $ads = 0

  end

  #--------------------------------------------------------------------------

  # * Main Processing

  #--------------------------------------------------------------------------

  def main

    # Load database

    $data_actors        = load_data("Data/Actors.rxdata")

    $data_classes       = load_data("Data/Classes.rxdata")

    $data_skills        = load_data("Data/Skills.rxdata")

    $data_items         = load_data("Data/Items.rxdata")

    $data_weapons       = load_data("Data/Weapons.rxdata")

    $data_armors        = load_data("Data/Armors.rxdata")

    $data_enemies       = load_data("Data/Enemies.rxdata")

    $data_troops        = load_data("Data/Troops.rxdata")

    $data_states        = load_data("Data/States.rxdata")

    $data_animations    = load_data("Data/Animations.rxdata")

    $data_tilesets      = load_data("Data/Tilesets.rxdata")

    $data_common_events = load_data("Data/CommonEvents.rxdata")

    $data_system        = load_data("Data/System.rxdata")

    $game_system = Game_System.new

    @window = Window_Intro.new

    @frame = 0

    Audio.me_stop

    Audio.bgs_stop

    Graphics.transition

    loop do

      Graphics.update

      Input.update

      update

      if $scene != self

        break

      end

    end

    # Prepare for transition

    Graphics.freeze

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    if Graphics.frame_count / Graphics.frame_rate != @total_sec

      @frame += 1

      @total_sec = Graphics.frame_count / Graphics.frame_rate

    end

    if @frame >= 5

      @window.contents_opacity -= 10

      if @window.contents_opacity < 1

         if $ads == 0

         @window.dispose

         $scene = Scene_Title.new

         else

         $ads +=1

         @window.contents_opacity = 255

         @frame = 0

         @window.refresh

         end

      end

    end

  end

end

 

class Window_Intro < Window_Base

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    super(-16, -16, 672, 512)

    self.contents = Bitmap.new(width - 32, height - 32)

    self.opacity = 0

    refresh

  end

  #--------------------------------------------------------------------------

  # * Refresh

  #--------------------------------------------------------------------------

  def refresh

    bitmap1 = RPG::Cache.picture("digibeetproduction")

    bitmap = [bitmap1]

    self.contents.blt(0, 0, bitmap[$ads], Rect.new(0, 0, 640, 480))

  end

end


Still doesn't not work! :mad: I really need this problem sorted!
 
Have you changed the line in main that goes to the title screen? This could be causing the issue rather than the script itself, if you've not changed anything in main, try changing the line;
Code:
$scene = Scene_Title.new
to
Code:
 $scene = Scene_Intro.new
 
Sure to enable BGS and BGM on this script all you have to do is add the lines;

Code:
$game_system.bgm_play(RPG::AudioFile.new('001-Battle01'))
And/Or
Code:
$game_system.bgs_play(RPG::AudioFile.new('001-Wind01'))

Place this under the line;
Code:
$game_system = Game_System.new
This should work fine for you, post and I'll see whats up.
 
Thanks a lot! When it played the sound it only played a very small part of it. I changed the line to:

Code:
$game_system.SE_play(RPG::AudioFile.new(

and it played the whole thing. (It was a SE not a BGS). Cheers!

[Name added to thanks page of my game]
 

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