Back vs Return - rvince452/twine-game-gen GitHub Wiki
<<back>>
<<return>>
- back is essentially an 'undo'. Not only passage history but variable state. Use this only if you really mean 'undo'. Also there can be problems if the source passage has any change in state.
- return means 'go back to the 'previous passage'. It can be handy but make sure you understand all the possibilities for 'previous passage' including any links introduced by a menu/footer.
You have 3 passages: START, A and B. You can go from START to A; from A to B. You have a variable named COUNT. COUNT is initialized as 0 and is increased by 1 when you enter any of those 3 passages
:: START
<<set $COUNT +1>>
<<back>>
<<return>>
[[A]]
:: A
<<set $COUNT +1>>
<<back>>
<<return>>
[[B]]
:: B
<<set $COUNT +1>>
<<back>>
<<return>>
Go from START to A to B. You should note the following:
| COUNT | Passage | Prev Passage |
|---|---|---|
| 1 | START | n/a |
| 2 | A | START |
| 3 | B | A |
Use back macro starting in B and then in A. You should end up in START
| COUNT | Passage | Prev Passage |
|---|---|---|
| 2 | A | START |
| 1 | START | n/a |
Now, again, go from START to A to B. The COUNT will be at 3. Now use the return macros starting in B and then in A.
| COUNT | Passage | Prev Passage |
|---|---|---|
| 4 | A | B |
| 5 | B | A |
| 6 | A | B |
| Note - you are trapped between A and B and the count keeps increasing. You can use back to get you out. |
Back should always work because it just brings you back through your history, BUT it will do variable changes. Since back is really an undo, try not to ever use it unless you really mean 'undo'. For example: "You have died in the game, press back to go to the last passage and try again"
Return will take you back to your last passage BUT you can get trapped between two passages - as we saw. If you use it, you have to consider how it will be used. There are some cases you might use it.
- In a dead-end object (like a closet or looking in a jar) - I mean a passage that has no other exits - in those cases I use a single return to let them go back. This is also a way to use a generic passage in multiple places. For example, I could have a single closet passage and include a link to it from all of the bedrooms (since each bedroom should have a closet).
- When you have normal links but want the user to be able to easily choose the link that takes them back. For example, imagine a hallway that links to 4 bedrooms (4 links). When the user steps into the hallway from a bedroom, they are presented with 4 links and they can choose the bedroom they want - but you might also allow a return macro to make it easier for them to go back to the bedroom where they were.
You should consider that there might be other ways to navigate to a passage from the current passage. For example, let's look again at the example of three passages START <-> A <-> B. In B, I place a return macro because the only place you can go from B would be A. I am lazy and placed the return rather than a link to A. This should work.
BUT, what if I have links in a side menu or in a footer (see the example game which has both). This would allow one to go from B to INVENTORY for example. If INVENTORY has a return, then the return from B will not go to A, it will go to INVENTORY. UGHH. Alternatively INVENTORY could have a BACK and then we are good. But there is a further caveat. There should not be any change in state in B.