I use 2 IF's for 1 Prompt. and no matter what I answer whether it matches or not it still goes to the Else option of the first IF.
I've tried to change their order and also merge them by placing the first IF inside the empty Else of the second IF.
https://ibb.co/sQXRhYb
[Help] 2 IF 1 Prompt can't figure why it goes to Else option
Re: [Help] 2 IF 1 Prompt can't figure why it goes to Else option
I would put money on the problem being in the if condition but for a non-coder like me, I can't really help find the issue.
That being said, I highly suggest instead of prompting the player to type something in to instead have choice boxes. It may be personal taste for me but I really don't like typing in teases when so many are case sensitive, or a minor misspelling messes you up. At best it makes you stop whatever you were doing and use both hands which ruins the pace for me and in my opinion doesn't "present" as well.
Yay for having a virginity variable, looks promising.
That being said, I highly suggest instead of prompting the player to type something in to instead have choice boxes. It may be personal taste for me but I really don't like typing in teases when so many are case sensitive, or a minor misspelling messes you up. At best it makes you stop whatever you were doing and use both hands which ruins the pace for me and in my opinion doesn't "present" as well.
Yay for having a virginity variable, looks promising.
-
- Explorer At Heart
- Posts: 265
- Joined: Thu Jan 03, 2013 4:55 pm
- Gender: Male
- Sexual Orientation: Straight
- I am a: Submissive
Re: [Help] 2 IF 1 Prompt can't figure why it goes to Else option
Not an expert in JS, but isn't string comparison done with === ?Epton wrote: ↑Sat Mar 05, 2022 5:49 pm I use 2 IF's for 1 Prompt. and no matter what I answer whether it matches or not it still goes to the Else option of the first IF.
I've tried to change their order and also merge them by placing the first IF inside the empty Else of the second IF.
https://ibb.co/sQXRhYb
Also, I maybe wrong, but I think the condition is wrong. Use an eval action with a console log to verify the returned value
- kinkyswan
- Explorer
- Posts: 46
- Joined: Sun Feb 08, 2009 2:08 am
- Gender: Male
- Sexual Orientation: Straight
- I am a: Submissive
Re: [Help] 2 IF 1 Prompt can't figure why it goes to Else option
I think the problem is the slashes. So instead of:
Code: Select all
Answer == Answer.trim().match(/"no|no it does not|no it doesn't"/)
Code: Select all
Answer == Answer.trim().match("no|no it does not|no it doesn't")
Code: Select all
Answer == Answer.trim().match(/no|no it does not|no it doesn't/)
- kinkyswan
- Explorer
- Posts: 46
- Joined: Sun Feb 08, 2009 2:08 am
- Gender: Male
- Sexual Orientation: Straight
- I am a: Submissive
Re: [Help] 2 IF 1 Prompt can't figure why it goes to Else option
The == is correct in this case because the return type of the match method is an array, while Answer is a string.
Assuming the user had typed in "no" in response to the prompt, the match method would return ["no"]. === only evaluates to true if the types on both sides are same, while == converts the expressions so they are the same type. So:
Code: Select all
"no" == ["no"] // true because ["no"] is first converted to "no"
"no" === ["no"] // false
Who is online
Users browsing this forum: No registered users and 50 guests