diff options
author | DS-Minetest <vorunbekannt75@web.de> | 2017-06-23 22:09:03 +0200 |
---|---|---|
committer | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2017-07-03 17:35:19 -0400 |
commit | 16146231b8f8c8562c1d1fd4a2c84bcf4134c3c5 (patch) | |
tree | f5333a567121117a5eb4c54d7a0b46fba8586c92 /wrench | |
parent | d4162be9a75816e2edbc8f6ed97588b2cad881d7 (diff) |
don't place eg. chests without data
Diffstat (limited to 'wrench')
-rw-r--r-- | wrench/init.lua | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/wrench/init.lua b/wrench/init.lua index f99fd14..bae77aa 100644 --- a/wrench/init.lua +++ b/wrench/init.lua @@ -24,10 +24,7 @@ local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end local function get_meta_type(name, metaname) local def = wrench.registered_nodes[name] - if not def or not def.metas or not def.metas[metaname] then - return nil - end - return def.metas[metaname] + return def and def.metas and def.metas[metaname] or nil end local function get_pickup_name(name) @@ -42,6 +39,14 @@ local function restore(pos, placer, itemstack) local data = itemstack:get_meta():get_string("data") data = (data ~= "" and data) or itemstack:get_metadata() data = minetest.deserialize(data) + if not data then + minetest.remove_node(pos) + minetest.log("error", placer:get_player_name().." wanted to place ".. + name.." at "..minetest.pos_to_string(pos).. + ", but it had no data.") + minetest.log("verbose", "itemstack: "..itemstack:to_string()) + return true + end minetest.set_node(pos, {name = data.name, param2 = node.param2}) for name, value in pairs(data.metas) do local meta_type = get_meta_type(data.name, name) |