diff options
author | DS <vorunbekannt75@web.de> | 2020-10-09 20:11:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-09 19:11:21 +0100 |
commit | f3ae45b2b245dd0aeb4a7d9b76afaf078871104c (patch) | |
tree | f9b0e27043bbe8f2b16e6f4917f6b9a92f273345 /src/script | |
parent | b2f3f663858e6d2a2174066e425bb6f2edea910b (diff) | |
download | minetest-f3ae45b2b245dd0aeb4a7d9b76afaf078871104c.tar.gz minetest-f3ae45b2b245dd0aeb4a7d9b76afaf078871104c.tar.bz2 minetest-f3ae45b2b245dd0aeb4a7d9b76afaf078871104c.zip |
Add a short_description to be used by mods (#8980)
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/common/c_content.cpp | 3 | ||||
-rw-r--r-- | src/script/lua_api/l_item.cpp | 11 | ||||
-rw-r--r-- | src/script/lua_api/l_item.h | 3 |
3 files changed, 17 insertions, 0 deletions
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index 774b6a326..147f6e3ed 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -56,6 +56,7 @@ void read_item_definition(lua_State* L, int index, es_ItemType, ITEM_NONE); getstringfield(L, index, "name", def.name); getstringfield(L, index, "description", def.description); + getstringfield(L, index, "short_description", def.short_description); getstringfield(L, index, "inventory_image", def.inventory_image); getstringfield(L, index, "inventory_overlay", def.inventory_overlay); getstringfield(L, index, "wield_image", def.wield_image); @@ -142,6 +143,8 @@ void push_item_definition_full(lua_State *L, const ItemDefinition &i) lua_setfield(L, -2, "name"); lua_pushstring(L, i.description.c_str()); lua_setfield(L, -2, "description"); + lua_pushstring(L, i.short_description.c_str()); + lua_setfield(L, -2, "short_description"); lua_pushstring(L, type.c_str()); lua_setfield(L, -2, "type"); lua_pushstring(L, i.inventory_image.c_str()); diff --git a/src/script/lua_api/l_item.cpp b/src/script/lua_api/l_item.cpp index d67cab76f..2d1124a4d 100644 --- a/src/script/lua_api/l_item.cpp +++ b/src/script/lua_api/l_item.cpp @@ -193,6 +193,16 @@ int LuaItemStack::l_get_description(lua_State *L) return 1; } +// get_short_description(self) +int LuaItemStack::l_get_short_description(lua_State *L) +{ + NO_MAP_LOCK_REQUIRED; + LuaItemStack *o = checkobject(L, 1); + std::string desc = o->m_stack.getShortDescription(getGameDef(L)->idef()); + lua_pushstring(L, desc.c_str()); + return 1; +} + // clear(self) -> true int LuaItemStack::l_clear(lua_State *L) { @@ -493,6 +503,7 @@ const luaL_Reg LuaItemStack::methods[] = { luamethod(LuaItemStack, get_metadata), luamethod(LuaItemStack, set_metadata), luamethod(LuaItemStack, get_description), + luamethod(LuaItemStack, get_short_description), luamethod(LuaItemStack, clear), luamethod(LuaItemStack, replace), luamethod(LuaItemStack, to_string), diff --git a/src/script/lua_api/l_item.h b/src/script/lua_api/l_item.h index 98744c071..16878c101 100644 --- a/src/script/lua_api/l_item.h +++ b/src/script/lua_api/l_item.h @@ -72,6 +72,9 @@ private: // get_description(self) static int l_get_description(lua_State *L); + // get_short_description(self) + static int l_get_short_description(lua_State *L); + // clear(self) -> true static int l_clear(lua_State *L); |