Skip to content

Commit

Permalink
lua_api.txt: Document how to properly clear node metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
mtango688 authored and paramat committed Jul 30, 2016
1 parent cc01c3c commit 573b50a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions doc/lua_api.txt
Expand Up @@ -2641,6 +2641,7 @@ Can be gotten via `minetest.get_meta(pos)`.
* `get_inventory()`: returns `InvRef`
* `to_table()`: returns `nil` or `{fields = {...}, inventory = {list1 = {}, ...}}`
* `from_table(nil or {})`
* to clear metadata, use from_table(nil)
* See "Node Metadata"

### `NodeTimerRef`
Expand Down

3 comments on commit 573b50a

@HybridDog
Copy link
Contributor

@HybridDog HybridDog commented on 573b50a Aug 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mtango688 in my experience meta:to_table() never returns nil
What is the meaning of clear metadata?

@mtango688
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know what a node is?

In Minetest, you obtain a reference to a node, and then you can perform several methods, one of which is "get_meta(pos)". From that, you can obtain a reference to extra data and functionality (called NodeMetaData). The above commit simply documents how to reset that data.

@HybridDog
Copy link
Contributor

@HybridDog HybridDog commented on 573b50a Aug 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you reset the metadata and then get the table using to_table(), it's not nil but {fields={}, inventory={}}, so l updated the WorldEdit save function.
HybridDog/WorldEdit-pack@46518c3#diff-47530146b5061f78ea9bf09cf9e200a3R163
In which case does to_table() return nil?
And does from_table{} also reset it?

Please sign in to comment.