If you are requesting technical assistance with Twine, please specify:
Twine Version: 2.3.14
Story Format: harlowe 3.3.2
How can I define an empty datamap?
for example, I made an empty datamap
(set:$inv to (dm:))
then I try to use it with a (if:) marco,
to see if it is empty,
I tried below:
(if: (datanames:$inv) is not 0)[(link:'haha')[]]
(if: $inv is not empty)[(link:'haha')[]]
(if: (datanames:$inv) is not empty)[(link:'haha')[]]
(if: (datanames:$inv) is not 0)[(link:'haha')[]]
.....
it all fails,
in short: I tried to hide the link when the datamap is empty, but I don’t how to define an empty datamap in a if marco.
(if (datanames: $inv)'s length is not 0)) should work: (datanames:) gives you an array, and 's length gives you the number of entries, then you compare against zero.
It’s mostly style or personal preference: if you’re only using the “not” case (no (else:)), it might read better: to say (unless: thing) than to say (if: not thing)