Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Hey! So I have three personality points that I'm keeping track of which affect automated MC responses. However, the code I made for it is a little unwieldy. The problem comes when I'm specifying the heirarchy in case they have equal points. I want it to be genuine > sarcastic > aggressive; or in other words, if genuine = sarcastic or genuine = aggressive, then genuine is dominant, and if sarcastic = aggressive, sarcastic is dominant. So whenever I have moments where I specify the type of response, I have to type out this whole thing:
if genuine > sarcastic and genuine > aggressive or genuine > sarcastic and genuine == aggressive or genuine == sarcastic and genuine > aggressive or genuine == sarcastic and genuine == aggressive:
rowan "Dialogue"
jump ch1_s2_menu3_main
elif sarcastic > genuine and sarcastic > aggressive or sarcastic > genuine and sarcastic == aggressive:
rowan "Dialogue"
jump ch1_s2_menu3_main
elif aggressive > genuine and aggressive > sarcastic:
rowan "Dialogue"
jump ch1_s2_menu3_main
As you can see, it's quite... long. I'm just wondering if there's a way I can set up the weight so I don't have to write that super long statement for the genuine personality every time?
Thank you! I've adapted my code to do the points this way. And just a quick verification, how do i establish the hierarchy in case there are ties in points? i'm guessing that's done in the default spot?
This code creates a list of tuples (trait_value, tiebreaker, trait_name) and sorts it ascending (largest last). Then it takes last (largest) element (trait[-1]) and extracts name from it (trait[-1][2]).
Tuples are compared by comparing its elements in order. If first element (trait value in my code) of one tuple is larger or smaller that the other, the whole tuple is considered larger or smaller. When those elements are equal (tie in points), Python goes to compare second element in tuples. In my code this element is a tiebreaker. 'Geniune' trait has a tiebreaker value of 3 — larger than any other. If 'Geniune' trait value ties with other trait, it will come on top, because its tiebreaker value will compare higher than one he tied with.
So every time you need to choose the response automatically, you call that function with those 3 responses for this situation, and it returns the proper one: