Skip to content

Commit a8c58d5

Browse files
authoredDec 10, 2021
Add pauloue's ItemStack example to docs (#9853)
1 parent d9d2193 commit a8c58d5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
 

‎doc/lua_api.txt

+15
Original file line numberDiff line numberDiff line change
@@ -2181,6 +2181,21 @@ Example:
21812181
meta:set_string("key", "value")
21822182
print(dump(meta:to_table()))
21832183

2184+
Example manipulations of "description" and expected output behaviors:
2185+
2186+
print(ItemStack("default:pick_steel"):get_description()) --> Steel Pickaxe
2187+
print(ItemStack("foobar"):get_description()) --> Unknown Item
2188+
2189+
local stack = ItemStack("default:stone")
2190+
stack:get_meta():set_string("description", "Custom description\nAnother line")
2191+
print(stack:get_description()) --> Custom description\nAnother line
2192+
print(stack:get_short_description()) --> Custom description
2193+
2194+
stack:get_meta():set_string("short_description", "Short")
2195+
print(stack:get_description()) --> Custom description\nAnother line
2196+
print(stack:get_short_description()) --> Short
2197+
2198+
print(ItemStack("mod:item_with_no_desc"):get_description()) --> mod:item_with_no_desc
21842199

21852200

21862201

0 commit comments

Comments
 (0)
Please sign in to comment.