[Harlowe 3.2.3] Simple save load mechanisim?

Twine Version: 2.3.16
Story Format: Harlowe 3.2.3

Hello there, I just started using twine yesterday and wanted to make a save-load mechanism for a game I’ll be making, at first I wanted to make the saves with date and time (ex. Slot IV - 13/3/20 - 10:03) but realized that would be a bit hard to handle and erased that code, now all I want to do is having 9 slots that have predetermined names (ex. Slot IV) At the beginning of the game I did this to load the game:

[[New Game]]

(if: (saved-games:) contains "Slot I")[
	(link:'Load Slot I')[
		(load-game:'Slot I')]]
(if: (saved-games:) contains "Slot II")[
	(link:'Load Slot II')[
		(load-game:'Slot II')]]
(if: (saved-games:) contains "Slot III")[
	(link:'Load Slot III')[
		(load-game:'Slot III')]]
(if: (saved-games:) contains "Slot IV")[
	(link:'Load Slot IV')[
		(load-game:'Slot IV')]]
(if: (saved-games:) contains "Slot V")[
	(link:'Load Slot V')[
		(load-game:'Slot V')]]
(if: (saved-games:) contains "Slot VI")[
	(link:'Load Slot VI')[
		(load-game:'Slot VI')]]
(if: (saved-games:) contains "Slot VII")[
	(link:'Load Slot VII')[
		(load-game:'Slot VII')]]
(if: (saved-games:) contains "Slot VIII")[
	(link:'Load Slot VIII')[
		(load-game:'Slot VIII')]]
(if: (saved-games:) contains "Slot IX")[
	(link:'Load Slot IX')[
		(load-game:'Slot IX')]]

And that works relatively fine, however for saving I kind of bumped to a roadblock:

(link:'Save Game')[
(dialog: bind $slotToSave,"Select a slot to save:", "Slot I","Slot II","Slot III","Slot IV","Slot V","Slot VI","Slot VII","Slot VIII","Slot IX")[(save-game:$slotToSave)]]

That saves fine but also gives the error: The string "" cannot be attached to this hook. after saving. How do I solve that?

1 Like

If you look at the usage (1st) line of the (dialog:) macro’s documentation you will see that it generates a Command object. Which aren’t designed to be attached to a Hook, like macros that generate a Changer object are.

This is why you’re getting the Hook attaching error that you are.

Changing your code to the following will get rid of the error.

(link:'Save Game')[
	(dialog: bind $slotToSave, "Select a slot to save:", "Slot I", "Slot II", "Slot III", "Slot IV", "Slot V", "Slot VI", "Slot VII", "Slot VIII", "Slot IX")
	(save-game: $slotToSave)

Ah, I see! Sorry about that. Thanks.