0 votes
by (2.7k points)
edited by

How to get a contains() function in sugarcube 2 like the sugarcube 1 version? Here is my code:

<<dropdown "$Choice0" "none" "Firebird" "Freeze" "Isida" "Hammer" "Twins" "Ricochet" "Smoky" "Thunder" "Vulcan" "Striker" "Shaft" "Railgun" "Magnum">><<dropdown "$Choice1" "none" "Firebird" "Freeze" "Isida" "Hammer" "Twins" "Ricochet" "Smoky" "Thunder" "Vulcan" "Striker" "Shaft" "Railgun" "Magnum">><<dropdown "$Choice2" "none" "Firebird" "Freeze" "Isida" "Hammer" "Twins" "Ricochet" "Smoky" "Thunder" "Vulcan" "Striker" "Shaft" "Railgun" "Magnum">>
<span id="Module">$Choice0-$Choice1-$Choice2</span>
<<button "Update">><<replace #Module>>$Choice0-$Choice1-$Choice2<</repeat>>

Basically, I play a game where there are several modules, which are combinations of protections from the weapons in the dropdown. I want players to be able to see the name of the module (there are many and it is annoying) just by selecting the weapons from the dropdown menus. Here is my StoryInit:

<<set $Modules = {"Kodiak T-A" : ["Firebird", "Railgun", "Thunder"], "Grizzly T-A" : ["Smoky", "Hammer", "Twins"], "Badger T-B" : ["Isida", "Freeze", "Ricochet"]}>>

(there are many more modules, but I am only showing these ones so that I do not fill up the whole page). I want my code to display "Kodiak T-A" and it's protections, when the user selects Firebird, Railgun and Thunder in any order. If they, for example, only select "Isida", and leave all of the other dropdowns at "none", then all modules that contain "Isida" will be displayed, along with their protections.

P.S: In case you want to know how many modules there are exactly, the full list is here.

1 Answer

0 votes
by (23.6k points)
selected by
 
Best answer

The sugarcube 2 pendant to contains() is includes().

by (2.7k points)
Thanks - I totally did not notice that!
...