[RESOLVED][RGSS] Calling actor id...

Started by bigace, December 24, 2012, 11:42:59 pm

Previous topic - Next topic

bigace

December 24, 2012, 11:42:59 pm Last Edit: December 25, 2012, 02:19:51 am by bigace
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.


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

KK20

Mind clarifying what you mean? What are you trying to accomplish?

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

bigace

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.


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

KK20

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

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

bigace

December 25, 2012, 01:47:46 am #4 Last Edit: December 25, 2012, 01:49:08 am by bigace
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


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

KK20

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?

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

bigace

December 25, 2012, 02:05:05 am #6 Last Edit: December 25, 2012, 02:06:25 am by bigace
 :facepalm: Sorry I had a brain fart. Thanks though :P


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

Heretic86

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
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)