I want to make an event where the player must input the day of the week

So, an NPC asks a character "What day is it today", Name Input Processing comes up and the player enters the day of the week which is saved as the name of the unused actor #8.

At the same time a variable is set to the following " new Date().toString().slice(0,3)+"day" ". This works fine, the variable becomes the string Monday (yes it won't work for any day with more than six letters, but I can do alternates later, I just want to get the basic question working).

So that all works fine. The player can input their answer and the game can store the day on a variable. The problem is, I don't see any way to compare this information. I can't take an Actor's name and store it as a variable, and I can't use a variable in the conditional branch setting for an actor's name, at least, Actor->Name->\V[8] doesn't work, maybe there's some kind of System.Actor[8].name or something that might work instead.

Also, I specifically want the player to write in the day. I know I could just provide a list and have them select the day, but that's not what I want.
You can store an Actor's name in a Variable like this:
Control Variable -> Script:
JavaScript:
$gameActors.actor(8)._name

In Conditional Branch -> Script you can compare the Actor's name to a Variable like this:
JavaScript:
$gameActors.actor(8)._name == $gameVariables.value(8)
This is how you store an actor's name into a variable:
1718013603339.png


The code for actor's name is$gameActors.actor(ID).name()

EDIT: or the one posted above me. Either code is valid.
The problem you might run into here is that the actor's name is going to be case sensitive, I'm pretty sure. "MONDAY" is different from "Monday" that the variable stores. If they typed in "MONDAY" and the day is "Monday" then it might not work. So unless there is a way to change the case with a script as well, this solution may not work for you as well (unless you directly communicated to the player that it is case-sensitive).

While a bit dirty, I came up with this. If you put it in a common event, and least it will prevent your event pages from getting bloated. I believe you won't have any problems doing it this way.

Code:
◆Control Variables:#0001 = new Date().toString().slice(0,3)+"day"
◆Name Input Processing:Day, 8 characters
◆Comment:Check to see if the day is Monday
◆If:Script:$gameVariables.value(1, "Monday")
  ◆Comment:Check to see if the 8th actor's name is "Monday."
  :       :This is case sensitive so it needs to be checked
  :       :three times in case they used all caps or no caps.
  ◆If:Name of Day is Monday
    ◆Comment:This will jump to the label where you'll end up
    :       :if you got the day correct. It needs to be at
    :       :the very last check when done this way!
    ◆Jump to Label:correct
    ◆
  :End
  ◆If:Name of Day is monday
    ◆Jump to Label:correct
    ◆
  :End
  ◆If:Name of Day is MONDAY
    ◆Jump to Label:correct
    ◆
  :End
  ◆
:End
◆Comment:Repeat this day check for Tuesday-Saturday
:       :Below, we'll do Sunday's but a bit different
◆If:Script:$gameVariables.value(1, "Sunday")
  ◆If:Name of Day is Sunday
    ◆Jump to Label:correct
    ◆
  :End
  ◆If:Name of Day is sunday
    ◆Jump to Label:correct
    ◆
  :End
  ◆If:Name of Day is SUNDAY
    ◆Comment:Here is where you'll end up if you put in the correct
    :       :day, with the label command.
    ◆Label:correct
    ◆Text:None, None, Window, Bottom
    :    :Correct! The day of the week is \v[1]!
    ◆
  :Else
    ◆Comment:Here is where you'll end up if the date is not correct.
    :       :This will only happen after everything else has
    :       :been checked!
    ◆Text:None, None, Window, Bottom
    :    :WRONG! Try again!
    ◆Comment:You could optionally put another label here to jump
    :       :to the top of the list, to make the player input
    :       :the name again. Depends on your design.
    ◆
  :End
  ◆
:End

If it's NOT case sensitive though, for some reason, and I've got that wrong, then feel free to use the more simple method above by checking to see if the actor's name is the name of the day 🙂
yes it won't work for any day with more than six letters, but I can do alternates later, I just want to get the basic question working
Alternatively, use (new Date()).getDay() to simply get the current day (as number from 0 to 6), regardless of what its called.
If they typed in "MONDAY" and the day is "Monday" then it might not work.
This can be done a bit easier by using toLowerCase to make sure the case matches.

Here's a full thing you can put into a conditional branch to check if an actor's name is equal to the name of the current weekday, case-insensitive.
JavaScript:
["sunday","monday","tuesday","wednesday","thursday","friday","saturday"][(new Date()).getDay()] === $gameActors.actor(8)._name.toLowerCase()
(Assuming the id of the actor you're using is 8)
The problem you might run into here is that the actor's name is going to be case sensitive, I'm pretty sure. "MONDAY" is different from "Monday" that the variable stores. If they typed in "MONDAY" and the day is "Monday" then it might not work. So unless there is a way to change the case with a script as well, this solution may not work for you as well (unless you directly communicated to the player that it is case-sensitive).

While a bit dirty, I came up with this. If you put it in a common event, and least it will prevent your event pages from getting bloated. I believe you won't have any problems doing it this way.

Code:
◆Control Variables:#0001 = new Date().toString().slice(0,3)+"day"
◆Name Input Processing:Day, 8 characters
◆Comment:Check to see if the day is Monday
◆If:Script:$gameVariables.value(1, "Monday")
  ◆Comment:Check to see if the 8th actor's name is "Monday."
  :       :This is case sensitive so it needs to be checked
  :       :three times in case they used all caps or no caps.
  ◆If:Name of Day is Monday
    ◆Comment:This will jump to the label where you'll end up
    :       :if you got the day correct. It needs to be at
    :       :the very last check when done this way!
    ◆Jump to Label:correct
    ◆
  :End
  ◆If:Name of Day is monday
    ◆Jump to Label:correct
    ◆
  :End
  ◆If:Name of Day is MONDAY
    ◆Jump to Label:correct
    ◆
  :End
  ◆
:End
◆Comment:Repeat this day check for Tuesday-Saturday
:       :Below, we'll do Sunday's but a bit different
◆If:Script:$gameVariables.value(1, "Sunday")
  ◆If:Name of Day is Sunday
    ◆Jump to Label:correct
    ◆
  :End
  ◆If:Name of Day is sunday
    ◆Jump to Label:correct
    ◆
  :End
  ◆If:Name of Day is SUNDAY
    ◆Comment:Here is where you'll end up if you put in the correct
    :       :day, with the label command.
    ◆Label:correct
    ◆Text:None, None, Window, Bottom
    :    :Correct! The day of the week is \v[1]!
    ◆
  :Else
    ◆Comment:Here is where you'll end up if the date is not correct.
    :       :This will only happen after everything else has
    :       :been checked!
    ◆Text:None, None, Window, Bottom
    :    :WRONG! Try again!
    ◆Comment:You could optionally put another label here to jump
    :       :to the top of the list, to make the player input
    :       :the name again. Depends on your design.
    ◆
  :End
  ◆
:End

If it's NOT case sensitive though, for some reason, and I've got that wrong, then feel free to use the more simple method above by checking to see if the actor's name is the name of the day 🙂
No issue if it's case sensitive. I want the player to spell type it correctly.
Alternatively, use (new Date()).getDay() to simply get the current day (as number from 0 to 6), regardless of what its called.

This can be done a bit easier by using toLowerCase to make sure the case matches.

Here's a full thing you can put into a conditional branch to check if an actor's name is equal to the name of the current weekday, case-insensitive.
JavaScript:
["sunday","monday","tuesday","wednesday","thursday","friday","saturday"][(new Date()).getDay()] === $gameActors.actor(8)._name.toLowerCase()
(Assuming the id of the actor you're using is 8)
getDay() will only return an integer, which I can't compare with a string, so it'll still require some if statements, though it'll be easier than trying to edit and append strings on the fly. How can I put a string into a variable though? Can I just type Monday in the script area for a variable or do I need to do something like toString("Monday")?
EDIT: I see you can just put a string in the script section, so long as you have the quotations.
How can I put a string into a variable though?
"Monday" is already a string value. You can just put it directly into the script field of the control variables window
getDay() will only return an integer, which I can't compare with a string, so it'll still require some if statements,
Or you can just use the script line lower down in my post, which turns that integer into a string (and compares it with user's input) 😉
I think the whole date and comparison thing has been figured out, so just as a quick note - the code that @Ethernite gave is better practice than what @BlackGoldSaw had. It's more correct to use getter functions when they're provided, so actor.name() as opposed to actor._name

In the default code those will function the same, but the whole point of getter functions is you might have a plugin somehow modifying the process and you're maintaining compatibility.

Original thread: https://forums.rpgmakerweb.com/threads/i-want-to-make-an-event-where-the-player-must-input-the-day-of-the-week.169402/