Status
Not open for further replies.

applechoirs

Warper
Member
Joined
Sep 11, 2015
Messages
3
Reaction score
2
First Language
Indonesian
Primarily Uses
RMMV
First is an apology if I'm not clear with my problem because English isn't my mother tongue.

So what am I trying to do here is to let players name their own character, but some names aren't allowed because they overlap with NPCs. Then, I want the name input prompt to be looped if players keep entering the same name/other names that aren't allowed.

So I did this:
loops.png
However, no matter what kind of name I input, I kept getting stuck in the loop. I searched and found that I should be putting the things that will break the loop in the If, not Else. If I want to follow that, that means the $gameActors script must be set to detect that the names inputted aren't forbidden names, and I don't know how to do it. In the first place, I'm not sure whether I did the $gameActors part right on the screenshot.

Any help with my problem? Thanks in advance.
 

autodidact

Veteran
Veteran
Joined
Nov 13, 2020
Messages
64
Reaction score
45
First Language
English
Primarily Uses
RMMV
Edit: Sorry, hasty reading. Ignore my post. See those posting below.

Well, it looks like your "if" check isn't actually checking the name that the player inputs.
Instead, it is checking the same $gameActors.actor(1).name every single time.

Try making it check for the variable that you are storing the name that the player inputs.
From your code, it looks like it should be $gameVariables.value(1)
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,967
Reaction score
8,616
First Language
German
Primarily Uses
RMMV
actually that part is correct @autodidact if you read what he wants to do.
The problem is because a comparison is always between two items, not one item and a list of items.

@applechoirs you'll have to rework the entire line, either checking for each name one after another or to check if the result is contained in the elements of an array (which is a different code, but I don't have that ready at the moment)
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
2,226
Reaction score
1,725
First Language
Portuguese - Br
Primarily Uses
RMMZ
Hi there!
Your script to check the value will not work like that, using a comma between each name. You have either do that:
JavaScript:
$gameActors.actor(1).name().toLowerCase() === "alex" || $gameActors.actor(1).name().toLowerCase() === "bob" || $gameActors.actor(1).name().toLowerCase() === "cherry" etc...

The "||" Operator means:
The actor name 1 is equal to alex OR Bob OR cherry...

If I was you, I will just create an array with every actor name on it and put that array into a variable(Before the loop). Put that script command on a script call:

JavaScript:
let usedNames = $gameParty.members().map(member => member.name().toLowerCase())
$gameVariables.setValue(ID, usedNames)

Then put this script on the conditional branch:

$gameVariables.value(ID).includes($gameActors.actor(1).name().toLowerCase())

"Includes" Is an array method to check if already exist an element in the array. In this case, we are checking if the actor name is on the array. If yes, this means that one party member already has this name.

Javascript Array
Javascript OR ||
 

Nolonar

Veteran
Veteran
Joined
Feb 18, 2018
Messages
274
Reaction score
377
First Language
French, German
Primarily Uses
RMMZ
Then put this script on the conditional branch:

$gameVariables.value(ID).includes($gameActors.actor(1).name().toLowerCase())

"Includes" Is an array method to check if already exist an element in the array. In this case, we are checking if the actor name is on the array. If yes, this means that one party member already has this name.

Just in case you (@applechoirs) don't want to compare the name with existing actor names (you did mention you wanted to avoid overlap with NPC names):

JavaScript:
["alex", "bob", "cherry"].includes($gameActors.actor(1).name().toLowerCase())
 
Last edited:

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
9,038
Reaction score
5,908
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.

Latest Threads

Latest Posts

Latest Profile Posts

So got my hearing tested to see if it was the cause of my mishearing what people say. Test showed no problems but talked with the doctor about anxiety and ADHD causing hearing issues and she agreed and also added that some people hear things differently. With my anxiety cause I am in fight or flight I pay attention to all the sounds in the area so body knows when react. Can't pay attention to one source.
Welp, people are trying to quit my team because I can't code. Where's the dancing blob emoji when I need it?

Forum statistics

Threads
116,053
Messages
1,095,319
Members
151,402
Latest member
Taigris
Top