Item Stacks: Add note about item meta data
This commit is contained in:
parent
6f9af6f0fd
commit
4b23c1689a
@ -13,7 +13,7 @@ In this chapter you will learn how to use ItemStacks.
|
|||||||
* Adding and Taking Items
|
* Adding and Taking Items
|
||||||
* Wear
|
* Wear
|
||||||
* Lua Tables
|
* Lua Tables
|
||||||
* Metadata
|
* Meta data
|
||||||
* More Methods
|
* More Methods
|
||||||
|
|
||||||
## Creating ItemStacks
|
## Creating ItemStacks
|
||||||
@ -118,16 +118,15 @@ local data = items:to_table()
|
|||||||
local items2 = ItemStack(data)
|
local items2 = ItemStack(data)
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
## Metadata
|
## Meta data
|
||||||
|
|
||||||
ItemStacks can also have a single field of metadata attached to
|
ItemStacks can have meta data, and use the same API as [Node Metadata](node_metadata.html).
|
||||||
them.
|
|
||||||
|
|
||||||
{% highlight lua %}
|
{% highlight lua %}
|
||||||
local meta = items:get_metadata()
|
local meta = items:get_meta()
|
||||||
print(dump(meta))
|
meta:set_string("foo", meta:get_string("foo") .. " ha!")
|
||||||
meta = meta .. " ha!"
|
|
||||||
items:set_metadata(meta)
|
print(dump(meta:get_string("foo")))
|
||||||
-- if ran multiple times, would give " ha! ha! ha!"
|
-- if ran multiple times, would give " ha! ha! ha!"
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user