Tutorial: hunger and eating food
Reset hunger when exiting the tutorial. Add an optional second parameter to lua pline, forcing a more-prompt.
This commit is contained in:
@@ -270,6 +270,18 @@ local tutorial_events = {
|
|||||||
tutorial_whitelist_commands["zap"] = true;
|
tutorial_whitelist_commands["zap"] = true;
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
func = function()
|
||||||
|
if (u.uhunger < 148) then
|
||||||
|
tutorial_whitelist_commands["eat"] = true;
|
||||||
|
local o = obj.new("blessed food ration");
|
||||||
|
o:placeobj(u.ux, u.uy);
|
||||||
|
nh.pline("Looks like you're getting hungry. You'll starve to death, unless you eat something.", true);
|
||||||
|
nh.pline("Comestibles are eaten with '" .. nh.eckey("eat") .. "'", true);
|
||||||
|
return true;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function tutorial_turn()
|
function tutorial_turn()
|
||||||
|
|||||||
@@ -331,10 +331,12 @@ Example:
|
|||||||
=== pline
|
=== pline
|
||||||
|
|
||||||
Show the text in the message area.
|
Show the text in the message area.
|
||||||
|
Second parameter is an optional boolean; if true, force a `--more--` prompt.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
nh.pline("Message text to show.");
|
nh.pline("Message text to show.");
|
||||||
|
nh.pline("Waiting for user.", true);
|
||||||
|
|
||||||
|
|
||||||
=== pushkey
|
=== pushkey
|
||||||
|
|||||||
+6
-2
@@ -603,14 +603,17 @@ nhl_impossible(lua_State *L)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* pline("It hits!") */
|
/* pline("It hits!") */
|
||||||
|
/* pline("It hits!", true) */
|
||||||
static int
|
static int
|
||||||
nhl_pline(lua_State *L)
|
nhl_pline(lua_State *L)
|
||||||
{
|
{
|
||||||
int argc = lua_gettop(L);
|
int argc = lua_gettop(L);
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1 || argc == 2) {
|
||||||
pline("%s", luaL_checkstring(L, 1));
|
pline("%s", luaL_checkstring(L, 1));
|
||||||
else
|
if (lua_toboolean(L, 2))
|
||||||
|
display_nhwindow(WIN_MESSAGE, TRUE); /* --more-- */
|
||||||
|
} else
|
||||||
nhl_error(L, "Wrong args");
|
nhl_error(L, "Wrong args");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1593,6 +1596,7 @@ nhl_gamestate(lua_State *L)
|
|||||||
if (wornmask)
|
if (wornmask)
|
||||||
setworn(otmp, wornmask);
|
setworn(otmp, wornmask);
|
||||||
}
|
}
|
||||||
|
init_uhunger();
|
||||||
stored = FALSE;
|
stored = FALSE;
|
||||||
} else {
|
} else {
|
||||||
/* store game state */
|
/* store game state */
|
||||||
|
|||||||
Reference in New Issue
Block a user