0 votes
by (690 points)

Make sure to

(set: $Atk to 1)
(set: $HP to 20)
(set: $Slime_HP to 3)

It is very important that these are set to these values

 

I am very new to Twine, and already looked up a tutorial for this. As far as I can tell, this code should work. If someone could load this into their twine and tell me where I went wrong that would be very nice...

(if: (either: 1, 0) is 0) [The Slime spits Acid at You!(set: $HP to $HP - (either: 1,2))(if: $HP < 1) [[You Are Dead]]] (else:) [Your Health is $HP. Do you
[[Attack ->Fight Slime]]
or
[[Flee ->Main]]?]
(else:) [You strike the Slime! (set: $Slime_HP to $Slime_HP - $ATK)(if: $Slime_HP < 1)
[[You killed Slime]]] (else:) [Slime has $Slime_HP Health Left.
Do you
[[Attack ->Fight Slime]]
or
[[Flee ->Main]]?]

Also

for the next one set

(set: $Inn_Price to 25)

The value of $Money can be varied for testing

(if: $Money > $Inn_Price)[(set: $HP to $Max_HP)(set: $Money to $Money - $Inn_Price)
You have rested and your Health has been restored.]
(if: $Money = $Inn_Price)[(set: $HP to $Max_HP)(set: $Money to $Money - $Inn_Price) You have rested and your Health has been restored.]
(if: $Money < $Inn_Price)[You are too poor, come back when you have $Inn_Price or more Coyn...]
[[Leave the Inn ->Main]]

 

Thanks for you help

1 Answer

+2 votes
by (159k points)

1. There are a number of syntax errors in your first example, the following is a reformatted version of your example.

(if: (either: 1, 0) is 0)[
	The Slime spits Acid at You!
	(set: $HP to $HP - (either: 1,2))
	(if: $HP < 1)
		[[You Are Dead]]
	]
	(else:)[
		Your Health is $HP. Do you
		[[Attack ->Fight Slime]]
		or
		[[Flee ->Main]]?
	]
	(else:)[
		You strike the Slime!
		(set: $Slime_HP to $Slime_HP - $ATK)
		(if: $Slime_HP < 1)
			[[You killed Slime]]
		]
		(else:)[
			Slime has $Slime_HP Health Left.
			Do you
			[[Attack ->Fight Slime]]
			or
			[[Flee ->Main]]?
		]

 ... as you can now see:
a. Line 4's (if:) macro is missing an open square bracket.
b. Line 1's (if:) macro is missing it's close square bracket before the (else:) on Line 13.
c. Line 16's (if:) macro is missing an open square bracket.
d. Line 13's (else:) macro is missing it's close square bracket after the close square bracket on Line 25.

There is an operator error in the second (if:) macro of your second example, you are incorrectly using a single equals sign (=) which means assignment when you actually want to compare the two variables. If you read the Boolean Data section of the Harlowe Manual you will see that it suggests using the is operator instead.

by (63.1k points)
edited by
You should use (elseif:)s for the second part (the inn part). If the player has 20 money and the inn costs ten, they'll lose all their money and rest twice. This will happen anytime they have double the money of the inn price, because of the ordering of the code and the use of there separate (if:)s.
by (690 points)
Thanks, but I actually figured that out after staring at the code for a while. I've also even given my game a large amount of heavy upgrades, Magick, initiative, inventory, multiple locations, RNG based damage, character gender, class system, RNG base stat system, and an interactive Level Up system...

...the sheer number of passages and curved grey lines actually gives me a headache, and makes me wish I had been more organized with the placements...
...