0 votes
by (130 points)

I'm really new to this (started last night on impulse and a dare), and am wanting to create a dating sim sort of game. I'm past the prologue point, but after that point I want the player's next readable option to have one link, but that link lead to different passages based on which character the player has appealed to most. 

    (set: $Player to 
    (dm:
            "Raoul", 10,
            "Svi", 10,
            "Stellar", 10,
            "Argon", 10,
            "Jiya", 10,
            "Thalli", 10,
            "Stron", 10,
            "Arcene", 10,
            "Sal", 10,
    )
)

The stats all start with 10 that way I won't have to deal with negative numbers. 

(is it obvious i have no idea what i'm doing?) 

1 Answer

+1 vote
by (159k points)

In your Question Tags you have stated that you are using Harlowe however you haven't stated which version of that story format you are using, and answers can vary on this information. I will assume you are using Harlowe v2.1.0 which is the current default of the Twine v2.2.1 application.

You can achieve the result you want by looping the names of each of the character that the Player can have a relationship with and comparing which one has the highest score, and in the case where multiple characters have the highest score the first character will be selected.

You can use the (datanames:) macro to obtain an Array containing the names of each of the characters, the (for:) macro to loop each of them, and the (if:) macro to compare the score of the current character to that of the highest one.

A story variable named $appealedTo is used to store the name of character with highest score. It starts out with the name of the first character that is checked (because obviously they will initially have the highest score so far), and changed each time a character is found with a higher score.

{
(set: $Player to 
    (dm:
            "Raoul", 10,
            "Svi", 10,
            "Stellar", 10,
            "Argon", 10,
            "Jiya", 10,
            "Thalli", 10,
            "Stron", 10,
            "Arcene", 10,
            "Sal", 10,
    )
)

(set: $appealedTo to "")
(for: each _name, ...(datanames: $Player))[
	(if: $appealedTo is "")[
		(set: $appealedTo to _name)
	]
	(else-if: $Player's (_name) > $Player's ($appealedTo))[
		(set: $appealedTo to _name)
	]
]
}

$appealedTo found the Player the most appealing.

note:you can rename the $appealedTo story variable to whatever makes sense in your project, as long as you change all occurrences of that name in the above code.

by (130 points)

This is... kinda my first time coding/programming/whatever it's called, so I still have a few questions if that's alright! 

Do you put anything in the doubled quotation marks? If so, what do I put?

Also, am I supposed to change the _name to the names of the characters? 

Also, before inputting this command, does it automatically tally itself up? or do I need more code to tally up the appealedto characters? For example, let's say this is the player's runthrough in the prologue. 

    (set: $Player to 
    (dm:
            "Raoul", 10,
            "Svi", 10,
            "Stellar", 11,
            "Argon", 10,
            "Jiya", 9,
            "Thalli", 10,
            "Stron", 10,
            "Arcene", 10,
            "Sal", 12,
    )
)

In which Sal is the most appealed to character, so his scene would pop up first. Does the game automatically know that Sal is the most appealedto character? All I did for each choice (at least, those that affected gameplay) is like this: 

(set: $Player to 
    ("Sal + 2",
    "Stellar + 1"
    )

Thanks so much for your help so far! 

by (159k points)

...am I supposed to change the _name to the names of the characters?

 No.
The _name temporary variable will automatically be assigned the name of the character being checked as the (for:) macro loops through each of character names contained within the list returned by the (datanames:) macro.

Do you put anything in the doubled quotation marks?

No.
Two quotation marks without any text between them are known as an Empty String, and in this case I am using that value to allow the (for:) macro to determine the name of the first character being checked.

does it automatically tally itself up?

No.
You will need to use TwineScript like the following to increase or decrease the current stat value of specific character within your $Player data-map.

(set: $Player's "Sal" to it + 2)
(set: $Player's "Stellar" to it + 1)
(set: $Player's "Argon" to it - 3)


You can use a (if:) macro like the following to check if Sal is the most appealed to character and  to show the related scene if they were.

(if: $appealedTo is "Sal")[
	Show the scene for Sal.
]

note: The (for:) macro related TwineScript needs to be executed some time before the above (if:) macro, or else the $appealedTo variable won't contain a name.

by (130 points)
This has been really useful so far! So final question (I hope, heh), is how do I get the next chain of text to be the Appealedto's?

So, once again let's fall back on Sal having the most appealedto. I want the player to be able to click "CONTINUE" on the end of the prologue and be taken to the most appealedto's scene, in this case Sal's. Do I connect them as normal with [[this]] and some code (if so, what is the code?) and if not, what do I do?
by (159k points)

I suggest you read the Harlowe manual (that I keep supplying you links to) because it contains the answers to your more recent questions.

 I want the player to be able to click "CONTINUE" on the end of the prologue and be taken to the most appealedto's scene...

You don't state the names of the Passages which will contain the scenes of each of the characters, so I will assume that those passages have names that are the same as the character names.

You can use the (link-goto:) macro to create your link, and use the value stored within the $appealedTo variable as the Destination Passage Name parameter.

(link-goto: "CONTINUE", $appealedTo)

.

...