Okay so I'm writing a romance centered interactive novel and I've got seven love interests. Throughout book 1, I want the player to be able to accumulate 'flirt points' for each character. Whoever has the most flirt points, I want to have them in book 2 be the main romance.
Meaning, that I want to be able to check the variable/attributes for their flirt levels against each other. I already know how to set them like this:
@set Flirt_Lav = 0
And then if I add an @inc to each choice you make to flirt with this character, her flirt score will go up. So I have all that figured out.
But how then do I compare all the values of all the flirt Attributes/Variables to see which is highest? And then how do I set up a thing where you can ask-- if two are equal-- 'which one of these romances would you like to lock in?' to the player?
I apologize if this has been asked before, please feel free to point me anywhere helpful, I'm so new to this site. I've been here a while and tried to publish my twine games but not anything in Squiffy or Quest.
I had to stop using Twine, cause it crashed and I lost a whole half of my work-- plus no one at the forums really gave me simple answers and I never understood what I was doing.
I don't know Squiffy at all. But I can tell you the algorithm I'd use; in a kind of pseudo-code.
highest_score = 0
characters_with_highest_score = new list (or array, or whatever the list data type is called)
for each character {
if (this character's score > highest_score) {
highest_score = this character's score
characters_with_highest_score = new list
}
if (this character's score == highest_score) {
add this character to the characters_with_highest_score list
}
}
if (characters_with_highest_score has exactly one character in the list) {
main_romance = characters_with_highest_score[0]
}
else {
Allow the player to choose from characters_with_highest_score
}
Whether the "for each" loop there is an actual loop, or if it's just repeating the same code for a bunch of different variables, is up to you. If you've put them in some kind of data structure, a real loop is easier. If they're separate variables, it might be easier to copy-paste the loop body once for each option.
Or this. I'm only showing it with three but you can expand it...
[[init]]:
@set flirt_frank=4
@set flirt_mel=3
@set flirt_john=4
{@top=@flirt_frank}
{if flirt_mel>@top:{@top=@flirt_mel}}
{if flirt_john>@top:{@top=@flirt_john}}
[[ready to go?]](rank)
[[rank]]:
You search your heart and realize you have few true choices:
{if top=@flirt_frank:[[Frank's my man!]](pick frank)}
{if top=@flirt_mel:[[Mel's my man!]](pick mel)}
{if top=@flirt_john:[[John's my man!]](pick john)}
[[pick frank]]:
You have chosen Frank!
[[pick mel]]:
You have chosen Mel!
[[pick john]]:
You have chosen John!
Bluevoss's seems like the closest to what I'm wanting to achieve, but a bit of explanation would be helpful. As I see this [[Init]] at the top and I wasn't even aware that was necessary? I thought you just had to put everything before the beginning of the code for the story itself. Do I have to put everything in an Init passage?
Also, I don't see any code in this second one for two equal values to be compared. You've just a choice for all of them and if I were going to do that, I'd just have them choose at the start of the game.
I need something to check if they have the exact same number of flirt points and if they do, ask the player which one they want. Otherwise, the highest number would just be automatically chosen.
Breaking this down, the [init] section represents your story. You won't set these values here - this is your adventure where you are @incing each of your characters to try to see who you can score the most of. I've just set these lines to represent your game.
@set flirt_frank=4
@set flirt_mel=3
@set flirt_john=4
And this section (at the end of your story) determines the "top" score in flirting. It walks through your lads and determines who has the highest score. It dosn't determine 'who' it actually is, just the highest score.
{@top=@flirt_frank}
{if flirt_mel>@top:{@top=@flirt_mel}}
{if flirt_john>@top:{@top=@flirt_john}}
After this, I hop to another section (though I guess you really don't need to). Here we print ALL the characters who have that top score. In my example, I set the data so both Frank and John have fours and tie for your affections. So this will print a select-able line for each match against "top".
{if top=@flirt_frank:[[Frank's my man!]](pick frank)}
{if top=@flirt_mel:[[Mel's my man!]](pick mel)}
{if top=@flirt_john:[[John's my man!]](pick john)}
IF only one guy has the high score, then only one selection will be available. Here, both Frank and John scored equally high so the player will get to chose either one to continue. Depending on which one is picked, you go to the matching [pick *] section where you can describe what happens.
The sections I showed above can be expanded out to represent the seven you are writing about. You'll just need a separate line per fellow.
Let me know if you have questions. I'd have used javascript for a lot of this but you seemed to want a squiffy-only solution, so that's what I went for. Hope this helps!
Okay thank you so much. All I'd get on the twine forums was a lot of technical jargon and no real explanations. You're the best advice-giver I've met on the internet who wasn't a friend trying to help me through PM's on other sites or through discord.
And yes, I absolutely only wanted the Squiffy-only way, because I am not even at the base level of coding knowledge. Thanks so much for the explanation!
Thanks much! If you have any questions about how to get things to work, squiffy-only or crazy-code, post this forum and I'll be glad to help. I'm happier with squiffy-only and have been playing with it for a year or so, so maybe I can give you a hand.
Trust me - it can get pretty crazy to get some ideas into squiffy.