Getting an actor id or database name in a script in XP

I'm using this plugin for my game and because of the actor faces part using the actor's current name to find a graphic, it doesn't work with an actor whose name was changed in the game unless I make versions of the image for every possible name that can be inputted. Is there some way to change the actor.name part so that it uses the actor's id or their name in the database instead?
Code:
class Window_Base < Window
  def face
    face = RPG::Cache.picture("")
  end 
 
  def draw_face(actor,x,y)
    face = RPG::Cache.picture(actor.name + "_face") rescue face
    fw = face.width
    fh = face.height
    src_rect = Rect.new(0, 0, fw, fh)
    self.contents.blt(x , y - fh, face, src_rect)   
  end
end
Yea, just replace "actor.name" with whatever alternative you want. You could use their database ID with "actor_id" or you could their character graphic filename (character_name) or their battler graphic filename (battler_name)/

Ruby:
actor.actor_id
actor.character_name
actor.battler_name
When I try to use the character or battler name version it gives this error message at the start of a battle: Script CBS line 43: NoMethodError occurred. undefined method 'width' for nil:NilClass
That error doesn't happen with the original version of the code but then it still doesn't work for renamed actors. I haven't tried the actor id one.
When I try to use the character or battler name version it gives this error message at the start of a battle: Script CBS line 43: NoMethodError occurred. undefined method 'width' for nil:NilClass
That error doesn't happen with the original version of the code but then it still doesn't work for renamed actors. I haven't tried the actor id one.
Did you update your filenames to match? Are the files placed in the "pictures" folder?
Well, normally you access the actor's ID by calling actor.id or $game_actors[ActorID].id or the like.
@actor_id is normally not accessible from other scripts unless you manually add:

attr_reader :actor_id

To the Game_Actor class.

EDIT 1

Ruby:
class Window_Base < Window
  def face
    face = RPG::Cache.picture("")
  end
 
  def draw_face(actor,x,y)
    face = RPG::Cache.picture(actor.name + "_face") rescue face
    fw = face.width
    fh = face.height
    src_rect = Rect.new(0, 0, fw, fh)
    self.contents.blt(x , y - fh, face, src_rect)
  end
end

There the face variable is useless inside the face method.
Remove the face = part, you only need it in the draw_face method.

AND replace the face variable AFTER rescue because it's pure nonsense. It's like calling nil which is never supposed to have a method called width or height. There you can type something like:

Bitmap.new(100, 100)

EDIT 2

Mobius XVI said:
Did you update your filenames to match? Are the files placed in the "pictures" folder?

Nah, it's just what I mentioned above.
Those changes worked. Would I be able to ask about another unrelated issue I'm having with that plugin here or would I have to make a new thread for it?
I guess a new thread would be the best option here mainly because this issue has been solved.
Report it to close it.
How do I do that? I don't see any options to.
Hi there @shadow56bomb if you need to report a thread to be closed, there is a little symbol with “report” at the bottom of each post. It will open a word prompt and you can let us know what needs checked out.

So, in the case of a solved thread, you could write something like “solved, can be closed.”

1741354999849.png


EDIT: This thread is closed due to being reported as solved. If you need it reopened, report it to let us know. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/getting-an-actor-id-or-database-name-in-a-script-in-xp.175979/