0 votes
by (300 points)

Hello, I tried to make a combination of passages in Twine 2.0 Harlowe where If in passage1 your HP is <1 the player gets send to passage2 where that the HP increases to 50 and when you click Next you get send back to passage1 where you can click Next again but this time you continue instead of getting sent to passage2 but when I test it it only works if your hp is <1 otherwise you still get sent to passage1 but this time when you click Next it just disappears and its just the blank page..here's my code: 

|test>[
	(link: "Continue")[
	    (if: $vesselhp is <1)[(goto: "New vessel")]         
	         ](else:) [(goto: "passage2")]
	] 

 

1 Answer

+1 vote
by (159k points)
selected by
 
Best answer

The following is slightly better formatted (line-breaks & indentation) version of your examine...

|test>[
	(link: "Continue")[
		(if: $vesselhp is <1)[
			(goto: "New vessel")
		]
	]
	(else:)[
		(goto: "passage2")
	]
]

... as you can now see your (else:) macro is outside the associated hook of you (link:) macro, this causes the (else:) to be executed before the link is clicked.

There are also a couple of minor issues with your example:

  1. You shouldn't be using the is operator when using the mathematical greater-than or less-than related operators.
  2. You shouldn't add space characters between a macro (like your (else:) macro) and it's associated.
  3. It helps readability if you add a space charter between the comparison operator of a condition expression (like that in your (if:) macro) and the value.

The follow is a modified version of your examine with the major and minor issues fixed.

|test>[
	(link: "Continue")[
		(if: $vesselhp < 1)[
			(goto: "New vessel")
		]
		(else:)[
			(goto: "passage2")
		]
	]
]

 

Note: You didn't state where you are initialising your $vesselhp variable to its default value (I assume that it equals zero), ideally that initialisation should be done in your story's header tagged special passage like so.

(set: $vesselhp to 0)

 

...