aboutsummaryrefslogtreecommitdiff
path: root/doc/lua_api.txt
diff options
context:
space:
mode:
authorFrancisco <FreeLikeGNU@users.noreply.github.com>2021-12-10 03:24:42 -0800
committerGitHub <noreply@github.com>2021-12-10 12:24:42 +0100
commita8c58d5cbba994849ea78e3eecefbefb70070bb7 (patch)
treec320cc0b858c4f44e6c7c100a95ea2f893b0f084 /doc/lua_api.txt
parentd9d219356aa31cd953303580ccde7f0e27dd0fe6 (diff)
downloadhax-minetest-server-a8c58d5cbba994849ea78e3eecefbefb70070bb7.tar.gz
hax-minetest-server-a8c58d5cbba994849ea78e3eecefbefb70070bb7.zip
Add pauloue's ItemStack example to docs (#9853)
Diffstat (limited to 'doc/lua_api.txt')
-rw-r--r--doc/lua_api.txt15
1 files changed, 15 insertions, 0 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index aff739cfb..e26497555 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -2181,6 +2181,21 @@ Example:
meta:set_string("key", "value")
print(dump(meta:to_table()))
+Example manipulations of "description" and expected output behaviors:
+
+ print(ItemStack("default:pick_steel"):get_description()) --> Steel Pickaxe
+ print(ItemStack("foobar"):get_description()) --> Unknown Item
+
+ local stack = ItemStack("default:stone")
+ stack:get_meta():set_string("description", "Custom description\nAnother line")
+ print(stack:get_description()) --> Custom description\nAnother line
+ print(stack:get_short_description()) --> Custom description
+
+ stack:get_meta():set_string("short_description", "Short")
+ print(stack:get_description()) --> Custom description\nAnother line
+ print(stack:get_short_description()) --> Short
+
+ print(ItemStack("mod:item_with_no_desc"):get_description()) --> mod:item_with_no_desc