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.

Find Name via Scripting [RESOLVED]

Hello,
Is there a way to find an actor's name through scripting and save it into another name? Because the name can be changed through the Name Input Processing command.

Basically, let's say someone plays my game and calls actor 1 Joe. Not only do I want actor 1's name to change to Joe, say I want actor 2's name to change too, like to Joe's Friend. So is there a script call that can do this?

For example, something like:
Code:
$game_actor[2].name = "$game_actor[1].name_to.s" + "'s Friend"

Just wondering if I'm close to the real command :smile: If not, could anyone just tell me how you'd do this?
 
This is what I came up with. It works, but there may be an easier one-liner that does the same thing.
Code:
name = $game_actors[1].name
$game_actors[2].name = name + "'s Friend"
*It doesn't need .to_s because it's already a string.
**Also, I guess due to Call Script's small window, if you use it make sure to delete the line break it makes--you'll see it if you show the name in a message, but not in the menu.
 
Try adding an 's'...  and you don't need the .to_s, since name is already a string (what Tensuke said...) :scruff:

$game_actors[2].name = $game_actors[1].name + "'s Friend"

Game_Actor is used as a reference class to define each of the $game_actors.

[edit] oops, get rid of the quotes around the variable....

Grammatically incorrect when I test it, it yields "Aluxes's Friend". should be "Aluxes' Friend"
 
Also, there's really no need for \, because ' works in ". (Doh!)

Though Brew, I'm curious how that works? I get a nomethod error if using that, which is why I renamed it to just 'name'.
 
Ahh, it actually works! I was just guessing when I typed that code!  :lol:

And don't worry Brew, I changed the name, so there won't be no "Aluxes's Friend" (well maybe if the player decides to name him Aluxes through the Name Input Processing :dead:)

Thanks for your help guys, resolved!
 

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