diff --git a/doc.lua b/doc.lua index 220fd21..b12f262 100644 --- a/doc.lua +++ b/doc.lua @@ -196,6 +196,17 @@ digtron.doc.power_connector_usagehelp = S("A power connector node automatically --------------------------------------------------------------------- +digtron.doc.inventory_ejector_longdesc = S("An outlet that can be used to eject accumulated detritus from a Digtron's inventory.") +digtron.doc.inventory_ejector_usagehelp = S("When this block is right-clicked it will search the entire inventory of the Digtron and will eject a stack of items taken from it, provided the items are not set for use by any of the Digtron's builders. Will not eject if the destination block is occupied.") + +if pipeworks_enabled then + digtron.doc.inventory_ejector_usagehelp = digtron.doc.inventory_ejector_usagehelp + .."\n\n".. + S("Item ejectors are compatible with pipeworks and will automatically connect to a pipeworks tube if one is adjacent in the output location.") +end + +--------------------------------------------------------------------- + digtron.doc.structure_longdesc = S("Structural component for a Digtron array") digtron.doc.structure_usagehelp = S("These blocks allow otherwise-disconnected sections of digtron blocks to be linked together. They are not usually necessary for simple diggers but more elaborate builder arrays might have builder blocks that can't be placed directly adjacent to other digtron blocks and these blocks can serve to keep them connected to the controller." .."\n\n".. diff --git a/init.lua b/init.lua index 5e93454..981bb39 100644 --- a/init.lua +++ b/init.lua @@ -31,16 +31,19 @@ dofile( digtron_modpath .. "/class_layout.lua" ) dofile( digtron_modpath .. "/entities.lua" ) dofile( digtron_modpath .. "/nodes/node_misc.lua" ) -- contains structure and light nodes dofile( digtron_modpath .. "/nodes/node_storage.lua" ) -- contains inventory and fuel storage nodes -dofile( digtron_modpath .. "/nodes/node_battery_holder.lua" ) -- holds rechargeable batteries from the technic mod dofile( digtron_modpath .. "/nodes/node_diggers.lua" ) -- contains all diggers dofile( digtron_modpath .. "/nodes/node_builders.lua" ) -- contains all builders (there's just one currently) dofile( digtron_modpath .. "/nodes/node_controllers.lua" ) -- controllers dofile( digtron_modpath .. "/nodes/node_axle.lua" ) -- Rotation controller dofile( digtron_modpath .. "/nodes/node_crate.lua" ) -- Digtron portability support -dofile( digtron_modpath .. "/nodes/recipes.lua" ) +dofile( digtron_modpath .. "/nodes/node_item_ejector.lua" ) -- ejects non-building, non-fuel items from inventories +--Technic +dofile( digtron_modpath .. "/nodes/node_battery_holder.lua" ) -- holds rechargeable batteries from the technic mod dofile( digtron_modpath .. "/nodes/node_power_connector.lua") +dofile( digtron_modpath .. "/nodes/recipes.lua" ) + dofile( digtron_modpath .. "/upgrades.lua" ) -- various LBMs for upgrading older versions of Digtron. -- digtron group numbers: diff --git a/nodes/node_item_ejector.lua b/nodes/node_item_ejector.lua new file mode 100644 index 0000000..ef016b7 --- /dev/null +++ b/nodes/node_item_ejector.lua @@ -0,0 +1,82 @@ +-- internationalization boilerplate +local MP = minetest.get_modpath(minetest.get_current_modname()) +local S, NS = dofile(MP.."/intllib.lua") + +local pipeworks_path = minetest.get_modpath("pipeworks") + +minetest.register_node("digtron:inventory_ejector", { + description = S("Digtron Inventory Ejector"), + _doc_items_longdesc = digtron.doc.inventory_ejector_longdesc, + _doc_items_usagehelp = digtron.doc.inventory_ejector_usagehelp, + groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 1, tubedevice = 1}, + tiles = {"digtron_plate.png", "digtron_plate.png", "digtron_plate.png", "digtron_plate.png", "digtron_plate.png^digtron_output.png", "digtron_plate.png"}, + drawtype = "nodebox", + sounds = digtron.metal_sounds, + paramtype = "light", + paramtype2 = "facedir", + is_ground_content = false, + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0.5, 0.1875}, -- NodeBox1 + {-0.3125, -0.3125, 0.1875, 0.3125, 0.3125, 0.3125}, -- NodeBox2 + {-0.1875, -0.1875, 0.3125, 0.1875, 0.1875, 0.5}, -- NodeBox3 + } + }, + + tube = (function() if pipeworks_path then return { + connect_sides = {back = 1} + } end end)(), + + on_rightclick = function(pos, node, player) + local dir = minetest.facedir_to_dir(node.param2) + local destination_pos = vector.add(pos, dir) + local destination_node_name = minetest.get_node(destination_pos).name + local destination_node_def = minetest.registered_nodes[destination_node_name] + local layout = DigtronLayout.create(pos, player) + + -- Build a list of all the items that builder nodes want to use. + local filter_items = {} + for _, node_image in pairs(layout.builders) do + filter_items[node_image.meta.inventory.main[1]:get_name()] = true + end + + -- Look through the inventories and find an item that's not on that list. + local source_node = nil + local source_index = nil + local source_stack = nil + for _, node_image in pairs(layout.inventories) do + for index, item_stack in pairs(node_image.meta.inventory.main) do + if item_stack:get_count() > 0 and not filter_items[item_stack:get_name()] then + source_node = node_image + source_index = index + source_stack = item_stack + break + end + end + if source_node then break end + end + + if source_node then + local meta = minetest.get_meta(source_node.pos) + local inv = meta:get_inventory() + + if pipeworks_path and minetest.get_node_group(destination_node_name, "tubedevice") > 0 then + local from_pos = vector.add(pos, vector.multiply(dir, 0.5)) + local start_pos = pos--vector.add(pos, dir) + inv:set_stack("main", source_index, nil) + pipeworks.tube_inject_item(from_pos, start_pos, vector.multiply(dir, 1), source_stack, player:get_player_name()) + minetest.sound_play("steam_puff", {gain=0.5, pos=pos}) + elseif destination_node_def and not destination_node_def.walkable then + minetest.add_item(destination_pos, source_stack) + inv:set_stack("main", source_index, nil) + minetest.sound_play("steam_puff", {gain=0.5, pos=pos}) + else + minetest.sound_play("buzzer", {gain=0.5, pos=pos}) + end + end + end, + + after_place_node = (function() if pipeworks_path then return pipeworks.after_place end end)(), + after_dig_node = (function() if pipeworks_path then return pipeworks.after_dig end end)() +}) diff --git a/nodes/node_misc.lua b/nodes/node_misc.lua index e847045..cea823e 100644 --- a/nodes/node_misc.lua +++ b/nodes/node_misc.lua @@ -52,7 +52,7 @@ minetest.register_node("digtron:light", { node_box = { type = "wallmounted", wall_top = {-0.25, 0.3125, -0.25, 0.25, 0.5, 0.25}, - wall_bottom = {-0.25, -0.3125, -0.25, 0.25, -0.5, 0.25}, + wall_bottom = {-0.25, -0.5, -0.25, 0.25, -0.3125, 0.25}, wall_side = {-0.5, -0.25, -0.25, -0.1875, 0.25, 0.25}, }, }) diff --git a/nodes/node_storage.lua b/nodes/node_storage.lua index fccf28a..123104e 100644 --- a/nodes/node_storage.lua +++ b/nodes/node_storage.lua @@ -2,6 +2,7 @@ local MP = minetest.get_modpath(minetest.get_current_modname()) local S, NS = dofile(MP.."/intllib.lua") +local pipeworks_path = minetest.get_modpath("pipeworks") local inventory_formspec = "size[8,9.3]" .. @@ -55,7 +56,7 @@ minetest.register_node("digtron:inventory", { -- Pipeworks compatibility ---------------------------------------------------------------- - tube = (function() if minetest.get_modpath("pipeworks") then return { + tube = (function() if pipeworks_path then return { insert_object = function(pos, node, stack, direction) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -70,8 +71,8 @@ minetest.register_node("digtron:inventory", { connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1} } end end)(), - after_place_node = (function() if minetest.get_modpath("pipeworks") then return pipeworks.after_place end end)(), - after_dig_node = (function() if minetest.get_modpath("pipeworks") then return pipeworks.after_dig end end)() + after_place_node = (function() if pipeworks_path then return pipeworks.after_place end end)(), + after_dig_node = (function() if pipeworks_path then return pipeworks.after_dig end end)() }) local fuelstore_formspec = @@ -138,7 +139,7 @@ minetest.register_node("digtron:fuelstore", { -- Pipeworks compatibility ---------------------------------------------------------------- - tube = (function() if minetest.get_modpath("pipeworks") then return { + tube = (function() if pipeworks_path then return { insert_object = function(pos, node, stack, direction) if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then local meta = minetest.get_meta(pos) @@ -159,8 +160,8 @@ minetest.register_node("digtron:fuelstore", { connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1} } end end)(), - after_place_node = (function() if minetest.get_modpath("pipeworks") then return pipeworks.after_place end end)(), - after_dig_node = (function() if minetest.get_modpath("pipeworks")then return pipeworks.after_dig end end)() + after_place_node = (function() if pipeworks_path then return pipeworks.after_place end end)(), + after_dig_node = (function() if pipeworks_path then return pipeworks.after_dig end end)() }) local combined_storage_formspec = @@ -241,7 +242,7 @@ minetest.register_node("digtron:combined_storage", { -- Pipeworks compatibility ---------------------------------------------------------------- - tube = (function() if minetest.get_modpath("pipeworks") then return { + tube = (function() if pipeworks_path then return { insert_object = function(pos, node, stack, direction) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -262,8 +263,8 @@ minetest.register_node("digtron:combined_storage", { connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1} } end end)(), - after_place_node = (function() if minetest.get_modpath("pipeworks") then return pipeworks.after_place end end)(), - after_dig_node = (function() if minetest.get_modpath("pipeworks") then return pipeworks.after_dig end end)() + after_place_node = (function() if pipeworks_path then return pipeworks.after_place end end)(), + after_dig_node = (function() if pipeworks_path then return pipeworks.after_dig end end)() }) -- Hopper compatibility diff --git a/nodes/recipes.lua b/nodes/recipes.lua index 87b0945..a275bb4 100644 --- a/nodes/recipes.lua +++ b/nodes/recipes.lua @@ -147,6 +147,15 @@ minetest.register_craft({ } }) +minetest.register_craft({ + output = "digtron:inventory_ejector", + recipe = { + {"default:steel_ingot","default:steel_ingot","default:steel_ingot"}, + {"","digtron:digtron_core",""}, + {"","default:steel_ingot",""} + } +}) + -- Structural minetest.register_craft({ diff --git a/sounds/license.txt b/sounds/license.txt index 722589d..1de8114 100644 --- a/sounds/license.txt +++ b/sounds/license.txt @@ -10,6 +10,7 @@ squeal.ogg - https://www.freesound.org/people/RutgerMuller/sounds/104026/ public truck.ogg - https://www.freesound.org/people/jberkuta14/sounds/134898/ public domain via CC 1.0 by jberkuta14 whirr.ogg - https://www.freesound.org/people/daveincamas/sounds/25034/ - under the CC BY 3.0 license by daveincamas woopwoopwoop.ogg - https://www.freesound.org/people/gregconquest/sounds/188012/ public domain via CC 1.0 by gregconquest +steam_puff.ogg - https://freesound.org/people/Aiwha/sounds/250703/ under the CC BY 3.0 license by Aiwha Creative Commons Attribution 3.0 license: diff --git a/sounds/steam_puff.ogg b/sounds/steam_puff.ogg new file mode 100644 index 0000000..6183d01 Binary files /dev/null and b/sounds/steam_puff.ogg differ diff --git a/textures/digtron_output.png b/textures/digtron_output.png new file mode 100644 index 0000000..1f12185 Binary files /dev/null and b/textures/digtron_output.png differ