diff options
Diffstat (limited to 'crawl-ref/source/dat')
-rw-r--r-- | crawl-ref/source/dat/clua/iter.lua | 4 | ||||
-rw-r--r-- | crawl-ref/source/dat/clua/test.lua | 11 |
2 files changed, 13 insertions, 2 deletions
diff --git a/crawl-ref/source/dat/clua/iter.lua b/crawl-ref/source/dat/clua/iter.lua index e4d1409781..8adf548a15 100644 --- a/crawl-ref/source/dat/clua/iter.lua +++ b/crawl-ref/source/dat/clua/iter.lua @@ -338,7 +338,7 @@ function iter.stack_search (coord, term, extra) local stack = dgn.items_at(_x, _y) if #stack == 0 then - error("no stack at " .. _x .. "/" .. _y) + return nil end for _, item in ipairs(stack) do @@ -347,7 +347,7 @@ function iter.stack_search (coord, term, extra) end end - return false + return nil end function iter.stack_destroy(coord, extra) diff --git a/crawl-ref/source/dat/clua/test.lua b/crawl-ref/source/dat/clua/test.lua index 404b2e1d1f..22a4005d20 100644 --- a/crawl-ref/source/dat/clua/test.lua +++ b/crawl-ref/source/dat/clua/test.lua @@ -20,4 +20,15 @@ function test.regenerate_level(place) debug.flush_map_memory() dgn.reset_level() debug.generate_level() +end + +function test.level_contains_item(item) + for y = 1, dgn.GYM - 2 do + for x = 1, dgn.GXM - 2 do + if iter.stack_search(x, y, item) then + return true + end + end + end + return false end
\ No newline at end of file |