Chaos Project

RPG Maker => RPG Maker Scripts => Script Requests => Topic started by: RoseSkye on February 18, 2018, 07:43:15 pm

Title: Script Call for changing event graphic.
Post by: RoseSkye on February 18, 2018, 07:43:15 pm
I tried searching the database and all I could find was @tile_id and set_graphic. Set graphic seems to give me errors while tile_id feels like it's for terrain. Can anyone give me an example call snippet for changing the in game graphic for events or player?

What I've tried -

$game_player.set_graphic('1139', 0, 2, 0)
$game_map.events[2].set_graphic('1139', 0, 2, 0)

Title: Re: Script Call for changing event graphic.
Post by: KK20 on February 18, 2018, 11:09:07 pm
set_graphic is defined for Game_Actor objects. $game_player is a subclass of Game_Character, so it does not have access to that method. You could get around this by accessing $game_party.actors or $game_actors[ID] instead, but that gets pretty messy. Not to mention events (Game_Event objects) aren't even Game_Actors, so you'd be screwed there.

There really is no easy script call to do this. So you will need to add this somewhere

class Game_Character
  def set_graphic(character_name, character_hue)
    @character_name = character_name
    @character_hue = character_hue
  end
end

which allows you to do the following script calls:
$game_player.set_graphic('001-Fighter01', 0)

$game_map.events[1].set_graphic('002-Fighter02', 180)

Granted with some line breaks in between since RMXP likes tiny textareas.
Title: Re: Script Call for changing event graphic.
Post by: RoseSkye on February 19, 2018, 01:11:16 am
Amazing! It works like a charm. Thanks~