Quantcast
Channel: Help! with 2.0 - Twine Forum
Viewing all articles
Browse latest Browse all 1844

If statement, comparing previous() to couple passage titles utterly fails.

$
0
0
Greetings
This is using Twine 2.0 with Sugarcube story format.
My game has buttons for entering inventoryScreen, charScreen, travelScreen, from any passage where it's allowable. After visiting the passage and reading the information presented there, at the end there is <<return>> button to return.
I've been trying to get around the loop that is created when, say, from inventoryScreen we would have clicked charScreen.

I'd done so already with simply disabling StoryMenu (holding the buttons) when on inventoryScreen passage and the others. But I require additional functionality on these passages now, and <<return>> and the loop 'bug' that comes with it is making it impossible for me.

So, I came up with this (for debugging whether it even works):
<<set $lastVisitedPassage = previous()>>
  <<if $lastVisitedPassage == "ScreenMenu" || "travelScreen" || "inventoryScreen" || "charScreen">>
  <<print "result 1">>
  <<print previous()>>
  <<else>>
  <<print "result 2">>
  <<print previous()>>
  <</if>>

and with this
<<set $lastVisitedPassage = previous()>>
  <<if $lastVisitedPassage == ("ScreenMenu" || "travelScreen" || "inventoryScreen" || "charScreen")>>
  <<print "result 1">>
  <<print previous()>>
  <<else>>
  <<print "result 2">>
  <<print previous()>>
  <</if>>

The first ALWAYS renders the result 1, the second ALWAYS the result 2. If I change == into != the situation get's reversed, but still always.
By always I mean no matter if print previous() shows any of the passageTitles I want to exclude or a random like desertVillage that I made.

How is that even possible? Of that I am very curious, if not frustrated with.

Most importantly, how to make it work? Or how to make another way of circumventing the <<return>> loop bug without disabling the possibility for the player to enter the inventoryScreen and other passages from any point in the game world?

Also, I'd tried changing the StoryMenu special passage to turn the buttons into setter links, like so:
[[Inventory->inventoryScreen][set $lastVisitedPassage = previous()]]
but an technical error pops up.

Best Regards!

Viewing all articles
Browse latest Browse all 1844

Trending Articles