i have a script that shows the player's face in battle and in the script it uses the player's name to find the picture for the battle scene, like this ("HUD_" + actor.name) i would like it to use just the player's ID instead so the player can change names something like this ("HUD_" + actor.id) but that doesn't seem to work any idea what the code for player ID is?
If you have issues accessing a variable that you expect is likely a variable (for example an id number due to it often being a unique value separating one object of the same type to another), it's probably because that variable is not publicly accessible. Looking at the code, this is the case here.
You need to make @actor_id publicly accessible. A quick addition to the scripts:
class Game_Actor
attr_reader :actor_id
end
will do the trick. Accessing it can be done via actor.actor_id
If you wanted to change it to be simply actor.id, you can add this code instead:
class Game_Actor
def id
return @actor_id
end
end
These IDs are the same IDs as in the database. So actor 1, by default, is Ralph, actor 2 is Ulrika etc.
Use "HUD_" + @actor.id.to_s You need to convert the integer into a string to add it to a string class.
Quote from: Mr_Wiggles on November 21, 2011, 10:03:16 PM
Use "HUD_" + @actor.id.to_s You need to convert the integer into a string to add it to a string class.
That's needed too. Completely overlooked the 'used in a string' part. I was a little tired and preoccupied when I was writing that.
thanks guys ^^
EDIT: can't seem to get it work T-T
is it like this?
Cache.system("HUD_" + @actor.id.to_s)
this is how it normaly looks like.
Cache.system("HUD_" + actor.name)
what it does is look for a picture to display which is a picture in the System folder ,with the name "HUD_<player_name>"
i want it to do, is look for a picture to display which is a picture in the System folder ,with the name "HUD_<player_ID>"
Do you have the variable "@actor" defined or are you using just "actor"?