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
56
Reaction score
38
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,670
Reaction score
8,489
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,164
Reaction score
1,646
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
262
Reaction score
367
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
8,921
Reaction score
5,847
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

Changed my avatar, goodbye Alan Sugar, hello George Carlin (one of my favorite human beings ever)
If you still don't subscribe our Polish channel please consider it :)
1.png
Who wants to see my review of the worst star wars movie? This movie has all the excitement of being on Jury Duty of the most boring case ever about trade negotiations.
A lot to learn to make a game. Can I handle it?
I've been working on status effects since last thursday, and today I finished the core mechanic of Zombie, Teleport, Curse and Recall. Zombie and Curse are lacking a few things to make them complete atm. Teleport though is the "HAHA" spell for some of my mobs, but can "NOPE" at them with Recall.

Forum statistics

Threads
115,171
Messages
1,087,798
Members
149,719
Latest member
NanYuan
Top