diff options
Diffstat (limited to 'crawl-ref/source/dat/clua/test.lua')
-rw-r--r-- | crawl-ref/source/dat/clua/test.lua | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/crawl-ref/source/dat/clua/test.lua b/crawl-ref/source/dat/clua/test.lua index 22a4005d20..03a23842e5 100644 --- a/crawl-ref/source/dat/clua/test.lua +++ b/crawl-ref/source/dat/clua/test.lua @@ -31,4 +31,49 @@ function test.level_contains_item(item) end end return false +end + +function test.level_monster_iterator(filter) + return iter.mons_rect_iterator(dgn.point(1, 1), + dgn.point(dgn.GXM - 2, dgn.GYM - 2), + filter) +end + +test.is_down_stair = dgn.feature_set_fn("stone_stairs_down_i", + "stone_stairs_down_ii", + "stone_stairs_down_iii") + +function test.level_has_down_stair() + for y = 1, dgn.GYM - 2 do + for x = 1, dgn.GXM - 2 do + local dfeat = dgn.grid(x, y) + if test.is_down_stair(dfeat) then + return true + end + end + end + return false +end + +function test.deeper_place_from(place) + if test.level_has_down_stair() then + local _, _, branch, depth = string.find(place, "(%w+):(%d+)") + return branch .. ":" .. (tonumber(depth) + 1) + end + return nil +end + +util.namespace('script') + +function script.simple_args() + local args = crawl.script_args() + return util.filter(function (arg) + return string.find(arg, '-') ~= 1 + end, + args) +end + +function script.usage(ustr) + ustr = string.gsub(string.gsub(ustr, "^%s+", ""), "%s+$", "") + error("\n" .. ustr) end
\ No newline at end of file |