+1 vote
by (690 points)
I have a save/load feature in my game, but I'm getting annoyed with the error that shows up If I click load on an empty save. I need an (if:) command to check if the save passage is empty or not

Can anyone help me with this?

1 Answer

+2 votes
by (159k points)
selected by
 
Best answer

Please use the Question Tags to state the name and full version number of the story format you are using, as answers can vary based on that information. You don't state which version of Harlowe you are using so I will assume that it is the default, which is v2.1.0

The (saved-games:) macro returns a Data-Map containing information about all the existing saves, you can use the contains operator to determine if that Data-Map contains a particular save. This is shown by the second of the macro's examples. There are at least two ways you can use this information:

1. Always show the link but only do the load if the save exist.

(link: "Load File A")[
	(if: (saved-games:) contains "File A")[
		(load-game: "File A")
	]
]


2. Only show the link if the save exists.

(if: (saved-games:) contains "File A")[
	(link: "Load File A")[
		(load-game: "File A")
	]
]

 

...