From a4183994a446a065e3151745b4167270ebae6194 Mon Sep 17 00:00:00 2001 From: Sfan5 Date: Wed, 1 May 2013 12:31:21 +0200 Subject: Add a Way of checking for specific Feature with Lua Adds minetest.get_feature() and minetest.has_feature() --- builtin/features.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 builtin/features.lua (limited to 'builtin/features.lua') diff --git a/builtin/features.lua b/builtin/features.lua new file mode 100644 index 000000000..0eef2519d --- /dev/null +++ b/builtin/features.lua @@ -0,0 +1,28 @@ +-- Minetest: builtin/features.lua + +minetest.features = { + "glasslike_framed" = true, + "nodebox_as_selectionbox" = true, + "chat_send_player_param3" = true, + "get_all_craft_recipes_works" = true, + "use_texture_alpha" = true, +} + +function minetest.has_feature(arg) + if type(arg) == "table" then + missing_features = {} + result = true + for ft, _ in pairs(arg) do + if not minetest.features[ftr] then + missing_features[ftr] = true + result = false + end + end + return result, missing_features + elseif type(arg) == "string" then + if not minetest.features[arg] then + return false, {[arg]=true} + end + return true, {} + end +end -- cgit v1.2.3