From 5d5502ae341030c58478dae2d04ba31ab2bfb93e Mon Sep 17 00:00:00 2001
From: Alexander Gavrilov
dfhack.items.getOwner(item)
+Returns the owner unit or nil.
+dfhack.items.setOwner(item,unit)
+Replaces the owner of the item. If unit is nil, removes ownership. +Returns false in case of error.
+dfhack.maps.getSize()
Returns map size in blocks: x, y, z
diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index fb818c206..febc59026 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -42,6 +42,7 @@ distribution. #include "modules/Job.h" #include "modules/Translation.h" #include "modules/Units.h" +#include "modules/Items.h" #include "modules/Materials.h" #include "modules/Maps.h" @@ -609,6 +610,12 @@ static const LuaWrapper::FunctionReg dfhack_units_module[] = { { NULL, NULL } }; +static const LuaWrapper::FunctionReg dfhack_items_module[] = { + WRAPM(Items, getOwner), + WRAPM(Items, setOwner), + { NULL, NULL } +}; + static bool maps_isBlockBurrowTile(df::burrow *burrow, df::map_block *block, int x, int y) { return Maps::isBlockBurrowTile(burrow, block, df::coord2d(x,y)); @@ -666,5 +673,6 @@ void OpenDFHackApi(lua_State *state) OpenModule(state, "gui", dfhack_gui_module); OpenModule(state, "job", dfhack_job_module, dfhack_job_funcs); OpenModule(state, "units", dfhack_units_module); + OpenModule(state, "items", dfhack_items_module); OpenModule(state, "maps", dfhack_maps_module, dfhack_maps_funcs); } diff --git a/library/include/DataDefs.h b/library/include/DataDefs.h index b9b4707d9..d4d757d94 100644 --- a/library/include/DataDefs.h +++ b/library/include/DataDefs.h @@ -425,6 +425,9 @@ namespace df static compound_identity *get() { return &T::_identity; } }; + template