From 12dd5323c8ac2b6b291d55678dfe1d392ee2d132 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Tue, 4 Apr 2023 13:04:35 +0300 Subject: [PATCH] Tutorial: eating food Also document the lua timers a bit more. --- dat/tut-1.lua | 20 +++++++++++++++----- doc/lua.adoc | 26 ++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/dat/tut-1.lua b/dat/tut-1.lua index 68830439d..8f755e39c 100644 --- a/dat/tut-1.lua +++ b/dat/tut-1.lua @@ -5,11 +5,11 @@ des.level_flags("mazelevel", "noflip", des.map([[ --------------------------------------------------------------------------- -|-.--|.......|......|..S....|.F.......|...................................| -|.-..........|......|--|....|.F.....|.|S-------...........................| -||.--|.......|..T......|....|.F.....|.|.......|...........................| -||.|.|.......|......|-.|....|.F.....|.|.......|...........................| -||.|.|.......|......||.|-.-----------.-.......|...........................| +|-.--|.......|......|..S....|.F.......|.............|.....................| +|.-..........|......|--|....|.F.....|.|S-------.....|.....................| +||.--|.......|..T......|....|.F.....|.|.......|.....|.....................| +||.|.|.......|......|-.|....|.F.....|.|.......|.....|.....................| +||.|.|.......|......||.|-.-----------.-.......|------.....................| |-+-S---------..---.||........................|...........................| |......| |.-------------------.......|...........................| |......| ###### |.........| |..S.......|...........................| @@ -203,6 +203,16 @@ des.trap({ type = "magic portal", coord = { 27,14 }, seen = true }); -- +des.engraving({ coord = { 48,1 }, type = "burn", text = "Use '" .. nh.eckey("eat") .. "' to eat edible things", degrade = false }); + +des.object({ coord = { 50,3 }, id = "apple", buc = "not-cursed" }); +des.object({ coord = { 50,3 }, id = "candy bar", buc = "not-cursed" }); + +local otmp = des.object({ coord = { 50,3 }, id = "corpse", montype = "newt", buc = "not-cursed" }); +otmp:stop_timer("rot-corpse"); + +-- + des.engraving({ coord = { 55,9 }, type = "burn", text = "UNDER CONSTRUCTION", degrade = false }); diff --git a/doc/lua.adoc b/doc/lua.adoc index 3c70ee6d7..a22da3da0 100644 --- a/doc/lua.adoc +++ b/doc/lua.adoc @@ -321,6 +321,7 @@ Example: === peek_timer_at When does timer at location at x,y trigger? +See <<_timer_types>>. Example: @@ -399,6 +400,7 @@ Example: === start_timer_at Start a timer at location x,y, with trigger time of `when` - relative to current turn. +See <<_timer_types>>. Example: @@ -409,6 +411,7 @@ Example: === stop_timer_at Stop a timer at location x,y. +See <<_timer_types>>. Example: @@ -1404,6 +1407,7 @@ Example: === has_timer Does object have an attached timer of certain type? +See <<_timer_types>>. Example: @@ -1414,6 +1418,7 @@ Example: Peek at an object timer. Returns the turn when timer triggers. Returns 0 if no such timer attached to the object. +See <<_timer_types>>. Example: @@ -1425,7 +1430,7 @@ Example: Stop object timer(s). Return the turn when timer would have triggered. Returns 0 if no such timer was attached to the object. Without a timer type parameters, stops all timers for the object, -and returns nothing. +and returns nothing. See <<_timer_types>>. Example: @@ -1435,7 +1440,7 @@ Example: === start_timer -Start an object timer. +Start an object timer. See <<_timer_types>>. Example: @@ -1494,3 +1499,20 @@ These constants are in the `nhc` table. | ROWNO | Number of map rows | DLB | 1 or 0, depending if NetHack is compiled with DLB |=== + + +== Timer types + +[%header, cols="20%,10%,70%"] +|=== +| Name | Type | Description +| rot-organic | obj | non-corpse object rotting away +| rot-corpse | obj | corpse object rotting away +| revive-mon | obj | monster corpse revival +| zombify-mon | obj | monster corpse rising as a zombie +| burn-obj | obj | light-source object is lit +| hatch-egg | obj | egg hatching +| fig-transform | obj | cursed figurine automatical transform +| shrink-glob | obj | glob object shrinking away +| melt-ice | map | ice at map location melts +|===