Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

[Harlowe] Finding the order in which items are added to an array

So, I have a story in which the order you visit pages is important (at least, the first visit). So if you go to page 1, page 6, page 4, and page 5 in that order, it's different than going to 1, 2, 3, 4, 5.

The first thing I tried was adding passage names to an array for the pages that mattered for the count, if you once you click on a link to go to the page. Then, let's say the text on page 3 changes if you have been to page 5, before going to page 4. So on page 3:

(if: $passlog.indexOf("page5") is not -1 and is < $passlog.indexOf("page4")[some text] (else:)[other text]

Which simply did not work at all. So I was trying to figure if either .indexOf doesn't work, or if I am using it wrong; both are completely possible in this case. I did find a kind of kludgey workaround-- I created variables to store the number of times I visit the passages ($count1, $count2) in question, and created a third variable for each page ($p1; $p2, et al). So If, say, p1 is in $passlog already, it'll set $p1 to itself; if it is not, then it'll set $p1 to whatever $count1's value is. Then I can compare $p1 and $p2 for basically the same result. The problem is what happens if $p1 and $p2 are equal, which is pretty likely... in fact, the only reason this is working at all right now is because there's a bug in my counting method that is artificially inflating the numbers of later passages.

So... Help?
Sign In or Register to comment.