diff --git a/.luacheckrc b/.luacheckrc index 494507e..d128c79 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -20,6 +20,6 @@ read_globals = { -- mods "default", "mesecon", "digiline", "screwdriver", "unified_inventory", - "i3", + "i3", "mcl_experience", "awards" } diff --git a/autocrafter.lua b/autocrafter.lua index 206f2b2..b5e06fc 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -35,25 +35,42 @@ end local function autocraft(inventory, craft) if not craft then return false end - local output_item = craft.output.item - - -- check if we have enough room in dst - if not inventory:room_for_item("dst", output_item) then return false end - local consumption = craft.consumption - local inv_index = count_index(inventory:get_list("src")) -- check if we have enough material available - for itemname, number in pairs(consumption) do + local inv_index = count_index(inventory:get_list("src")) + for itemname, number in pairs(craft.consumption) do if (not inv_index[itemname]) or inv_index[itemname] < number then return false end end + -- check if output and all replacements fit in dst + local output = craft.output.item + local out_items = count_index(craft.decremented_input.items) + out_items[output:get_name()] = (out_items[output:get_name()] or 0) + output:get_count() + local empty_count = 0 + for _,item in pairs(inventory:get_list("dst")) do + if item:is_empty() then + empty_count = empty_count + 1 + else + local name = item:get_name() + if out_items[name] then + out_items[name] = out_items[name] - item:get_free_space() + end + end + end + for _,count in pairs(out_items) do + if count > 0 then + empty_count = empty_count - 1 + end + end + if empty_count < 0 then + return false + end -- consume material - for itemname, number in pairs(consumption) do + for itemname, number in pairs(craft.consumption) do for _ = 1, number do -- We have to do that since remove_item does not work if count > stack_max inventory:remove_item("src", ItemStack(itemname)) end end - -- craft the result into the dst inventory and add any "replacements" as well - inventory:add_item("dst", output_item) + inventory:add_item("dst", output) for i = 1, 9 do inventory:add_item("dst", craft.decremented_input.items[i]) end @@ -176,7 +193,7 @@ local function update_meta(meta, enabled) local state = enabled and "on" or "off" meta:set_int("enabled", enabled and 1 or 0) local list_backgrounds = "" - if minetest.get_modpath("i3") then + if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then list_backgrounds = "style_type[box;colors=#666]" for i=0, 2 do for j=0, 2 do @@ -275,8 +292,8 @@ minetest.register_node("pipeworks:autocrafter", { description = S("Autocrafter"), drawtype = "normal", tiles = {"pipeworks_autocrafter.png"}, - groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1, dig_generic = 1, axey=5}, - _mcl_hardness=1.6, + groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1, dig_generic = 1, axey=1, handy=1, pickaxey=1}, + _mcl_hardness=0.8, tube = {insert_object = function(pos, node, stack, direction) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() diff --git a/common.lua b/common.lua index 1161ba6..3a45e91 100644 --- a/common.lua +++ b/common.lua @@ -168,6 +168,31 @@ function fs_helpers.get_inv(y) end end + table.insert(fs, "style_type[list;size="..size..";spacing="..spacing.."]") + table.insert(fs, "list[current_player;main;"..inv_x..","..(inv_y + 1.15)..";"..hotbar_len..","..(inv_size / hotbar_len)..";"..hotbar_len.."]") + elseif minetest.get_modpath("mcl_formspec") then + local inv_x = 0.22 + local inv_y = (y + 0.4) or 6.9 + local size, spacing = 1, 0.1 + local hotbar_len = 9 + local inv_size = hotbar_len * 4 + + table.insert(fs, "style_type[box;colors=#77777710,#77777710,#777,#777]") + + for i = 0, hotbar_len - 1 do + table.insert(fs, "box["..(i * size + inv_x + (i * spacing))..","..inv_y..";"..size..","..size..";]") + end + + table.insert(fs, "style_type[list;size="..size..";spacing="..spacing.."]") + table.insert(fs, "list[current_player;main;"..inv_x..","..inv_y..";"..hotbar_len..",1;]") + + table.insert(fs, "style_type[box;colors=#666]") + for i=0, 2 do + for j=0, hotbar_len - 1 do + table.insert(fs, "box["..0.2+(j*0.1)+(j*size)..","..(inv_y+size+spacing+0.05)+(i*0.1)+(i*size)..";"..size..","..size..";]") + end + end + table.insert(fs, "style_type[list;size="..size..";spacing="..spacing.."]") table.insert(fs, "list[current_player;main;"..inv_x..","..(inv_y + 1.15)..";"..hotbar_len..","..(inv_size / hotbar_len)..";"..hotbar_len.."]") else diff --git a/crafts.lua b/crafts.lua index 54e2d6a..dc9319b 100644 --- a/crafts.lua +++ b/crafts.lua @@ -16,18 +16,17 @@ local materials = { if minetest.get_modpath("mcl_core") then materials = { stone = "mcl_core:stone", - desert_stone = "mcl_core:sandstone2", + desert_stone = "mcl_core:redsandstone", desert_sand = "mcl_core:sand", - chest = "mcl_chests:chest_small", + chest = "mcl_chests:chest", steel_ingot = "mcl_core:iron_ingot", gold_ingot = "mcl_core:gold_ingot", - mese = "default:mese", - mese_crystal = "default:mese_crystal", + mese = "mesecons_torch:redstoneblock", + mese_crystal = "mesecons:redstone", mese_crystal_fragment = "mesecons:redstone", - teleporter = "default:mese", - -- Use iron where no equivalent - copper_ingot = "mcl_core:iron_ingot", - glass = "default:glass", + teleporter = "mesecons_torch:redstoneblock", + copper_ingot = "mcl_copper:copper_ingot", + glass = "mcl_core:glass", } elseif minetest.get_modpath("fl_ores") and minetest.get_modpath("fl_stone") then materials = { diff --git a/decorative_tubes.lua b/decorative_tubes.lua index 37ecec2..4893d0c 100644 --- a/decorative_tubes.lua +++ b/decorative_tubes.lua @@ -14,8 +14,8 @@ minetest.register_node("pipeworks:steel_block_embedded_tube", { }, paramtype = "light", paramtype2 = "facedir", - groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1, dig_glass = 2, pickaxey=5}, - _mcl_hardness=1.6, + groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1, dig_glass = 2, pickaxey=1, handy=1}, + _mcl_hardness=0.8, legacy_facedir_simple = true, _sound_def = { key = "node_sound_stone_defaults", @@ -63,8 +63,8 @@ minetest.register_node("pipeworks:steel_pane_embedded_tube", { collision_box = pane_box, paramtype = "light", paramtype2 = "facedir", - groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1, dig_glass = 2, pickaxey=5}, - _mcl_hardness=1.6, + groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1, dig_glass = 2, pickaxey=1, handy=1}, + _mcl_hardness=0.8, legacy_facedir_simple = true, _sound_def = { key = "node_sound_stone_defaults", diff --git a/devices.lua b/devices.lua index c5c9bf1..5384b7d 100644 --- a/devices.lua +++ b/devices.lua @@ -133,9 +133,9 @@ for s in ipairs(states) do local dgroups if states[s] == "off" then - dgroups = {snappy=3, pipe=1, dig_generic = 4, axey=5} + dgroups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1} else - dgroups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=5} + dgroups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1} end local pumpname = "pipeworks:pump_"..states[s] @@ -148,7 +148,7 @@ for s in ipairs(states) do paramtype = "light", paramtype2 = "facedir", groups = dgroups, - _mcl_hardness=1.6, + _mcl_hardness=0.8, _sound_def = { key = "node_sound_metal_defaults", }, @@ -203,7 +203,7 @@ for s in ipairs(states) do fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 } }, groups = dgroups, - _mcl_hardness = 1.6, + _mcl_hardness=0.8, _sound_def = { key = "node_sound_metal_defaults", }, @@ -253,8 +253,8 @@ minetest.register_node(nodename_valve_loaded, { type = "fixed", fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 } }, - groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=5}, - _mcl_hardness=1.6, + groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, + _mcl_hardness=0.8, _sound_def = { key = "node_sound_metal_defaults", }, @@ -306,8 +306,8 @@ minetest.register_node("pipeworks:grating", { }, sunlight_propagates = true, paramtype = "light", - groups = {snappy=3, pipe=1, dig_generic = 4, axey=5}, - _mcl_hardness=1.6, + groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, + _mcl_hardness=0.8, _sound_def = { key = "node_sound_metal_defaults", }, @@ -334,8 +334,8 @@ minetest.register_node(nodename_spigot_empty, { sunlight_propagates = true, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1, dig_generic = 4, axey=5}, - _mcl_hardness=1.6, + groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, + _mcl_hardness=0.8, _sound_def = { key = "node_sound_metal_defaults", }, @@ -372,8 +372,8 @@ minetest.register_node(nodename_spigot_loaded, { sunlight_propagates = true, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=5}, - _mcl_hardness=1.6, + groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, + _mcl_hardness=0.8, _sound_def = { key = "node_sound_metal_defaults", }, @@ -431,8 +431,8 @@ minetest.register_node(nodename_panel_empty, { tiles = { "pipeworks_entry_panel.png" }, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1, dig_generic = 4, axey=5}, - _mcl_hardness=1.6, + groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, + _mcl_hardness=0.8, _sound_def = { key = "node_sound_metal_defaults", }, @@ -454,8 +454,8 @@ minetest.register_node(nodename_panel_loaded, { tiles = { "pipeworks_entry_panel.png" }, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=5}, - _mcl_hardness=1.6, + groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, + _mcl_hardness=0.8, _sound_def = { key = "node_sound_metal_defaults", }, @@ -487,8 +487,8 @@ minetest.register_node(nodename_sensor_empty, { sunlight_propagates = true, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1, dig_generic = 4, axey=5}, - _mcl_hardness=1.6, + groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, + _mcl_hardness=0.8, _sound_def = { key = "node_sound_metal_defaults", }, @@ -529,8 +529,8 @@ minetest.register_node(nodename_sensor_loaded, { sunlight_propagates = true, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=5}, - _mcl_hardness=1.6, + groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, + _mcl_hardness=0.8, _sound_def = { key = "node_sound_metal_defaults", }, @@ -577,12 +577,12 @@ new_flow_logic_register.transition_simple_set(sensor_pressure_set, { mesecons=pi -- TODO flow-logic-stub: these don't currently do anything under the new flow logic. for fill = 0, 10 do local filldesc=S("empty") - local sgroups = {snappy=3, pipe=1, tankfill=fill+1, dig_generic = 4, axey=5} + local sgroups = {snappy=3, pipe=1, tankfill=fill+1, dig_generic = 4, axey=1, handy=1, pickaxey=1} local image = nil if fill ~= 0 then filldesc=S("@1% full", 10*fill) - sgroups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1, dig_generic = 4, axey=5} + sgroups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1} image = "pipeworks_storage_tank_fittings.png" end @@ -599,8 +599,8 @@ for fill = 0, 10 do inventory_image = image, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1, dig_generic = 4, axey=5}, - _mcl_hardness=1.6, + groups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, + _mcl_hardness=0.8, _sound_def = { key = "node_sound_metal_defaults", }, @@ -631,7 +631,7 @@ for fill = 0, 10 do paramtype = "light", paramtype2 = "facedir", groups = sgroups, - _mcl_hardness=1.6, + _mcl_hardness=0.8, _sound_def = { key = "node_sound_metal_defaults", }, @@ -660,8 +660,8 @@ minetest.register_node(nodename_fountain_empty, { tiles = { "pipeworks_fountainhead.png" }, sunlight_propagates = true, paramtype = "light", - groups = {snappy=3, pipe=1, dig_generic = 4, axey=5}, - _mcl_hardness=1.6, + groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, + _mcl_hardness=0.8, _sound_def = { key = "node_sound_metal_defaults", }, @@ -698,8 +698,8 @@ minetest.register_node(nodename_fountain_loaded, { tiles = { "pipeworks_fountainhead.png" }, sunlight_propagates = true, paramtype = "light", - groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=5}, - _mcl_hardness=1.6, + groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, + _mcl_hardness=0.8, _sound_def = { key = "node_sound_metal_defaults", }, @@ -751,8 +751,8 @@ minetest.register_node(nodename_sp_empty, { tiles = { "pipeworks_straight_pipe_empty.png" }, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1, dig_generic = 4, axey=5}, - _mcl_hardness=1.6, + groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, + _mcl_hardness=0.8, _sound_def = { key = "node_sound_metal_defaults", }, @@ -776,8 +776,8 @@ minetest.register_node(nodename_sp_loaded, { tiles = { "pipeworks_straight_pipe_loaded.png" }, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=5}, - _mcl_hardness=1.6, + groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, + _mcl_hardness=0.8, _sound_def = { key = "node_sound_metal_defaults", }, diff --git a/filter-injector.lua b/filter-injector.lua index ac98a62..22e8b86 100644 --- a/filter-injector.lua +++ b/filter-injector.lua @@ -38,7 +38,7 @@ local function set_filter_formspec(data, meta) end local size = "10.2,11" local list_backgrounds = "" - if minetest.get_modpath("i3") then + if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then list_backgrounds = "style_type[box;colors=#666]" for i=0, 7 do for j=0, 1 do @@ -388,8 +388,8 @@ for _, data in ipairs({ "pipeworks_"..data.name.."_top.png", }, paramtype2 = "facedir", - groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, mesecon = 2, axey=5}, - _mcl_hardness=1.6, + groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, mesecon = 2, axey=1, handy=1, pickaxey=1}, + _mcl_hardness=0.8, legacy_facedir_simple = true, _sound_def = { key = "node_sound_wood_defaults", diff --git a/init.lua b/init.lua index 8622c6f..2c21c84 100644 --- a/init.lua +++ b/init.lua @@ -182,6 +182,12 @@ if pipeworks.enable_redefines and (minetest.get_modpath("default") or minetest.g dofile(pipeworks.modpath.."/compat-chests.lua") dofile(pipeworks.modpath.."/compat-furnaces.lua") end +if pipeworks.enable_redefines and minetest.get_modpath("mcl_barrels") then + dofile(pipeworks.modpath.."/mcl_barrels.lua") +end +if pipeworks.enable_redefines and minetest.get_modpath("mcl_furnaces") then + dofile(pipeworks.modpath.."/mcl_furnaces.lua") +end if pipeworks.enable_autocrafter then dofile(pipeworks.modpath.."/autocrafter.lua") end @@ -198,7 +204,7 @@ minetest.register_alias("pipeworks:pipe", "pipeworks:pipe_110000_empty") -- Unified Inventory categories integration -if minetest.global_exists("unified_inventory") and unified_inventory.registered_categories then +if minetest.get_modpath("unified_inventory") and unified_inventory.registered_categories then if not unified_inventory.registered_categories["automation"] then unified_inventory.register_category("automation", { symbol = "pipeworks:lua_tube000000", diff --git a/legacy.lua b/legacy.lua index f45c375..fdaa0de 100644 --- a/legacy.lua +++ b/legacy.lua @@ -26,8 +26,8 @@ if not minetest.get_modpath("auto_tree_tap") and "pipeworks_nodebreaker_back.png","pipeworks_nodebreaker_front_off.png"}, is_ground_content = true, paramtype2 = "facedir", - groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, not_in_creative_inventory=1, axey=5}, - _mcl_hardness=1.6, + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, not_in_creative_inventory=1, axey=1, handy=1, pickaxey=1}, + _mcl_hardness=0.8, _sound_def = { key = "node_sound_stone_defaults", }, @@ -55,7 +55,6 @@ if not minetest.get_modpath("auto_tree_tap") and local node = minetest.get_node(pos) node.param2 = minetest.dir_to_facedir(dir, true) minetest.set_node(pos, node) - minetest.log("action", "real (6d) facedir: " .. node.param2) end end, after_dig_node = pipeworks.scan_for_tube_objects, diff --git a/lua_tube.lua b/lua_tube.lua index cae1bf3..7c02e9e 100644 --- a/lua_tube.lua +++ b/lua_tube.lua @@ -425,7 +425,7 @@ end -- itbl: Flat table of functions to run after sandbox cleanup, used to prevent various security hazards local function get_digiline_send(pos, itbl, send_warning) - if not minetest.global_exists("digilines") then return end + if not minetest.get_modpath("digilines") then return end local chan_maxlen = mesecon.setting("luacontroller_digiline_channel_maxlen", 256) local maxlen = mesecon.setting("luacontroller_digiline_maxlen", 50000) return function(channel, msg) @@ -865,7 +865,7 @@ for white = 0, 1 do tiles[3] = tiles[3]..tiles_on_off.R270:format(white == 1 and "on" or "off"); tiles[4] = tiles[4]..tiles_on_off.R_90:format(white == 1 and "on" or "off"); - local groups = {snappy = 3, tube = 1, tubedevice = 1, overheat = 1, dig_generic = 4, axey=5} + local groups = {snappy = 3, tube = 1, tubedevice = 1, overheat = 1, dig_generic = 4, axey=1, handy=1, pickaxey=1} if red + blue + yellow + green + black + white ~= 0 then groups.not_in_creative_inventory = 1 end @@ -912,7 +912,7 @@ for white = 0, 1 do paramtype = "light", is_ground_content = false, groups = groups, - _mcl_hardness=1.6, + _mcl_hardness=0.8, drop = BASENAME.."000000", sunlight_propagates = true, selection_box = selection_box, @@ -1024,8 +1024,8 @@ minetest.register_node(BASENAME .. "_burnt", { is_burnt = true, paramtype = "light", is_ground_content = false, - groups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory=1, dig_generic = 4, axey=5}, - _mcl_hardness=1.6, + groups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, + _mcl_hardness=0.8, drop = BASENAME.."000000", sunlight_propagates = true, selection_box = selection_box, diff --git a/luaentity.lua b/luaentity.lua index 9baea55..ef6d552 100644 --- a/luaentity.lua +++ b/luaentity.lua @@ -163,11 +163,15 @@ local entitydef_default = { if not is_active(entity_pos) then return end - local ent = minetest.add_entity(entity_pos, entity.name):get_luaentity() + local object = minetest.add_entity(entity_pos, entity.name) + if not object then + return + end + local ent = object:get_luaentity() ent:from_data(entity.data) ent.parent_id = self._id ent.attached_id = index - entity.entity = ent.object + entity.entity = object local master = self._attached_entities_master if master then self:_attach(index, master) diff --git a/mcl_barrels.lua b/mcl_barrels.lua new file mode 100644 index 0000000..423dab3 --- /dev/null +++ b/mcl_barrels.lua @@ -0,0 +1,72 @@ +-- this bit of code modifies the mcl barrels to be compatible with +-- pipeworks. + +-- Pipeworks Specific +local tube_entry = "^pipeworks_tube_connection_wooden.png" + +-- Original Definitions +local old_barrel = table.copy(minetest.registered_items["mcl_barrels:barrel_closed"]) + +local groups = old_barrel.groups +groups["tubedevice"] = 1 +groups["tubedevice_receiver"] = 1 +local groups_open = table.copy(groups) +groups_open["not_in_creative_inventory"] = 1 + + +-- Override Construction +local override_barrel = {} + +override_barrel.tiles = { + "mcl_barrels_barrel_top.png^[transformR270", + "mcl_barrels_barrel_bottom.png"..tube_entry, + "mcl_barrels_barrel_side.png"..tube_entry +} + +override_barrel.after_place_node = function(pos, placer, itemstack, pointed_thing) + old_barrel.after_place_node(pos, placer, itemstack, pointed_thing) + pipeworks.after_place(pos, placer, itemstack, pointed_thing) +end + +override_barrel.tube = { + insert_object = function(pos, node, stack, direction) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return inv:add_item("main", stack) + end, + can_insert = function(pos, node, stack, direction) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + if meta:get_int("splitstacks") == 1 then + stack = stack:peek_item(1) + end + return inv:room_for_item("main", stack) + end, + input_inventory = "main", + connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1} +} + +override_barrel.after_dig_node = function(pos, oldnode, oldmetadata, digger) + old_barrel.after_dig_node(pos, oldnode, oldmetadata, digger) + pipeworks.after_dig(pos) +end + +override_barrel.groups = table.copy(old_barrel.groups) + +override_barrel.on_rotate = pipeworks.on_rotate + + +local override_barrel_open = table.copy(override_barrel) + +override_barrel_open.tiles = { + "mcl_barrels_barrel_top_open.png", + "mcl_barrels_barrel_bottom.png"..tube_entry, + "mcl_barrels_barrel_side.png"..tube_entry +} + +override_barrel_open.groups = groups_open + + +-- Override with the new modifications. +minetest.override_item("mcl_barrels:barrel_closed", override_barrel) +minetest.override_item("mcl_barrels:barrel_open", override_barrel_open) diff --git a/mcl_furnaces.lua b/mcl_furnaces.lua new file mode 100644 index 0000000..e23a297 --- /dev/null +++ b/mcl_furnaces.lua @@ -0,0 +1,376 @@ + +local old_furnace = table.copy(minetest.registered_nodes["mcl_furnaces:furnace"]) +local old_blast_furnace = table.copy(minetest.registered_nodes["mcl_blast_furnace:blast_furnace"]) +local old_smoker = table.copy(minetest.registered_nodes["mcl_smoker:smoker"]) + +local tube_entry = "^pipeworks_tube_connection_stony.png" + +-- groups +local furnace_groups = old_furnace.groups +furnace_groups["tubedevice"] = 1 +furnace_groups["tubedevice_receiver"] = 1 +local furnace_groups_active = table.copy(furnace_groups) +furnace_groups_active["not_in_creative_inventory"] = 1 + +local blast_furnace_groups = old_blast_furnace.groups +blast_furnace_groups["tubedevice"] = 1 +blast_furnace_groups["tubedevice_receiver"] = 1 +local blast_furnace_groups_active = table.copy(blast_furnace_groups) +blast_furnace_groups_active["not_in_creative_inventory"] = 1 + +local smoker_groups = old_smoker.groups +smoker_groups["tubedevice"] = 1 +smoker_groups["tubedevice_receiver"] = 1 +local smoker_groups_active = table.copy(smoker_groups) +smoker_groups_active["not_in_creative_inventory"] = 1 + + +-- a hack to give the exp to fake players it's be dropped instead added to (fake) player inv +local function give_xp(pos, player) + local meta = minetest.get_meta(pos) + local dir = vector.divide(minetest.facedir_to_dir(minetest.get_node(pos).param2), -1.95) + local xp = meta:get_int("xp") + if xp > 0 then + mcl_experience.throw_xp(vector.add(pos, dir), xp) + meta:set_int("xp", 0) + end +end + +local override = {} + +override.tiles = { + "default_furnace_top.png"..tube_entry, + "default_furnace_bottom.png"..tube_entry, + "default_furnace_side.png"..tube_entry, + "default_furnace_side.png"..tube_entry, + "default_furnace_side.png"..tube_entry, + "default_furnace_front.png" +} + +override.groups = furnace_groups + +override.tube = { + insert_object = function(pos, node, stack, direction) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local timer = minetest.get_node_timer(pos) + if not timer:is_started() then + timer:start(1.0) + end + if direction.y == 1 then + return inv:add_item("fuel", stack) + else + return inv:add_item("src", stack) + end + end, + can_insert = function(pos,node,stack,direction) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + if direction.y == 1 then + return inv:room_for_item("fuel", stack) + else + if meta:get_int("split_material_stacks") == 1 then + stack = stack:peek_item(1) + end + return inv:room_for_item("src", stack) + end + end, + input_inventory = "dst", + connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1} +} + +override.after_place_node = function(pos, placer, itemstack, pointed_thing) + pipeworks.after_place(pos, placer, itemstack, pointed_thing) +end + +override.after_dig_node = function(pos, oldnode, oldmetadata, digger) + old_furnace.after_dig_node(pos, oldnode, oldmetadata, digger) + pipeworks.after_dig(pos) +end + +override.on_metadata_inventory_take = function(pos, listname, index, stack, player) + if listname == "dst" then + if stack:get_name() == "mcl_core:iron_ingot" then + awards.unlock(player:get_player_name(), "mcl:acquireIron") + elseif stack:get_name() == "mcl_fishing:fish_cooked" then + awards.unlock(player:get_player_name(), "mcl:cookFish") + end + give_xp(pos, player) + end +end + +override.on_rotate = pipeworks.on_rotate + + +local override_active = table.copy(override) + +override_active.tiles = { + "default_furnace_top.png"..tube_entry, + "default_furnace_bottom.png"..tube_entry, + "default_furnace_side.png"..tube_entry, + "default_furnace_side.png"..tube_entry, + "default_furnace_side.png"..tube_entry, + "default_furnace_front_active.png", +} + +override_active.groups = furnace_groups_active + +override_active.tube = { + insert_object = function(pos,node,stack,direction) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local timer = minetest.get_node_timer(pos) + if not timer:is_started() then + timer:start(1.0) + end + if direction.y == 1 then + return inv:add_item("fuel", stack) + else + return inv:add_item("src", stack) + end + end, + can_insert = function(pos, node, stack, direction) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + if direction.y == 1 then + return inv:room_for_item("fuel", stack) + else + return inv:room_for_item("src", stack) + end + end, + input_inventory = "dst", + connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1} +} + + +--blast furnace + +local override_blast_furnace = {} + +override_blast_furnace.tiles = { + "blast_furnace_top.png"..tube_entry, + "blast_furnace_top.png"..tube_entry, + "blast_furnace_side.png"..tube_entry, + "blast_furnace_side.png"..tube_entry, + "blast_furnace_side.png"..tube_entry, + "blast_furnace_front.png" +} + +override_blast_furnace.groups = blast_furnace_groups + +override_blast_furnace.tube = { + insert_object = function(pos, node, stack, direction) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local timer = minetest.get_node_timer(pos) + if not timer:is_started() then + timer:start(1.0) + end + if direction.y == 1 then + return inv:add_item("fuel", stack) + else + return inv:add_item("src", stack) + end + end, + can_insert = function(pos,node,stack,direction) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + if direction.y == 1 then + return inv:room_for_item("fuel", stack) + else + if meta:get_int("split_material_stacks") == 1 then + stack = stack:peek_item(1) + end + return inv:room_for_item("src", stack) + end + end, + input_inventory = "dst", + connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1} +} + +override_blast_furnace.after_place_node = function(pos, placer, itemstack, pointed_thing) + pipeworks.after_place(pos, placer, itemstack, pointed_thing) +end + +override_blast_furnace.after_dig_node = function(pos, oldnode, oldmetadata, digger) + old_blast_furnace.after_dig_node(pos, oldnode, oldmetadata, digger) + pipeworks.after_dig(pos) +end + +override_blast_furnace.on_metadata_inventory_take = function(pos, listname, index, stack, player) + -- Award smelting achievements + if listname == "dst" then + if stack:get_name() == "mcl_core:iron_ingot" then + awards.unlock(player:get_player_name(), "mcl:acquireIron") + end + give_xp(pos, player) + end +end + +override_blast_furnace.on_rotate = pipeworks.on_rotate + + +local override_blast_active = table.copy(override) + +override_blast_active.tiles = { + "blast_furnace_top.png"..tube_entry, + "blast_furnace_top.png"..tube_entry, + "blast_furnace_side.png"..tube_entry, + "blast_furnace_side.png"..tube_entry, + "blast_furnace_side.png"..tube_entry, + { + name = "blast_furnace_front_on.png", + animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 48 } + }, +} + +override_blast_active.groups = blast_furnace_groups_active + +override_blast_active.tube = { + insert_object = function(pos,node,stack,direction) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local timer = minetest.get_node_timer(pos) + if not timer:is_started() then + timer:start(1.0) + end + if direction.y == 1 then + return inv:add_item("fuel", stack) + else + return inv:add_item("src", stack) + end + end, + can_insert = function(pos, node, stack, direction) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + if direction.y == 1 then + return inv:room_for_item("fuel", stack) + else + return inv:room_for_item("src", stack) + end + end, + input_inventory = "dst", + connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1} +} + + +-- smoker + +local override_smoker = {} + +override_smoker.tiles = { + "smoker_top.png"..tube_entry, + "smoker_bottom.png"..tube_entry, + "smoker_side.png"..tube_entry, + "smoker_side.png"..tube_entry, + "smoker_side.png"..tube_entry, + "smoker_front.png" +} + +override_smoker.groups = smoker_groups + +override_smoker.tube = { + insert_object = function(pos, node, stack, direction) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local timer = minetest.get_node_timer(pos) + if not timer:is_started() then + timer:start(1.0) + end + if direction.y == 1 then + return inv:add_item("fuel", stack) + else + return inv:add_item("src", stack) + end + end, + can_insert = function(pos,node,stack,direction) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + if direction.y == 1 then + return inv:room_for_item("fuel", stack) + else + if meta:get_int("split_material_stacks") == 1 then + stack = stack:peek_item(1) + end + return inv:room_for_item("src", stack) + end + end, + input_inventory = "dst", + connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1} +} + +override_smoker.after_place_node = function(pos, placer, itemstack, pointed_thing) + pipeworks.after_place(pos, placer, itemstack, pointed_thing) +end + +override_smoker.after_dig_node = function(pos, oldnode, oldmetadata, digger) + old_smoker.after_dig_node(pos, oldnode, oldmetadata, digger) + pipeworks.after_dig(pos) +end + +override_smoker.on_metadata_inventory_take = function(pos, listname, index, stack, player) + -- Award fish achievements + if listname == "dst" then + if stack:get_name() == "mcl_fishing:fish_cooked" then + awards.unlock(player:get_player_name(), "mcl:cookFish") + end + give_xp(pos, player) + end +end + +override_smoker.on_rotate = pipeworks.on_rotate + + +local override_smoker_active = table.copy(override) + +override_smoker_active.tiles = { + "smoker_top.png"..tube_entry, + "smoker_bottom.png"..tube_entry, + "smoker_side.png"..tube_entry, + "smoker_side.png"..tube_entry, + "smoker_side.png"..tube_entry, + { + name = "smoker_front_on.png", + animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 48 } + }, +} + +override_smoker_active.groups = smoker_groups_active + +override_smoker_active.tube = { + insert_object = function(pos,node,stack,direction) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local timer = minetest.get_node_timer(pos) + if not timer:is_started() then + timer:start(1.0) + end + if direction.y == 1 then + return inv:add_item("fuel", stack) + else + return inv:add_item("src", stack) + end + end, + can_insert = function(pos, node, stack, direction) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + if direction.y == 1 then + return inv:room_for_item("fuel", stack) + else + return inv:room_for_item("src", stack) + end + end, + input_inventory = "dst", + connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1} +} + + +-- override +minetest.override_item("mcl_furnaces:furnace", override) +minetest.override_item("mcl_furnaces:furnace_active", override_active) + +minetest.override_item("mcl_blast_furnace:blast_furnace", override_blast_furnace) +minetest.override_item("mcl_blast_furnace:blast_furnace_active", override_blast_active) + +minetest.override_item("mcl_smoker:smoker", override_smoker) +minetest.override_item("mcl_smoker:smoker_active", override_smoker_active) diff --git a/mod.conf b/mod.conf index 51e0f95..c9dbf62 100644 --- a/mod.conf +++ b/mod.conf @@ -1,5 +1,5 @@ name = pipeworks description = This mod uses mesh nodes and nodeboxes to supply a complete set of 3D pipes and tubes, along with devices that work with them. depends = basic_materials -optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver, fl_mapgen, sound_api, i3, hades_core, hades_furnaces, hades_chests, mcl_mapgen_core +optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver, fl_mapgen, sound_api, i3, hades_core, hades_furnaces, hades_chests, mcl_mapgen_core, mcl_barrels, mcl_furnaces, mcl_experience min_minetest_version = 5.4.0 diff --git a/pipes.lua b/pipes.lua index 1e78417..8b9f01b 100644 --- a/pipes.lua +++ b/pipes.lua @@ -37,11 +37,11 @@ for index, connects in ipairs(cconnects) do end --]] - local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1, dig_generic = 4, axey=5} + local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1, dig_generic = 4, axey=1, handy=1, pickaxey=1} local pipedesc = S("Pipe Segment").." "..dump(connects) if #connects == 0 then - pgroups = {snappy = 3, tube = 1, dig_generic = 4, axey=5} + pgroups = {snappy = 3, tube = 1, dig_generic = 4, axey=1, handy=1, pickaxey=1} pipedesc = S("Pipe Segment") end @@ -76,7 +76,7 @@ for index, connects in ipairs(cconnects) do fixed = outsel }, groups = pgroups, - _mcl_hardness=1.6, + _mcl_hardness=0.8, _sound_def = { key = "node_sound_metal_defaults", }, @@ -94,7 +94,7 @@ for index, connects in ipairs(cconnects) do pipenumber = index }) - local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1, dig_generic = 4, axey=5} + local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1, dig_generic = 4, axey=1, handy=1, pickaxey=1} minetest.register_node("pipeworks:pipe_"..index.."_loaded", { description = pipedesc, @@ -113,7 +113,7 @@ for index, connects in ipairs(cconnects) do fixed = outsel }, groups = pgroups, - _mcl_hardness = 1.6, + _mcl_hardness=0.8, _sound_def = { key = "node_sound_metal_defaults", }, diff --git a/pressure_logic/abms.lua b/pressure_logic/abms.lua index 2675b7c..bf9c2db 100644 --- a/pressure_logic/abms.lua +++ b/pressure_logic/abms.lua @@ -353,7 +353,7 @@ end flowlogic.run_transition_post = function(pos, node) local mesecons_def = minetest.registered_nodes[node.name].mesecons local mesecons_rules = pipeworks.flowables.transitions.mesecons[node.name] - if minetest.global_exists("mesecon") and (mesecons_def ~= nil) and mesecons_rules then + if minetest.get_modpath("mesecons") and (mesecons_def ~= nil) and mesecons_rules then if type(mesecons_def) ~= "table" then pipeworks.logger("flowlogic.run_transition_post() BUG mesecons def for "..node.name.."not a table: got "..tostring(mesecons_def)) else diff --git a/routing_tubes.lua b/routing_tubes.lua index 4ea5c28..f6fec5e 100644 --- a/routing_tubes.lua +++ b/routing_tubes.lua @@ -97,7 +97,16 @@ pipeworks.register_tube("pipeworks:broken_tube", { pipeworks.logger(log_msg.." but original node "..was_node.name.." is not registered anymore.") minetest.chat_send_player(playername, S("This tube cannot be repaired.")) end - end + end, + allow_metadata_inventory_put = function() + return 0 + end, + allow_metadata_inventory_move = function() + return 0 + end, + allow_metadata_inventory_take = function() + return 0 + end, } }) @@ -168,8 +177,8 @@ if pipeworks.enable_one_way_tube then paramtype = "light", node_box = {type = "fixed", fixed = {{-1/2, -9/64, -9/64, 1/2, 9/64, 9/64}}}, - groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, tubedevice = 1, axey=5}, - _mcl_hardness=1.6, + groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, tubedevice = 1, axey=1, handy=1, pickaxey=1}, + _mcl_hardness=0.8, _sound_def = { key = "node_sound_wood_defaults", }, diff --git a/sorting_tubes.lua b/sorting_tubes.lua index d35308f..39a8686 100644 --- a/sorting_tubes.lua +++ b/sorting_tubes.lua @@ -24,7 +24,7 @@ if pipeworks.enable_mese_tube then ) end local list_backgrounds = "" - if minetest.get_modpath("i3") then + if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then list_backgrounds = "style_type[box;colors=#666]" for i=0, 5 do for j=0, 5 do diff --git a/teleport_tube.lua b/teleport_tube.lua index e888333..9439ddd 100644 --- a/teleport_tube.lua +++ b/teleport_tube.lua @@ -148,9 +148,11 @@ local function get_receivers(pos, channel) return receivers end -local help_text = S("Channels are public by default").."\n".. +local help_text = minetest.formspec_escape( + S("Channels are public by default").."\n".. S("Use : for fully private channels").."\n".. - S("Use \\; for private receivers") + S("Use ; for private receivers") +) local size = has_digilines and "8,5.9" or "8,4.4" diff --git a/trashcan.lua b/trashcan.lua index 7c3d4e9..29a4d08 100644 --- a/trashcan.lua +++ b/trashcan.lua @@ -10,8 +10,8 @@ minetest.register_node("pipeworks:trashcan", { "pipeworks_trashcan_side.png", "pipeworks_trashcan_side.png", }, - groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1, dig_generic = 4, axey=5}, - _mcl_hardness=1.6, + groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, + _mcl_hardness=0.8, tube = { insert_object = function(pos, node, stack, direction) return ItemStack("") @@ -23,7 +23,7 @@ minetest.register_node("pipeworks:trashcan", { local meta = minetest.get_meta(pos) local size = "10.2,9" local list_background = "" - if minetest.get_modpath("i3") then + if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then list_background = "style_type[box;colors=#666]box[4.5,2;1,1;]" end meta:set_string("formspec", diff --git a/tube_registration.lua b/tube_registration.lua index 0028623..b837cb8 100644 --- a/tube_registration.lua +++ b/tube_registration.lua @@ -61,13 +61,13 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e outimgs[vti[v]] = ends[v] end - local tgroups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory = 1, dig_generic = 4, axey=5} + local tgroups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory = 1, dig_generic = 4, axey=1, handy=1, pickaxey=1} local tubedesc = string.format("%s %s", desc, dump(connects)) local iimg = type(plain[1]) == "table" and plain[1].name or plain[1] local wscale = {x = 1, y = 1, z = 1} if #connects == 0 then - tgroups = {snappy = 3, tube = 1, tubedevice = 1, dig_generic = 4, axey=5} + tgroups = {snappy = 3, tube = 1, tubedevice = 1, dig_generic = 4, axey=1, handy=1, pickaxey=1} tubedesc = desc iimg=inv outimgs = { @@ -106,7 +106,7 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e fixed = outboxes }, groups = tgroups, - _mcl_hardness=1.6, + _mcl_hardness=0.8, _sound_def = { key = "node_sound_wood_defaults", }, diff --git a/wielder.lua b/wielder.lua index e24b8ce..0cc26f9 100644 --- a/wielder.lua +++ b/wielder.lua @@ -8,7 +8,7 @@ end local function set_wielder_formspec(data, meta) local size = "10.2,"..(7+data.wield_inv_height) local list_background = "" - if minetest.get_modpath("i3") then + if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then list_background = "style_type[box;colors=#666]" for i=0, data.wield_inv_height-1 do for j=0, data.wield_inv_width-1 do @@ -146,7 +146,7 @@ local function register_wielder(data) data.fixup_node = data.fixup_node or function (pos, node) end data.fixup_oldmetadata = data.fixup_oldmetadata or function (m) return m end for _, state in ipairs({ "off", "on" }) do - local groups = { snappy=2, choppy=2, oddly_breakable_by_hand=2, mesecon=2, tubedevice=1, tubedevice_receiver=1, axey=5 } + local groups = { snappy=2, choppy=2, oddly_breakable_by_hand=2, mesecon=2, tubedevice=1, tubedevice_receiver=1, axey=1, handy=1, pickaxey=1 } if state == "on" then groups.not_in_creative_inventory = 1 end local tile_images = {} for _, face in ipairs({ "top", "bottom", "side2", "side1", "back", "front" }) do @@ -225,7 +225,6 @@ local function register_wielder(data) local node = minetest.get_node(pos) node.param2 = minetest.dir_to_facedir(dir, true) minetest.set_node(pos, node) - minetest.log("action", "real (6d) facedir: " .. node.param2) end minetest.get_meta(pos):set_string("owner", placer:get_player_name()) end,