fix leaving the tutorial levels

While running the tutorial, the Save command is disabled.  When the
tutorial was extended to two levels, stashing and restoring the
hero's equipment stopped working as intended if player entered the
second level.  The attempted fix for that broke re-enabling Save
even if the player left the tutorial without entering its second
level.

This seems to fix things, but I'm flailing around with barely a clue
here.  A couple of simpler attempts didn't work and I haven't figured
out why, so this is a bit more complex than what I wanted.

Reorganizing nhl_callback() isn't part of the fix, just avoids use
of some redundant code.
This commit is contained in:
PatR
2023-06-23 15:19:36 -07:00
parent 47fc27d188
commit cd9f145dba
6 changed files with 62 additions and 65 deletions

View File

@@ -195,17 +195,23 @@ end
function tutorial_enter()
-- nh.pline("TUT:enter");
-- add the tutorial branch callbacks
nh.callback("cmd_before", "tutorial_cmd_before");
nh.callback("end_turn", "tutorial_turn");
-- save state for later restore
nh.gamestate();
end
function tutorial_leave()
-- nh.pline("TUT:leave");
-- remove the tutorial level callbacks
-- remove the tutorial branch callbacks
nh.callback("cmd_before", "tutorial_cmd_before", true);
nh.callback("level_enter", "tutorial_enter", true);
nh.callback("level_leave", "tutorial_leave", true);
nh.callback("end_turn", "tutorial_turn", true);
-- restore state for regular play
nh.gamestate(true);
end