diff options
author | Adam Borowski <kilobyte@angband.pl> | 2011-07-11 15:02:23 +0200 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2011-07-12 00:32:22 +0200 |
commit | 82cb2a995b33f27d7ee692c01b0c10b48e24616e (patch) | |
tree | 5041db95383d95a992a3ea32a5057cc4df6da3d1 /crawl-ref/source/l_debug.cc | |
parent | 917a65255999b0aef5d317d6bd4a17e6a59b9eea (diff) | |
download | crawl-ref-82cb2a995b33f27d7ee692c01b0c10b48e24616e.tar.gz crawl-ref-82cb2a995b33f27d7ee692c01b0c10b48e24616e.zip |
A dlua function debug.disable() to turn off some parts of Crawl.
Currently implemented:
* spawns
* mon_act
* mon_regen
* player_regen
* hunger
Diffstat (limited to 'crawl-ref/source/l_debug.cc')
-rw-r--r-- | crawl-ref/source/l_debug.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/crawl-ref/source/l_debug.cc b/crawl-ref/source/l_debug.cc index d0cf583b40..07f6c4bf68 100644 --- a/crawl-ref/source/l_debug.cc +++ b/crawl-ref/source/l_debug.cc @@ -326,6 +326,35 @@ LUAFN(debug_seen_monsters_react) return (0); } +static const char* disablements[] = +{ + "spawns", + "mon_act", + "mon_regen", + "player_regen", + "hunger", +}; + +LUAFN(debug_disable) +{ + COMPILE_CHECK(ARRAYSZ(disablements) == NUM_DISABLEMENTS); + + const char* what = luaL_checkstring(ls, 1); + for (int dis = 0; dis < NUM_DISABLEMENTS; dis++) + if (what && !strcmp(what, disablements[dis])) + { + bool onoff = true; + if (lua_isboolean(ls, 2)) + onoff = lua_toboolean(ls, 2); + crawl_state.disables.set(dis, onoff); + return (0); + } + luaL_argerror(ls, 1, + make_stringf("unknown thing to disable: %s", what).c_str()); + + return (0); +} + const struct luaL_reg debug_dlib[] = { { "goto_place", debug_goto_place }, @@ -349,5 +378,6 @@ const struct luaL_reg debug_dlib[] = { "check_uniques", debug_check_uniques }, { "viewwindow", debug_viewwindow }, { "seen_monsters_react", debug_seen_monsters_react }, +{ "disable", debug_disable }, { NULL, NULL } }; |