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:
@@ -136,5 +136,9 @@ nhcore = {
|
||||
|
||||
-- getpos_tip is called the first time the code enters getpos()
|
||||
getpos_tip = show_getpos_tip,
|
||||
|
||||
-- enter_tutorial and leave_tutorial
|
||||
enter_tutorial = tutorial_enter,
|
||||
leave_tutorial = tutorial_leave,
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -254,11 +254,11 @@ des.trap({ type = "magic portal", coord = { 66,2 }, seen = true });
|
||||
|
||||
----------------
|
||||
|
||||
nh.callback("cmd_before", "tutorial_cmd_before");
|
||||
-- entering and leaving tutorial _branch_ now handled by core
|
||||
-- // nh.callback("cmd_before", "tutorial_cmd_before");
|
||||
-- // nh.callback("level_enter", "tutorial_enter");
|
||||
-- // nh.callback("level_leave", "tutorial_leave");
|
||||
nh.callback("end_turn", "tutorial_turn");
|
||||
-- // nh.callback("end_turn", "tutorial_turn");
|
||||
|
||||
----------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user