Twine Version: 2.9.1.0
SugarCube: 2.37.0
I’m in the planning stage for my next project, and I’m wanting to have the ending determined by comparing the relative influence values of the groups that the player interacts with.
Basically, for this:
$Guild1.Inf = 5
$Guild2.Inf = 4
$Guild3.Inf = 3
$Guild4.Inf = 2
$Guild5.Inf = 1
I want it to tell me that Guild 1 has the highest influence.
Now, I did a bit of looking around, and saw that I could return the highest variable:
Math.max($Guild1.Inf, $Guild2.Inf, $Guild3.Inf, $Guild4.Inf, $Guild5.Inf)
But what that does is return “5,” because it’s the highest one. I’m not looking for what the highest variable is, I’m looking for something that will tell me which one has the highest number.
Closest I can think of is this:
<<set $MostInfluence to Math.max($Guild1.Inf, $Guild2.Inf, $Guild3.Inf, $Guild4.Inf, $Guild5.Inf)>>
<<if $MostInfluence eq $Guild1.Inf>>
You have the most influence from $Guild1.Name.
<<elseif $MostInfluence eq $Guild2.Inf>>
You have the most influence from $Guild2.Name.
<<elseif $MostInfluence eq $Guild3.Inf>>
You have the most influence from $Guild3.Name.
<<elseif $MostInfluence eq $Guild4.Inf>>
You have the most influence from $Guild4.Name.
<<else>>
You have the most influence from $Guild5.Name.
<</if>>
The problem with doing that is that it will just default to the first one that matches it, so if I have equal influence, it’s going to tell me that I have the most influence with guild 1.
Now, I could put in
<<if $Guild1.Inf eq $Guild2.Inf and $Guild1.Inf eq $Guild3.Inf and $Guild1.Inf eq $Guild4.Inf and $Guild1.Inf eq $Guild5.Inf>>
You have equal influence among the guilds.
<<else>>
The code above
<</if>>
but if the stats are
$Guild1.Inf = 4
$Guild2.Inf = 4
$Guild3.Inf = 4
$Guild4.Inf = 2
$Guild5.Inf = 1
How would I make it print
You have the most influence with $Guild1.Name, $Guild2.Name and $Guild3.Name.