How do you call a specific method in a class that has been aliased?

boldpaste2

The Dragon Heretics
Veteran
Joined
Dec 7, 2013
Messages
797
Reaction score
439
First Language
English
Primarily Uses
I was wondering how I can manually reinitialize a class within a script. I am trying to call a part of Khas sapphire engine to reinitialize because the normal means of how it works is never used. Pretty much, this class is used to change the graphic of weapon when it is equipped. (and going through the equip menu reinitialize it, unfortunately for me, all my equipping is done through script calls so the weapon graphic does not update).

So, in the script fragment below, how can I rerun initialize or refresh_weapon from a script call.

Code:
...class Spriteset_Map  alias sas_update update  alias sas_initialize initialize  alias sas_dispose dispose  def initialize    @trash = []    $game_map.show_particles    $game_map.show_damage_sprites    $game_map.sas_hud.show    sas_initialize    @weapon_graphic = Sprite.new(@viewport1)    @weapon_graphic.ox = 22    @weapon_graphic.oy = 22    @attacking = false    @attack_timer = 0    @angles = {2=>[80,110,140,170],4=>[340,10,40,70],6=>[290,260,230,200],8=>[290,320,350,20]}    @correction = {2=>[-8,-10],4=>[0,-10],6=>[0,-4],8=>[4,-10]}    @z_values = {2=>120,4=>50,6=>120,8=>50}    refresh_weapon  end    def refresh_weapon    @weapon_bitmap.dispose unless @weapon_bitmap.nil?    @weapon_bitmap = nil    return if $game_party.members.empty?    index = ($game_party.members[0].weapons[0].icon_index rescue nil)    unless index == nil      temp = Cache.system("Iconset")      @weapon_bitmap = Bitmap.new(24,24)      @weapon_bitmap.blt(0,0,temp,Rect.new(index%16*24,index/16*24,24,24))      temp.dispose      temp = nil    end  end...end
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,575
Reaction score
3,781
First Language
Java's Crypt
Primarily Uses
RMMZ
I suspect I understood your question wrong, but:


Spriteset_Map is initialized when the map Scene is first loaded...


Your best bet would be to either:


1) Change something on Scene_Map to destroy and recreate the spriteset (methods dispose_spriteset and create_spriteset). You will need to be careful where you call this from.


2) Change scene to another Scene_Map.
 
Last edited by a moderator:

boldpaste2

The Dragon Heretics
Veteran
Joined
Dec 7, 2013
Messages
797
Reaction score
439
First Language
English
Primarily Uses
I suspect I understood your question wrong, but:

Spriteset_Map is initialized when the map Scene is first loaded...

Your best bet would be to either:

1) Change something on Scene_Map to destroy and recreate the spriteset (methods dispose_spriteset and create_spriteset). You will need to be careful where you call this from.

2) Change scene to another Scene_Map.
You pretty much understand the issue. :p

1) Crashes no matter where I call it lol.

2) Doesn't seem to run the class

Whenever you open a menu (and in my case, the only menu accessible is the save) it will refresh and change the graphic to what it should be. So maybe creating an empty Scene that closes itself when called? (wonder if that is even possible).
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,575
Reaction score
3,781
First Language
Java's Crypt
Primarily Uses
RMMZ
Well, you only need to refresh the graphic? In that case you shouldn't be reinitializing the whole spriteset. That's what I meant with "understood wrong".

Edit:

It's the weapon graphic that you need to refresh?

Add this on the script list:

Code:
class Scene_Map < Scene_Base  attr_reader :spritesetend
and call this:

Code:
SceneManager.scene.spriteset.refresh_weapon if SceneManager.scene.is_a? Scene_Map
 
Last edited by a moderator:

boldpaste2

The Dragon Heretics
Veteran
Joined
Dec 7, 2013
Messages
797
Reaction score
439
First Language
English
Primarily Uses
That did the trick ^^

2 hours of me messing with the script for it to be fixed with 3 lines of code xD

Thank you for helping me out with that. I was about to go mad. ^^
 
Last edited by a moderator:

Latest Threads

Latest Posts

Latest Profile Posts

Hey everyone, we know that the edit bar is missing. We're working on it. You can talk about it in the announcement here: https://forums.rpgmakerweb.com/index.php?threads/forum-errors-missing-edit-bar-etc.132715/
So, explain why we can no longer use BBC code or smilies in our posts? This sparks much sadness...
Are we now stuck with WYSIWYG ? I cannot revert back my posts to good old raw text ?
I'm wondering if I may be putting too many things into one map. A story, within a story, within a story . . . it's fun, but I can't shake the feeling that it may be better to scrap some of it, and use it for another map. I'm not sure what to do.

Forum statistics

Threads
107,789
Messages
1,032,205
Members
139,939
Latest member
Mineformer
Top