Anytype variable problem

So i’ve rewrote my enemy several times to avoid researching this. I GIVE UP. how do I restrict an any-type variable to be a number-only variable?

The TypedVar data section of the Harlowe manual explains where a typed value can be defined & used, and the Datatype data section explains which data types are supported.

You haven’t stated under which conditions you want to restrict the specific datatype to number:

  • the argument of a custom macro.
  • some other situation.

In the case of a custom macro argument, that is done during the macro definition phase…

(set: $rollXdY to (macro: num-type _dice, num-type _faces, [
	(set: _total to 0)
	(for: each _die, ...(range: 1, _dice))[
		(set: _total to it + (random: 1, _faces))
	]
	(output-data: _total)
]))

3d6: (print: ($rollXdY: 3, 6))
1 Like