Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Change Actor name based on variable (in script)

I'm having a little trouble getting this to work, and I'm sure I'm just not calling this right.

Basically, I want a variable to determine what to name my actors.

I have both versions of the names stored in arrays from constants set at the start of the script (in order of the ids they appear in the database from 0-11)

NAMES1 = ["Name1", "Name2", "Name3", "Name4", "Name5"]
NEWNAMES = ["NewName1", "NewName2", "NewName3", "NewName4", "NewName5"]

It's set up just like that for the arrays.

What I need is a call in the script (and where exactly I should place this call) that will read a variable, and based on whether it's 0 (original names) or 1 (new names), or a switch can be used with ON and OFF, change the actor's names to what is set in the array and vice versa.

I know this is easily achieved with events, but for me, this has to be done within a script (it's part of an options menu).
 
I think this should do it. Test it out.

Code:
class Game_Actor

  

  NAMES1 = ["Name1", "Name2", "Name3", "Name4", "Name5",

            "Name6", "Name7", "Name8"]

  NEWNAMES = ["NewName1", "NewName2", "NewName3", "NewName4", "NewName5",

              "NewName6", "NewName7", "NewName8"]

  

  def name

    if $game_variables[1] == 1

      return NEWNAMES[@actor_id - 1]

    else

      return NAMES1[@actor_id - 1]

    end

  end

end
 
For some reason my reply didn't go through. Anyway, the code here didn't help, but after a while I figured it out with a friend of mine. Thank you Brewmeister, though, for always trying to lend a hand. Appreciate it very much.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top