Help performing functions to variables

Twine Version: 2.9.2
Harlowe: 3.3.9

I am having trouble performing addition and subtraction to variables in Twine.

(if: (num:$alcohol) > 0)
	 [(set: (num: $alcohol) to it - 1)
 	   (set: (num: $clean) to it + 1)
[[You cleansed.->starting page]]]

(else:) [[[Gonna have to get some more alcohol.->starting page]]] 

I initialize the variables on the first page title screen with:

This is the title screen.

(set: $pizza_roominated to 'false')
(set: $alcohol to '2')
(set: $clean to '5')





[[>Start Game->starting page]]

So on the earlier example of code, I am trying to add a constant number to each of the variables when an action is performed, which leads to this page aka the first example of code; but it returns this error when testing:

“The (num:) macro’s 1st value is the any-typed variable name, $alcohol, but should be a string.
The (num:) macro’s 1st value is the any-typed variable name, $clean, but should be a string.”

What am I doing wrong here? I just can’t figure it out, have tried multiple different ways of writing this based on responses others have had in older questions on this and the original twine forum, but none have worked. Thanks.

I believe you need to (set: $alcohol to 2) in the first place (make it a number, not a string with quote marks) and then change it with (set: $alcohol to it - 1) etc.

2 Likes