RMRK is retiring.
Server is paid up for the rest of 2026, but the forum may go after that. See here for more information. Please archive or save anything you would like to keep before 2027.
Main Menu
  • Welcome to The RPG Maker Resource Kit.

RMVXA (Script Request) Skip missing resource

Started by &&&&&&&&&&&&&, April 15, 2013, 10:11:06 PM

0 Members and 1 Guest are viewing this topic.

&&&&&&&&&&&&&

I was wondering if a script that just skipped missing resources existed.

Scenario:
"Map 1" has "BGM A"
I delete "BGM A"
When I play "Map 1" the game crashes "Missing BGM A!"

What I'm looking for:
"Map 1" has "BGM A"
I delete "BGM A"
When I play "Map 1" it just doesn't play any music.


Why did they do this? Most games (non-rpg maker) that have a missing file, that file just doesn't load. Why does a missing file just out right crash the game?

ts;dc
Also, this is probably something handled at a level that scripts can't change. I was just hoping that it was possible to change this with a script or something, IDK.
&&&&&&&&&&&&&&&&

cozziekuns

#1
I'm skeptical that this will be error free due to how quickly I made this little snippet, but this should work:


#==============================================================================
# ** Audio
#==============================================================================

class << Audio
 
  [:bgm, :bgs, :me, :se].each { |method|
    alias_method("coz_aud_skmrsc_#{method}_play".intern, "#{method}_play".intern)
    define_method("#{method}_play".intern) { |filename, *args|
      send("coz_aud_skmrsc_#{method}_play".intern, filename, *args) rescue nil
    }
  }
 
end

#==============================================================================
# ** Cache
#==============================================================================

class << Cache

  alias coz_cch_skmrsc_load_bitmap load_bitmap
  def load_bitmap(*args)
    coz_cch_skmrsc_load_bitmap(*args) rescue empty_bitmap
  end

end

&&&&&&&&&&&&&

Wow. Thank you.
It works perfectly. I made a test map, set a song, then deleted it. The game just continued on like normal.

I don't know why they didn't just make it this way. >_>

Again, thank you. ^_^
&&&&&&&&&&&&&&&&

Wiimeiser