minertools: table.indexof() function used.

Local implementation of is_member_of() function removed, array membership
checks now use Minetest own table.indexof() function instead.

Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
This commit is contained in:
Michal Cieslakiewicz 2019-05-20 17:52:31 +02:00
parent a2bc26992f
commit be846a7bc4

View File

@ -163,14 +163,6 @@ local function has_obsidian(name)
return false return false
end end
-- check if node is in array
local function is_member_of(name, array)
for _, n in ipairs(array) do
if n == name then return true end
end
return false
end
--[[ --[[
------------- -------------
Settings Menu Settings Menu
@ -411,7 +403,7 @@ local function mineralfinder_init_metadata(player, tool)
local ore_list = tool_def._find_ore_list local ore_list = tool_def._find_ore_list
local tool_meta = tool:get_meta() local tool_meta = tool:get_meta()
local ore_type = tool_meta:get_string("ore_type") local ore_type = tool_meta:get_string("ore_type")
if not is_member_of(ore_type, ore_list) then if table.indexof(ore_list, ore_type) < 0 then
tool_meta:set_string("ore_type", "coal") tool_meta:set_string("ore_type", "coal")
player:set_wielded_item(tool) -- update item player:set_wielded_item(tool) -- update item
return true return true
@ -441,7 +433,7 @@ local function multidevice_init_metadata(player, tool)
-- mineral finder module -- mineral finder module
local ore_list = tool_def._find_ore_list local ore_list = tool_def._find_ore_list
local ore_type = tool_meta:get_string("ore_type") local ore_type = tool_meta:get_string("ore_type")
if not is_member_of(ore_type, ore_list) then if table.indexof(ore_list, ore_type) < 0 then
tool_meta:set_string("ore_type", "coal") tool_meta:set_string("ore_type", "coal")
tool_upd = true tool_upd = true
end end