Adding letters???

Status
Not open for further replies.

Stupidbro

Veteran
Veteran
Joined
Jul 8, 2019
Messages
87
Reaction score
8
First Language
English
Primarily Uses
RMVXA
Sorry about the ambiguous title, but here's the issue:
I want to give the player a nickname based on the first letters of the name they input, so if they type "Emmet" they'd get the nickname "Em" or if they typed "Gunther" they'd get "Gu".
What I've got is
Code:
$game_actors[1].nickname = $game_actors[1].name[0] + $game_actors[1].name[1]
And I've seen things online to indicate that that should work, provided that it is a string (I'm not certain of that but I thought it'd probably be). However, it gives a NoMethodError message because "undefined method '+' for nil:NilClass". Ideas?

Edit: fixed a typo
 
Last edited:

Xane

Veteran
Veteran
Joined
Jun 5, 2020
Messages
72
Reaction score
374
First Language
(US) English
Primarily Uses
RMVXA
If that's the way you typed it, you have a typo error. There's a space between . and nickname when there shouldn't be.
 

Stupidbro

Veteran
Veteran
Joined
Jul 8, 2019
Messages
87
Reaction score
8
First Language
English
Primarily Uses
RMVXA
Sorry about the ambiguous title, but here's the issue:
I want to give the player a nickname based on the first letters of the name they input, so if they type "Emmet" they'd get the nickname "Em" or if they typed "Gunther" they'd get "Gu".
What I've got is
Code:
$game_actors[1]. nickname = $game_actors[1].name[0] + $game_actors[1].name[1]
And I've seen things online to indicate that that should work, provided that it is a string (I'm not certain of that but I thought it'd probably be). However, it gives a NoMethodError message because "undefined method '+' for nil:NilClass". Ideas?
If that's the way you typed it, you have a typo error. There's a space between . and nickname when there shouldn't be.
That's a transcription error, my bad. Correcting it.
 

Xane

Veteran
Veteran
Joined
Jun 5, 2020
Messages
72
Reaction score
374
First Language
(US) English
Primarily Uses
RMVXA
On the matter regarding this if it hasn't fixed the issue. I did go ahead and inject that in a script call and it works just fine via events.
 

Stupidbro

Veteran
Veteran
Joined
Jul 8, 2019
Messages
87
Reaction score
8
First Language
English
Primarily Uses
RMVXA
On the matter regarding this if it hasn't fixed the issue. I did go ahead and inject that in a script call and it works just fine via events.
That's really weird. I've modified very little of the script and what I have modified (save file stuff) shouldn't be affecting it.

It's possible that I accidentally corrected whatever the issue is in transcription, but I doubt it. I'll look it over again and get back to you.

Edit: SO APPARENTLY THAT WASN'T AS IMPOSSIBLE AS I THOUGHT! I changed the actor id in the example for simplicity's sake, but my original script called the wrong actor's id for the second part, and the actor's name I was calling was empty so there wasn't a first and second character to add.

Tldr: The sample is correct and I need to reread my scripts very meticulously because sometimes I'm an idiot.
 
Last edited:

Xane

Veteran
Veteran
Joined
Jun 5, 2020
Messages
72
Reaction score
374
First Language
(US) English
Primarily Uses
RMVXA
Glad you were able to solve it! A good indicator is to double check if the actor id exists in your database it will always throw an error if that actor isn't created. And that anytime you call from $game_actor you use the corresponding database id but any calls from $game_party.members always starts from 0.
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,813
Reaction score
5,212
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Yet another gaming question, i'm currently playing Last of Us 2 and want to get another game to play next but can't decide between Ghost of Tsushima, Miles Morales & Jedi Fallen Order. After the latest mandalorian i AM on a star wars kick, but i also LOVED the last spiderman game that prequels Miles Morales. Ghost of Tsushima is the bottom of my list but i heard it was AWESOME. Just want a good story & fun gameplay.
I checked out Genshin Impact gameplay out of curiosity. I can't believe it's available as a mobile game too. Smooth animation, great music, and stellar sound effects (the ambient sounds are pretty detailed).

I'm flabbergasted to see games have becoming more and more advanced. Maybe also because I'm oblivious to current trend for a long time, it almost feel like I'm being sent into distant future. xD
xDRAGOONx wrote on WaywardMartian's profile.
Your artwork is amazing!!!
:ewat:
Stream will be live shortly with a session of the Interactive Text Adventure! Feel free to drop by!
I should finish the cat video I'm editing and finish the indesign stuff. So far only 1 is done and 4 to go

Forum statistics

Threads
105,665
Messages
1,015,384
Members
137,341
Latest member
jasapembuatanwebsite
Top