Main Menu
  • Welcome to The RPG Maker Resource Kit.

some scripting help

Started by Mitsarugi, November 20, 2011, 10:36:33 PM

0 Members and 1 Guest are viewing this topic.

Mitsarugi

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?

LoganF

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.
(Why do I always feel like it's the end of the world and I'm the last man standing?)

Mr_Wiggles

Use "HUD_" + @actor.id.to_s You need to convert the integer into a string to add it to a string class.
[spoiler]
METALFRESH is a paint contractor that specializes in refinishing metal and vinyl siding. We paint metal buildings as well as siding on homes.

We also

    Refinish decks
    Do custom interior painting
    Strip wallpaper
    Refinish cedar siding
    Metal front doors and sidelights
    Metal garage and service doors
    Grained fiberglass doors

    If your structure is *RUSTED *FADED *CHALKING *IN NEED OF COLOR CHANGE, we can fix it with a guarentee!

northern Illinois and southern Wisconsin.

http://metalfreshcoatings.com

[/spoiler]

LoganF

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.
(Why do I always feel like it's the end of the world and I'm the last man standing?)

Mitsarugi

#4
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>"

Mr_Wiggles

Do you have the variable "@actor" defined or are you using just "actor"?
[spoiler]
METALFRESH is a paint contractor that specializes in refinishing metal and vinyl siding. We paint metal buildings as well as siding on homes.

We also

    Refinish decks
    Do custom interior painting
    Strip wallpaper
    Refinish cedar siding
    Metal front doors and sidelights
    Metal garage and service doors
    Grained fiberglass doors

    If your structure is *RUSTED *FADED *CHALKING *IN NEED OF COLOR CHANGE, we can fix it with a guarentee!

northern Illinois and southern Wisconsin.

http://metalfreshcoatings.com

[/spoiler]