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
62
Reaction score
42
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,944
Reaction score
8,614
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
376
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,024
Reaction score
5,906
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 Profile Posts

FL Studio is a huge step up from LMMS but I'm having such a tough time with it D:<
The new Dune movie reminds me of the game Dune 2 made by Westwood. A quality product on its own, but extremely disloyal to its source of inspiration.
Terrible Writing Advice, you've done it again.
1635026211997.png
Feeling like my new profile picture is nice. Thinking of making it semi-permanent, does any one has an opinion? Does it look too evil or does it work as a public profile picture? :)
Bishiba.png

Forum statistics

Threads
116,032
Messages
1,095,119
Members
151,366
Latest member
1AmAlex
Top