diff options
| author | Alexander Gavrilov | 2012-05-02 12:50:05 +0400 |
|---|---|---|
| committer | Alexander Gavrilov | 2012-05-02 12:50:05 +0400 |
| commit | 28b5068382ebd406b269e6b4aeb073e7cd26503e (patch) | |
| tree | 31f5ddd90b035e18857e645562b309040c84b559 /library/LuaApi.cpp | |
| parent | eadce959408a7b1811bd158e4d5cb74e57b671e6 (diff) | |
| download | dfhack-28b5068382ebd406b269e6b4aeb073e7cd26503e.tar.gz dfhack-28b5068382ebd406b269e6b4aeb073e7cd26503e.tar.bz2 dfhack-28b5068382ebd406b269e6b4aeb073e7cd26503e.tar.xz | |
Allow both coordinate object and (x,y,z) as arguments to getTileBlock.
Diffstat (limited to 'library/LuaApi.cpp')
| -rw-r--r-- | library/LuaApi.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index 0d064718..05a71d61 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -520,8 +520,7 @@ static int dfhack_matinfo_matches(lua_State *state) else if (lua_istable(state, 2)) { df::dfhack_material_category tmp; - if (!Lua::AssignDFObject(*Lua::GetOutput(state), state, &tmp, 2, false)) - lua_error(state); + Lua::CheckDFObject(state, &tmp, 2, false); lua_pushboolean(state, info.matches(tmp)); } else @@ -714,7 +713,6 @@ static const luaL_Reg dfhack_items_funcs[] = { static const LuaWrapper::FunctionReg dfhack_maps_module[] = { WRAPN(getBlock, (df::map_block* (*)(int32_t,int32_t,int32_t))Maps::getBlock), - WRAPN(getTileBlock, (df::map_block* (*)(df::coord))Maps::getTileBlock), WRAPM(Maps, getRegionBiome), WRAPM(Maps, getGlobalInitFeature), WRAPM(Maps, getLocalInitFeature), @@ -722,7 +720,27 @@ static const LuaWrapper::FunctionReg dfhack_maps_module[] = { { NULL, NULL } }; +static int maps_getTileBlock(lua_State *L) +{ + df::map_block *block; + if (lua_gettop(L) == 1) + { + df::coord pos; + Lua::CheckDFObject(L, &pos, 1); + block = Maps::getTileBlock(pos); + } + else + { + block = Maps::getTileBlock( + luaL_checkint(L, 1), luaL_checkint(L, 2), luaL_checkint(L, 3) + ); + } + Lua::PushDFObject(L, block); + return 1; +} + static const luaL_Reg dfhack_maps_funcs[] = { + { "getTileBlock", maps_getTileBlock }, { NULL, NULL } }; |
