Alright, so this is my first twine game, and anyone who bothers to check will can see that I made this account a sole 5 minutes ago, but I'm really at a loss here. But don't worry, I've lurked enough to not be a complete pain.
I'm using Twine 2 with Harlowe because as it will soon become apparent, i'm really not a coding expert. At all. Most of what i've done has been through osmosis of various tutorials, and...I'm having a lot of problems, But I just go with this one first.
In the game i am creating, there's a fair bit of "open world exploration", as in there's a passage that acts as a hub (The Pod), at three main locations to visit (The Docks, The Forest, The Village). What I'm trying to do is create conditions that must be met in order for certain passages to be read for the player to proceed. The scenario is pretty much: Player must meet 3 conditions, "accessed_village" + "accessed_dock " + "accessed_forest" to 'notice something they missed when previously at an area and have the option to go to a previously unseen passage. to do this, i'm creating a-not-really item that is added to the players $inv array, so that when the conditions are met it shows up.
it looks like this:
(set: $inv to $inv + (a: "accessed_dock"))
repeat in two more locations (yes, i've checked spelling) annnnd:
(if: $inv contains "accessed_village" + "accessed_dock " + "accessed_forest")[Oh, and there's a dog wearing a scarf watching you from under cafe table.]
Now- I have created something similar: alternate text based on what item the player chose to take earlier in the game, using stat values (picking up object put the item into the $inv array, as well as a value for a stat (the game has three stats that effect stuff, basic if/elseif/elseif ) AND THAT WORKED. The array method does not.
So if you've gotten through all of that, my question is, how can I use arrays to if/else conditions, so the player is able to "unlock" new dialoge by preforming tasks (which I could assign values i suppose), or having 'items' in the $inv array?
Comments
Now as mentioned, this is one of....many problems with my coding. Any suggestions are appreciated!
a. See if String "accessed_village" is within the array. (Boolean true or false)
b. Add two String values ( "accessed_dock " + "accessed_forest") to the Boolean
Unfortunately the contains operator does not support searching for an array of values, as demonstrated by the following test:
There is a way to achieve the result you want but using array subtraction and checking the length (number of elements in) of the result:
The above two examples used extra variables to store the items and the result of the subtraction, this was both for readability sake and to help with debugging.
You can do the same process using only the $list variable:
However in the end, i ended up making the decision to change what the game required the player to do to advance (instead of 'areas accessed', its now 'characters introduced' as i already had a single use passage set up (you dont know someones name the first time you meet them!) so ive created an incresing varible that must be met, instead of creating a list.
If anything similar this problem comes up in the future, I'll definetly be using your solution!! Again, thank you so much!