diff --git a/mods/ITEMS/mcl_cauldrons/register.lua b/mods/ITEMS/mcl_cauldrons/register.lua index 78711eb5f..1159c8686 100644 --- a/mods/ITEMS/mcl_cauldrons/register.lua +++ b/mods/ITEMS/mcl_cauldrons/register.lua @@ -119,25 +119,15 @@ function mcl_cauldrons.empty_cauldron_on_drain(node, change_levels, substance) end --- test for membership in list (styled after R7RS) -local function member(obj, lis) - for i, v in ipairs(lis) do - if v == obj then return true end +-- test for membership in list +-- may be replaced with find(table, obj) -> any or nil +local function table_find(tbl, obj) + for k, v in pairs(lis) do + if v == obj then return k end end - return false end --- helper function to imply class-inheritance relation. -local function extends(parent_class, child_class) - if child_class == nil then child_class = {} end - child_class.__index = parent_class - setmetatable(child_class, child_class) - return child_class -end - - - -- Items that may interact with cauldron (right-click on cauldron). -- * May change cauldron state (substance+fill_level; fill/drain) -- * May change itemstack in hand (exchanging items for cauldron change). @@ -152,7 +142,7 @@ mcl_cauldrons.InteractableItem = { return child end, add_item_proxy = function(self, item_proxy) - if not member(item_proxy, self.handlers) then + if not table_find(self.handler, item_proxy) then -- instantiate prototype for sake of .parent instantiated = { __index = item_proxy, @@ -424,7 +414,7 @@ function mcl_cauldrons.BannerProxy:_accepts_itemstack(itemstack) if string.sub(itemstack:get_name(), 1, 12) == "mcl_banners:" then return true end - return member(itemstack:get_name(), {"mcl_banners:placeholder_banner"}) + return table_find({"mcl_banners:placeholder_banner"}, itemstack:get_name()) end function mcl_cauldrons.BannerProxy:do_apply(pos, node, user, itemstack) @@ -448,7 +438,7 @@ mcl_cauldrons.Cauldron = { } function mcl_cauldrons.Cauldron:add_item_proxy(proxy) - if not member(proxy, self.registered_proxies) then + if not table_find(self.registered_proxies, proxy) then -- insert at front so newer proxies override older ones. table.insert(self.registered_proxies, 1, proxy) end @@ -575,9 +565,7 @@ mcl_cauldrons.register_cauldron_node("mcl_cauldrons:cauldron_water_1", node_box = mcl_cauldrons.cauldron_nodeboxes[1], collision_box = mcl_cauldrons.cauldron_nodeboxes[0], tiles = { - "(default_water_source_animated.png^[verticalframe:16:0"..")^mcl_cauldrons_cauldron_top.png", - "mcl_cauldrons_cauldron_inner.png^mcl_cauldrons_cauldron_bottom.png", - "mcl_cauldrons_cauldron_side.png" + [1]="(default_water_source_animated.png^[verticalframe:16:0)^mcl_cauldrons_cauldron_top.png", }, drop = "mcl_cauldrons:cauldron", _mcl_cauldron_substance = "water", @@ -617,9 +605,7 @@ if minetest.get_modpath("mclx_core") then node_box = mcl_cauldrons.cauldron_nodeboxes[1], collision_box = mcl_cauldrons.cauldron_nodeboxes[0], tiles = { - "(default_river_water_source_animated.png^[verticalframe:16:0"..")^mcl_cauldrons_cauldron_top.png", - "mcl_cauldrons_cauldron_inner.png^mcl_cauldrons_cauldron_bottom.png", - "mcl_cauldrons_cauldron_side.png" + [1]="(default_river_water_source_animated.png^[verticalframe:16:0)^mcl_cauldrons_cauldron_top.png", }, drop = "mcl_cauldrons:cauldron", _mcl_cauldron_substance = "river_water",