IF this AND that
KFL
23 Apr 2020, 01:50I am suuuuuuper new to coding and have been working with the desktop interface rather than diving into the code itself. How do I make it so that the character needs to answer multiple questions (3) correctly in order for something to happen? I have a switch script set up to ask the three questions and get the responses, but I'm not sure what the next piece is. Is there an "IF this is true AND that is true THEN this happens" function? Is there a way to make something happen after 3 flags get put on an object? I don't know what I'm doing. Thanks!

Pykrete
23 Apr 2020, 02:57Hmm, you could do it with a variable.
player.correct answers = 0
On the first question, if the answer is correct, then...
player.correct answers = player.correct answers + 1
This makes it '1'. If the answer is incorrect, don't increase the variable. On the next two questions, repeat the process - if they got two right, the final result would be '2'. If they got all 3 right, then '3'. Then, make your final if check..
if (player.correct answers = 3) {
SUCCESS CODE
}
else {
FAIL CODE
}
Alternately...
if (player.question 1) and (player.question 2) and (player.question 3) {
SUCCESS CODE
}
- MIGHT work! Not sure.
XanMag
23 Apr 2020, 03:57Okay, so I did pretty much the same thing in Dragon's Den.
Here is what I would do:
- Add an integer attribute to an object. Set it to 0.
- Use a get input, switch, add case script to check for a right answer.
- If the right answer is presented by the player, add a +1 to the integer attribute.
- Pose question two. If right, add another +1 to the attribute. If wrong (else), set to zero and start over.
- Once the player gets to +3, run a script to acknowledge the success of the player.
FYI... long campfire session tonight and lots of imbibing, so... if you need clarification, I will be GLAD to give it in about 16 hours! Let me know.
KFL
24 Apr 2020, 03:24Thank you so much! That worked like a charm.