From 5786374fe311fe99ed6ed1a6118cd97d712f963f Mon Sep 17 00:00:00 2001 From: crabman77 Date: Wed, 12 Apr 2017 20:34:59 +0200 Subject: [PATCH 1/5] fix nodes have not footstep sound --- mods/colouredstonebricks/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/colouredstonebricks/init.lua b/mods/colouredstonebricks/init.lua index d686490a..4ea99355 100755 --- a/mods/colouredstonebricks/init.lua +++ b/mods/colouredstonebricks/init.lua @@ -47,7 +47,7 @@ for number = 1, 15 do description = colour.." Stone Brick", tiles = {"colouredstonebricks_"..colour2..".png"}, groups = {cracky=3}, - sounds = default.node_sound_defaults(), + sounds = default.node_sound_stone_defaults(), }) minetest.register_craft({ @@ -64,7 +64,7 @@ for number = 1, 15 do description = colour.." Stone Brick", tiles = {"colouredstonebricks_"..colour2..".png"}, groups = {cracky=3}, - sounds = default.node_sound_defaults(), + sounds = default.node_sound_stone_defaults(), sunlight_propagates = true, }) end From 4cbd20d9fd4d7e7a5c9f9519363507e139a9d8c3 Mon Sep 17 00:00:00 2001 From: sys4-fr Date: Fri, 14 Apr 2017 22:32:13 +0200 Subject: [PATCH 2/5] Update autocrafter from pipeworks to be digilinized --- mods/pipeworks/autocrafter.lua | 82 +++++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 22 deletions(-) diff --git a/mods/pipeworks/autocrafter.lua b/mods/pipeworks/autocrafter.lua index faf53815..d471910b 100755 --- a/mods/pipeworks/autocrafter.lua +++ b/mods/pipeworks/autocrafter.lua @@ -102,6 +102,7 @@ local function after_recipe_change(pos, inventory) minetest.get_node_timer(pos):stop() autocrafterCache[minetest.hash_node_position(pos)] = nil meta:set_string("infotext", "unconfigured Autocrafter") + inventory:set_stack("output", 1, "") return end local recipe_changed = false @@ -171,27 +172,29 @@ end local function update_meta(meta, enabled) local state = enabled and "on" or "off" meta:set_int("enabled", enabled and 1 or 0) - meta:set_string("formspec", - "size[8,11]".. - "list[context;recipe;0,0;3,3;]".. - "image[3,1;1,1;gui_hb_bg.png^[colorize:#141318:255]".. - "list[context;output;3,1;1,1;]".. - "image_button[3,2;1,1;pipeworks_button_" .. state .. ".png;" .. state .. ";;;false;pipeworks_button_interm.png]" .. - "list[context;src;0,3.5;8,3;]".. - "list[context;dst;4,0;4,3;]".. - default.gui_bg.. - default.gui_bg_img.. - default.gui_slots.. - default.get_hotbar_bg(0,7) .. - "list[current_player;main;0,7;8,4;]" .. - "listring[current_player;main]".. - "listring[context;src]" .. - "listring[context;dst]" .. - "listring[current_player;main]".. - "listring[context;recipe]" .. - "listring[context;output]" - ) - + local fs = "size[8,11]".. + "list[context;recipe;0,0;3,3;]".. + "image[3,1;1,1;gui_hb_bg.png^[colorize:#141318:255]".. + "list[context;output;3,1;1,1;]".. + "image_button[3,2;1,0.6;pipeworks_button_" .. state .. ".png;" .. state .. ";;;false;pipeworks_button_interm.png]" .. + "list[context;src;0,4.5;8,3;]".. + "list[context;dst;4,0;4,3;]".. + default.gui_bg.. + default.gui_bg_img.. + default.gui_slots.. + default.get_hotbar_bg(0,8) .. + "list[current_player;main;0,8;8,4;]" .. + "listring[current_player;main]".. + "listring[context;src]" .. + "listring[current_player;main]".. + "listring[context;dst]" .. + "listring[current_player;main]" + if minetest.get_modpath("digilines") then + fs = fs.."field[1,3.5;4,1;channel;Channel;${channel}]" + fs = fs.."button_exit[5,3.2;2,1;save;Save]" + end + meta:set_string("formspec",fs) + -- toggling the button doesn't quite call for running a recipe change check -- so instead we run a minimal version for infotext setting only -- this might be more written code, but actually executes less @@ -282,6 +285,8 @@ minetest.register_node("pipeworks:autocrafter", { if update_meta(meta, true) then start_crafter(pos) end + elseif fields.save then + meta:set_string("channel", fields.channel) end end, can_dig = function(pos, player) @@ -362,7 +367,40 @@ minetest.register_node("pipeworks:autocrafter", { after_inventory_change(pos) return count end, - on_timer = run_autocrafter + on_timer = run_autocrafter, + digiline = { + receptor = {}, + effector = { + action = function(pos,node,channel,msg) + local meta = minetest.get_meta(pos) + if channel ~= meta:get_string("channel") then return end + if type(msg) == "table" then + if #msg < 3 then return end + local inv = meta:get_inventory() + for y=0,2,1 do + for x=1,3,1 do + local slot = y*3+x + if minetest.registered_items[msg[y+1][x]] then + inv:set_stack("recipe",slot,ItemStack(msg[y+1][x])) + else + inv:set_stack("recipe",slot,ItemStack("")) + end + end + end + after_recipe_change(pos,inv) + elseif msg == "off" then + update_meta(meta, false) + minetest.get_node_timer(pos):stop() + elseif msg == "on" then + if update_meta(meta, true) then + start_crafter(pos) + end + elseif msg == "single" then + run_autocrafter(pos,1) + end + end, + }, + }, }) minetest.register_craft( { From ef69f1d88c595f8b20d7e8d8aeb4d2d3be0216e0 Mon Sep 17 00:00:00 2001 From: sys4-fr Date: Fri, 14 Apr 2017 22:40:27 +0200 Subject: [PATCH 3/5] Add superquarry machine (made by Cyberpangolin) --- mods/nalc/init.lua | 3 + mods/nalc/technic/superquarry.lua | 269 ++++++++++++++++++++++++++++++ 2 files changed, 272 insertions(+) create mode 100644 mods/nalc/technic/superquarry.lua diff --git a/mods/nalc/init.lua b/mods/nalc/init.lua index ab0d0354..ec413086 100644 --- a/mods/nalc/init.lua +++ b/mods/nalc/init.lua @@ -236,4 +236,7 @@ if minetest.get_modpath("technic") then register_dust("Mithril", "default:mithril_ingot") register_dust("Silver", "default:silver_ingot") register_dust("Tin", "default:tin_ingot") + + -- Add superquarry machine + dofile(get_modpath(minetest.get_current_modname()).."/technic/superquarry.lua") end diff --git a/mods/nalc/technic/superquarry.lua b/mods/nalc/technic/superquarry.lua new file mode 100644 index 00000000..5831b506 --- /dev/null +++ b/mods/nalc/technic/superquarry.lua @@ -0,0 +1,269 @@ + +local S = technic.getter + +local tube_entry = "^pipeworks_tube_connection_metallic.png" +local cable_entry = "^technic_cable_connection_overlay.png" + +minetest.register_craft({ + recipe = { + {"default:mithrilblock", "pipeworks:filter", "default:mithrilblock"}, + {"technic:motor", "technic:quarry", "technic:diamond_drill_head"}, + {"technic:quarry", "technic:hv_cable", "technic:quarry"}}, + output = "technic:superquarry", +}) + +local superquarry_dig_above_nodes = 3 -- How far above the superquarry we will dig nodes +local superquarry_max_depth = 2500 +local superquarry_demand = 20000 +local superquarry_eject_dir = vector.new(0, 1, 0) + +local function set_superquarry_formspec(meta) + local radius = meta:get_int("size") + local formspec = "size[6,4.3]".. + "list[context;cache;0,1;4,3;]".. + "item_image[4.8,0;1,1;technic:superquarry]".. + "label[0,0.2;"..S("%s superquarry"):format("HV").."]".. + "field[4.3,3.5;2,1;size;"..S("Radius:")..";"..radius.."]" + if meta:get_int("enabled") == 0 then + formspec = formspec.."button[4,1;2,1;enable;"..S("Disabled").."]" + else + formspec = formspec.."button[4,1;2,1;disable;"..S("Enabled").."]" + end + local diameter = radius*2 + 1 + local nd = meta:get_int("dug") + local rel_y = superquarry_dig_above_nodes - math.floor(nd / (diameter*diameter)) + formspec = formspec.."label[0,4;"..minetest.formspec_escape( + nd == 0 and S("Digging not started") or + (rel_y < -superquarry_max_depth and S("Digging finished") or + (meta:get_int("purge_on") == 1 and S("Purging cache") or + S("Digging %d m "..(rel_y > 0 and "above" or "below").." machine") + :format(math.abs(rel_y)))) + ).."]" + formspec = formspec.."button[4,2;2,1;restart;"..S("Restart").."]" + meta:set_string("formspec", formspec) +end + +local function set_superquarry_demand(meta) + local radius = meta:get_int("size") + local diameter = radius*2 + 1 + local machine_name = S("%s superquarry"):format("HV") + if meta:get_int("enabled") == 0 or meta:get_int("purge_on") == 1 then + meta:set_string("infotext", S(meta:get_int("purge_on") == 1 and "%s purging cache" or "%s Disabled"):format(machine_name)) + meta:set_int("HV_EU_demand", 0) + elseif meta:get_int("dug") == diameter*diameter * (superquarry_dig_above_nodes+1+superquarry_max_depth) then + meta:set_string("infotext", S("%s Finished"):format(machine_name)) + meta:set_int("HV_EU_demand", 0) + else + meta:set_string("infotext", S(meta:get_int("HV_EU_input") >= superquarry_demand and "%s Active" or "%s Unpowered"):format(machine_name)) + meta:set_int("HV_EU_demand", superquarry_demand) + end +end + +local function superquarry_receive_fields(pos, formname, fields, sender) + local meta = minetest.get_meta(pos) + if fields.size and string.find(fields.size, "^[0-17]+$") then + local size = tonumber(fields.size) + if size >= 2 and size <= 16 and size ~= meta:get_int("size") then + meta:set_int("size", size) + meta:set_int("dug", 0) + end + end + if fields.enable then meta:set_int("enabled", 1) end + if fields.disable then meta:set_int("enabled", 0) end + if fields.restart then + meta:set_int("dug", 0) + meta:set_int("purge_on", 1) + end + set_superquarry_formspec(meta) + set_superquarry_demand(meta) +end + +local function superquarry_handle_purge(pos) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local i = 0 + for _,stack in ipairs(inv:get_list("cache")) do + i = i + 1 + if stack then + local item = stack:to_table() + if item then + technic.tube_inject_item(pos, pos, superquarry_eject_dir, item) + stack:clear() + inv:set_stack("cache", i, stack) + break + end + end + end + if inv:is_empty("cache") then + meta:set_int("purge_on", 0) + end +end + +local function superquarry_run(pos, node) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + -- initialize cache for the case we load an older world + inv:set_size("cache", 12) + -- toss a coin whether we do an automatic purge. Chance 1:100 + local purge_rand = math.random() + if purge_rand <= 0.01 then + meta:set_int("purge_on", 1) + end + + if meta:get_int("enabled") and meta:get_int("HV_EU_input") >= superquarry_demand and meta:get_int("purge_on") == 0 then + local pdir = minetest.facedir_to_dir(node.param2) + local qdir = pdir.x == 1 and vector.new(0,0,-1) or + (pdir.z == -1 and vector.new(-1,0,0) or + (pdir.x == -1 and vector.new(0,0,1) or + vector.new(1,0,0))) + local radius = meta:get_int("size") + local diameter = radius*2 + 1 + local startpos = vector.add(vector.add(vector.add(pos, + vector.new(0, superquarry_dig_above_nodes, 0)), + pdir), + vector.multiply(qdir, -radius)) + local endpos = vector.add(vector.add(vector.add(startpos, + vector.new(0, -superquarry_dig_above_nodes-superquarry_max_depth, 0)), + vector.multiply(pdir, diameter-1)), + vector.multiply(qdir, diameter-1)) + local vm = VoxelManip() + local minpos, maxpos = vm:read_from_map(startpos, endpos) + local area = VoxelArea:new({MinEdge=minpos, MaxEdge=maxpos}) + local data = vm:get_data() + local c_air = minetest.get_content_id("air") + local owner = meta:get_string("owner") + local nd = meta:get_int("dug") + while nd ~= diameter*diameter * (superquarry_dig_above_nodes+1+superquarry_max_depth) do + local ry = math.floor(nd / (diameter*diameter)) + local ndl = nd % (diameter*diameter) + if ry % 2 == 1 then + ndl = diameter*diameter - 1 - ndl + end + local rq = math.floor(ndl / diameter) + local rp = ndl % diameter + if rq % 2 == 1 then rp = diameter - 1 - rp end + local digpos = vector.add(vector.add(vector.add(startpos, + vector.new(0, -ry, 0)), + vector.multiply(pdir, rp)), + vector.multiply(qdir, rq)) + local can_dig = true + if can_dig and minetest.is_protected and minetest.is_protected(digpos, owner) then + can_dig = false + end + local dignode + if can_dig then + dignode = technic.get_or_load_node(digpos) or minetest.get_node(digpos) + local dignodedef = minetest.registered_nodes[dignode.name] or {diggable=false} + if not dignodedef.diggable or (dignodedef.can_dig and not dignodedef.can_dig(digpos, nil)) then + can_dig = false + end + end + + if can_dig then + for ay = startpos.y, digpos.y+1, -1 do + local checkpos = {x=digpos.x, y=ay, z=digpos.z} + local checknode = technic.get_or_load_node(checkpos) or minetest.get_node(checkpos) + if checknode.name ~= "air" then + can_dig = false + break + end + end + end + nd = nd + 1 + if can_dig then + minetest.remove_node(digpos) + local drops = minetest.get_node_drops(dignode.name, "") + for _, dropped_item in ipairs(drops) do + local left = inv:add_item("cache", dropped_item) + while not left:is_empty() do + meta:set_int("purge_on", 1) + superquarry_handle_purge(pos) + left = inv:add_item("cache", left) + end + end + break + end + end + if nd == diameter*diameter * (superquarry_dig_above_nodes+1+superquarry_max_depth) then + -- if a superquarry is finished, we enable purge mode + meta:set_int("purge_on", 1) + end + meta:set_int("dug", nd) + else + -- if a superquarry is disabled or has no power, we enable purge mode + meta:set_int("purge_on", 1) + end + -- if something triggered a purge, we handle it + if meta:get_int("purge_on") == 1 then + superquarry_handle_purge(pos) + end + set_superquarry_formspec(meta) + set_superquarry_demand(meta) +end + +local function send_move_error(player) + minetest.chat_send_player(player:get_player_name(), + S("Manually taking/removing from cache by hand is not possible. ".. + "If you can't wait, restart or disable the superquarry to start automatic purge.")) + return 0 +end + +minetest.register_node("technic:superquarry", { + description = S("%s superquarry"):format("HV"), + tiles = { + "default_obsidian_block.png"..tube_entry, + "default_obsidian_block.png"..cable_entry, + "default_obsidian_block.png"..cable_entry, + "default_obsidian_block.png"..cable_entry, + "default_obsidian_block.png^default_tool_mesepick.png", + "default_obsidian_block.png"..cable_entry + }, + paramtype2 = "facedir", + groups = {cracky=2, tubedevice=1, technic_machine=1, technic_hv=1}, + connect_sides = {"bottom", "front", "left", "right"}, + tube = { + connect_sides = {top = 1}, + -- lower priority than other tubes, so that quarries will prefer any + -- other tube to another superquarry, which could lead to server freezes + -- in certain superquarry placements (2x2 for example would never eject) + priority = 10, + can_go = function(pos, node, velocity, stack) + -- always eject the same, even if items came in another way + -- this further mitigates loops and generally avoids random sideway movement + -- that can be expected in certain superquarry placements + return { superquarry_eject_dir } + end + }, + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("infotext", S("%s superquarry"):format("HV")) + meta:set_int("size", 4) + set_superquarry_formspec(meta) + set_superquarry_demand(meta) + end, + after_place_node = function(pos, placer, itemstack) + local meta = minetest.get_meta(pos) + meta:set_string("owner", placer:get_player_name()) + pipeworks.scan_for_tube_objects(pos) + end, + can_dig = function(pos,player) + local meta = minetest.get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("cache") + end, + after_dig_node = pipeworks.scan_for_tube_objects, + on_receive_fields = superquarry_receive_fields, + technic_run = superquarry_run, + allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + return send_move_error(player) + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + return send_move_error(player) + end, + allow_metadata_inventory_take = function(pos, listname, index, stack, player) + return send_move_error(player) + end +}) + +technic.register_machine("HV", "technic:superquarry", technic.receiver) + From cc86e42a5bc8d46cb9f1f5b76e78caf59ca58a23 Mon Sep 17 00:00:00 2001 From: sys4-fr Date: Fri, 14 Apr 2017 22:44:06 +0200 Subject: [PATCH 4/5] Fix nalc mod --- mods/nalc/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/nalc/init.lua b/mods/nalc/init.lua index ec413086..74e2c277 100644 --- a/mods/nalc/init.lua +++ b/mods/nalc/init.lua @@ -238,5 +238,5 @@ if minetest.get_modpath("technic") then register_dust("Tin", "default:tin_ingot") -- Add superquarry machine - dofile(get_modpath(minetest.get_current_modname()).."/technic/superquarry.lua") + dofile(minetest.get_modpath(minetest.get_current_modname()).."/technic/superquarry.lua") end From e112cd3867b0d7b7f9e94a0587d654100d1e4c4c Mon Sep 17 00:00:00 2001 From: sys4-fr Date: Fri, 14 Apr 2017 22:57:44 +0200 Subject: [PATCH 5/5] Fix superquarry.lua file --- mods/nalc/technic/superquarry.lua | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/mods/nalc/technic/superquarry.lua b/mods/nalc/technic/superquarry.lua index 5831b506..6a255e68 100644 --- a/mods/nalc/technic/superquarry.lua +++ b/mods/nalc/technic/superquarry.lua @@ -9,7 +9,7 @@ minetest.register_craft({ {"default:mithrilblock", "pipeworks:filter", "default:mithrilblock"}, {"technic:motor", "technic:quarry", "technic:diamond_drill_head"}, {"technic:quarry", "technic:hv_cable", "technic:quarry"}}, - output = "technic:superquarry", + output = "nalc:superquarry", }) local superquarry_dig_above_nodes = 3 -- How far above the superquarry we will dig nodes @@ -21,7 +21,7 @@ local function set_superquarry_formspec(meta) local radius = meta:get_int("size") local formspec = "size[6,4.3]".. "list[context;cache;0,1;4,3;]".. - "item_image[4.8,0;1,1;technic:superquarry]".. + "item_image[4.8,0;1,1;nalc:superquarry]".. "label[0,0.2;"..S("%s superquarry"):format("HV").."]".. "field[4.3,3.5;2,1;size;"..S("Radius:")..";"..radius.."]" if meta:get_int("enabled") == 0 then @@ -61,7 +61,7 @@ end local function superquarry_receive_fields(pos, formname, fields, sender) local meta = minetest.get_meta(pos) - if fields.size and string.find(fields.size, "^[0-17]+$") then + if fields.size and string.find(fields.size, "^[0-9]+$") then local size = tonumber(fields.size) if size >= 2 and size <= 16 and size ~= meta:get_int("size") then meta:set_int("size", size) @@ -106,7 +106,7 @@ local function superquarry_run(pos, node) inv:set_size("cache", 12) -- toss a coin whether we do an automatic purge. Chance 1:100 local purge_rand = math.random() - if purge_rand <= 0.01 then + if purge_rand <= 0.005 then meta:set_int("purge_on", 1) end @@ -208,16 +208,20 @@ local function send_move_error(player) return 0 end -minetest.register_node("technic:superquarry", { +minetest.register_node("nalc:superquarry", { description = S("%s superquarry"):format("HV"), tiles = { - "default_obsidian_block.png"..tube_entry, - "default_obsidian_block.png"..cable_entry, - "default_obsidian_block.png"..cable_entry, - "default_obsidian_block.png"..cable_entry, - "default_obsidian_block.png^default_tool_mesepick.png", - "default_obsidian_block.png"..cable_entry + "default_mithril_block.png", + "default_mithril_block.png", + "default_mithril_block.png", + "default_mithril_block.png", + "default_mithril_block.png^default_tool_mesepick.png", + "default_mithril_block.png" }, + inventory_image = minetest.inventorycube( + "default_mithril_block.png", + "default_mithril_block.png^default_tool_mesepick.png", + "default_mithril_block.png"), paramtype2 = "facedir", groups = {cracky=2, tubedevice=1, technic_machine=1, technic_hv=1}, connect_sides = {"bottom", "front", "left", "right"}, @@ -237,7 +241,7 @@ minetest.register_node("technic:superquarry", { on_construct = function(pos) local meta = minetest.get_meta(pos) meta:set_string("infotext", S("%s superquarry"):format("HV")) - meta:set_int("size", 4) + meta:set_int("size", 8) set_superquarry_formspec(meta) set_superquarry_demand(meta) end, @@ -265,5 +269,5 @@ minetest.register_node("technic:superquarry", { end }) -technic.register_machine("HV", "technic:superquarry", technic.receiver) +technic.register_machine("HV", "nalc:superquarry", technic.receiver)