Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: bigace on December 24, 2012, 11:42:59 pm

Title: [RESOLVED][RGSS] Calling actor id...
Post by: bigace on December 24, 2012, 11:42:59 pm
How do you call actor.id in Window_MenuStatus, the game crashes when I try to call it like name and class_id. I just notice that it's not a variable like the latters so won't work the same as them.
Title: Re: [RGSS] Calling actor id...
Post by: KK20 on December 25, 2012, 12:25:13 am
Mind clarifying what you mean? What are you trying to accomplish?
Title: Re: [RGSS] Calling actor id...
Post by: bigace on December 25, 2012, 12:53:38 am
You know how you can call the actors name and class in Window_MenuStatus or any other menu, well how do you call the actors id. I was trying to call it when using it to call the actors face image from the folder because, if someone was to rename their actor they would get an error due to the fact you changed the actors name. So I was just going to change it to id instead but I got an error.
Title: Re: [RGSS] Calling actor id...
Post by: KK20 on December 25, 2012, 01:03:59 am
It should be .id. Maybe the object you were calling on wasn't even an actor? In other words

actor = SomethingWeird.new
.
.
.
print actor.id # Error
Title: Re: [RGSS] Calling actor id...
Post by: bigace on December 25, 2012, 01:47:46 am
That wouldn't make any sense as I can call an image using actor.name.

For an example as you get the same error both ways, go to Window_Base and change actor.name to actor.id
  def draw_actor_name(actor, x, y)
   self.contents.font.color = normal_color
   self.contents.draw_text(x, y, 120, 32, actor.name)
 end

to
  def draw_actor_name(actor, x, y)
   self.contents.font.color = normal_color
   self.contents.draw_text(x, y, 120, 32, actor.id)
 end


The error I get when I change actor.name to actor.id from either draw_actor_name or from my draw_face method.
QuoteScript 'Window_Base' line 123: TypeError occurred.
cannot convert Fixnum into String
Title: Re: [RGSS] Calling actor id...
Post by: KK20 on December 25, 2012, 01:55:50 am
General rule of thumb. When trying to draw numbers as text/in a string format...use .to_s

def draw_actor_name(actor, x, y)
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, 120, 32, actor.id.to_s)
  end

You do understand what that error message means, right?
Title: Re: [RGSS] Calling actor id...
Post by: bigace on December 25, 2012, 02:05:05 am
 :facepalm: Sorry I had a brain fart. Thanks though :P
Title: Re: [RESOLVED][RGSS] Calling actor id...
Post by: Heretic86 on December 26, 2012, 04:09:32 am
Sounds like a good place to use the $global reference...


x = 123
y = 123
for actor in $game_party.actors
  self.contents.font.color = normal_color
  # Don't forget Font Size!
  self.contents.draw_text(x, y, 120, 32, actor.id.to_s)
  # Increase Y value for next actor to position text correctly
  y += 160
end