diff options
author | ShadowNinja <shadowninja@minetest.net> | 2013-12-20 17:07:39 -0500 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2013-12-20 17:07:39 -0500 |
commit | 731a82169b01116a4b707d9ecca3c7c9ca930abc (patch) | |
tree | 6084b4a05cd12a3ac5cbd359bef1bb252d6df21e /wrench/support.lua | |
parent | 0d32e05b52fcbafa60f3c939a327ba4019d022ce (diff) |
Rewrite wrench. INCOMPATIBLE WITH OLD ITEMS
You must place all of your picked up nodes before
updating and pick them back up after.
Diffstat (limited to 'wrench/support.lua')
-rw-r--r-- | wrench/support.lua | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/wrench/support.lua b/wrench/support.lua new file mode 100644 index 0000000..6d1c9ab --- /dev/null +++ b/wrench/support.lua @@ -0,0 +1,71 @@ +--[[ +supported_nodes +This table stores all nodes that are compatible with the wrench mod. +Syntax: + [<node name>] = { + lists = {"<inventory list name>"}, + metas = {["<meta name>"] = STRING, + ["<meta name>"] = INT, + ["<meta name>"] = FLOAT}, + owned = true, + store_meta_always = true, + } + owned - nodes that are protected by owner requirements (Ex. locked chests) + store_meta_always - when nodes are broken this ensures metadata and + inventory is always stored (Ex. active state for machines) +--]] + +wrench.META_TYPE_INT = 0 +wrench.META_TYPE_FLOAT = 1 +wrench.META_TYPE_STRING = 2 + +local INT, STRING, FLOAT = + wrench.META_TYPE_INT, + wrench.META_TYPE_STRING, + wrench.META_TYPE_FLOAT + +wrench.registered_nodes = { + ["default:chest"] = { + lists = {"main"}, + }, + ["default:chest_locked"] = { + lists = {"main"}, + metas = {owner = STRING, + infotext = STRING}, + owned = true, + }, + ["default:furnace"] = { + lists = {"fuel", "src", "dst"}, + metas = {infotext = STRING, + fuel_totaltime = FLOAT, + fuel_time = FLOAT, + src_totaltime = FLOAT, + src_time = FLOAT}, + }, + ["default:furnace_active"] = { + lists = {"fuel", "src", "dst"}, + metas = {infotext = STRING, + fuel_totaltime = FLOAT, + fuel_time = FLOAT, + src_totaltime = FLOAT, + src_time = FLOAT}, + store_meta_always = true, + }, + ["default:sign_wall"] = { + metas = {infotext = STRING, + text = STRING}, + }, +} + +function wrench:original_name(name) + for key, value in pairs(self.registered_nodes) do + if name == value.name then + return key + end + end +end + +function wrench:register_node(name, def) + self.registered_nodes[name] = def +end + |