diff --git a/api.lua b/api.lua index 728a8b3..e066f9d 100644 --- a/api.lua +++ b/api.lua @@ -26,7 +26,7 @@ function microexpansion.register_oredef(ore, defs) end for _,d in ipairs(defs) do - d.ore = "microexpansion:"..ore + d.ore = ore minetest.register_ore(d) end end diff --git a/depends.txt b/depends.txt index d3f04d8..96b6770 100644 --- a/depends.txt +++ b/depends.txt @@ -1,2 +1,3 @@ default pipeworks? +basic_materials? diff --git a/init.lua b/init.lua index e50a3af..bd51da1 100644 --- a/init.lua +++ b/init.lua @@ -11,9 +11,12 @@ microexpansion.gui_bg = "bgcolor[#080808BB;true]background[5,5;1,1;gui_formbg.pn microexpansion.gui_slots = "listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]" microexpansion.settings = { - huge_stacks = minetest.settings:get_bool("microexpansion_huge_stacks") + huge_stacks = minetest.settings:get_bool("microexpansion_huge_stacks"), + simple_craft = minetest.settings:get_bool("microexpansion_simple_craft") } +microexpansion.uinv_category_enabled = minetest.global_exists("unified_inventory") and unified_inventory.add_category_item and true or false + -- logger function microexpansion.log(content, log_type) assert(content, "microexpansion.log: missing content") diff --git a/mod.conf b/mod.conf index 759261f..e678050 100644 --- a/mod.conf +++ b/mod.conf @@ -1,4 +1,4 @@ name = microexpansion description = A storage managing solution to get an overview over all your items. depends = default -optional_depends = pipeworks +optional_depends = pipeworks,basic_materials diff --git a/modules.conf b/modules.conf index 6c1ae5b..5374f54 100644 --- a/modules.conf +++ b/modules.conf @@ -1,6 +1,6 @@ -shared = true network = true power = false storage = true ores = true item_transfer = true +crafting = true diff --git a/modules/crafting/alternatives.lua b/modules/crafting/alternatives.lua new file mode 100644 index 0000000..b2aa299 --- /dev/null +++ b/modules/crafting/alternatives.lua @@ -0,0 +1,37 @@ +--- +-- craftitems that offer alternative craft recipes + +local me = microexpansion + +--TODO: build specialized integrated circuits / chips out of the ic and other stuff that are required to build the devices / machines instead of the control unit being an alternative + +--- +-- [Microexpansion Control Unit] +-- a different logic chip that uses gold, quartz and wood +-- for use instead of basic_materials:ic that requires sand, coal and copper +me.register_item("logic_chip", { + description = "Control Unit", + recipe = { + { 2, + { + {"basic_materials:gold_wire"}, + {"basic_materials:silicon"}, + {"basic_materials:plastic_sheet"} + }, + }, + { 2, + { + {"basic_materials:gold_wire"}, + {"microexpansion:quartz_crystal"}, + {"basic_materials:plastic_sheet"} + }, + }, + { 2, + { + {"microexpansion:gold_wire"}, + {"microexpansion:quartz_crystal"}, + {"group:wood"} + }, + }, + }, +}) diff --git a/modules/crafting/init.lua b/modules/crafting/init.lua new file mode 100644 index 0000000..c9146dc --- /dev/null +++ b/modules/crafting/init.lua @@ -0,0 +1,8 @@ +local module_path = microexpansion.get_module_path("crafting") + +-- basic_materials replacements +dofile(module_path.."/materials.lua") +-- shared items used for various machine recipes +dofile(module_path.."/shared.lua") +-- items that allow for alternative recipes +dofile(module_path.."/alternatives.lua") diff --git a/modules/crafting/materials.lua b/modules/crafting/materials.lua new file mode 100644 index 0000000..934a3ed --- /dev/null +++ b/modules/crafting/materials.lua @@ -0,0 +1,19 @@ +--- +-- Craft materials, that are normally registered by basic_materials + +local me = microexpansion +local substitute_basic_materials = microexpansion.settings.simple_craft == true or not minetest.get_modpath("basic_materials") + + +-- [register item] Gold Wire +me.register_item("gold_wire", { + description = "Gold Wire", + groups = { wire = 1 }, + recipe = substitute_basic_materials and { + { 2, { + {"default:gold_ingot", "default:stick"}, + {"default:stick", ""} + }, + }, + } or nil, +}) diff --git a/modules/shared/init.lua b/modules/crafting/shared.lua similarity index 54% rename from modules/shared/init.lua rename to modules/crafting/shared.lua index 396af72..ad80c5f 100644 --- a/modules/shared/init.lua +++ b/modules/crafting/shared.lua @@ -1,9 +1,8 @@ --- shared/init.lua +-- crafting/shared.lua local me = microexpansion --- This mostly contains items that are used by multiple modules and --- don't really fit with anything else. +-- custom items that are used by multiple devices -- [register item] Steel Infused Obsidian Ingot me.register_item("steel_infused_obsidian_ingot", { @@ -28,28 +27,3 @@ me.register_item("machine_casing", { }, }, }) - --- [register item] Gold Wire -me.register_item("gold_wire", { - description = "Gold Wire", - recipe = { - { 2, { - {"default:gold_ingot", "default:stick"}, - {"default:stick", ""} - }, - }, - }, -}) - --- [register item] Control Unit -me.register_item("logic_chip", { - description = "Control Unit", - recipe = { - { 2, { - {"microexpansion:gold_wire"}, - {"microexpansion:quartz_crystal"}, - {"group:wood"} - }, - }, - }, -}) diff --git a/modules/item_transfer/exporter.lua b/modules/item_transfer/exporter.lua index 5aef6c4..04b6215 100644 --- a/modules/item_transfer/exporter.lua +++ b/modules/item_transfer/exporter.lua @@ -23,6 +23,7 @@ local function exporter_timer(pos, elapsed) end local max_count = math.pow(2, upgrades.bulk or 0) microexpansion.move_inv({inv=net:get_inventory(),name="main",huge=true}, {inv=inv,name=list}, max_count, export_filter) + --TODO: perhaps call allow_insert and on_insert callbacks end return true end @@ -50,6 +51,12 @@ item_transfer.register_io_device("exporter", { }, connect_sides = { "left" }, recipe = { + { 1, { + {"", "basic_materials:ic", "default:steel_ingot" }, + {"", "microexpansion:cable", "group:shovel" }, + {"", "", "default:steel_ingot" }, + }, + }, { 1, { {"", "microexpansion:logic_chip", "default:steel_ingot" }, {"", "microexpansion:cable", "group:shovel" }, @@ -81,4 +88,6 @@ item_transfer.register_io_device("exporter", { end }) - +if me.uinv_category_enabled then + unified_inventory.add_category_item("storage", "microexpansion:exporter") +end diff --git a/modules/item_transfer/importer.lua b/modules/item_transfer/importer.lua index 75b7c30..52ac2e6 100644 --- a/modules/item_transfer/importer.lua +++ b/modules/item_transfer/importer.lua @@ -58,6 +58,12 @@ item_transfer.register_io_device("importer", { }, connect_sides = { "left" }, recipe = { + { 1, { + {"", "basic_materials:ic", "default:steel_ingot" }, + {"", "microexpansion:cable", "group:hoe" }, + {"", "", "default:steel_ingot" }, + }, + }, { 1, { {"", "microexpansion:logic_chip", "default:steel_ingot" }, {"", "microexpansion:cable", "group:hoe" }, @@ -89,4 +95,6 @@ item_transfer.register_io_device("importer", { end }) - +if me.uinv_category_enabled then + unified_inventory.add_category_item("storage", "microexpansion:importer") +end diff --git a/modules/item_transfer/upgrades.lua b/modules/item_transfer/upgrades.lua index 5ebe780..0b65297 100644 --- a/modules/item_transfer/upgrades.lua +++ b/modules/item_transfer/upgrades.lua @@ -22,6 +22,11 @@ me.register_item("upgrade_bulk", { description = "Bulk Upgrade", usedfor = "upgrades components to process more at the same time", recipe = { + { 1, { + {"basic_materials:gold_wire"}, + {"microexpansion:upgrade_base"} + }, + }, { 1, { {"microexpansion:gold_wire"}, {"microexpansion:upgrade_base"} @@ -48,6 +53,11 @@ me.register_item("upgrade_control", { description = "Control Upgrade", usedfor = "allows more fine tuned control over components", recipe = { + { 1, { + {"basic_materials:ic"}, + {"microexpansion:upgrade_base"} + }, + }, { 1, { {"microexpansion:logic_chip"}, {"microexpansion:upgrade_base"} diff --git a/modules/network/ctrl.lua b/modules/network/ctrl.lua index 93336cf..3d0103a 100644 --- a/modules/network/ctrl.lua +++ b/modules/network/ctrl.lua @@ -251,3 +251,9 @@ me.register_machine("cable", { type = "conductor", }, }) + +if me.uinv_category_enabled then + unified_inventory.add_category_item("storage", "microexpansion:ctrl") + unified_inventory.add_category_item("storage", "microexpansion:cable") +end + diff --git a/modules/ores/init.lua b/modules/ores/init.lua index 0f32daf..ffe7ae7 100644 --- a/modules/ores/init.lua +++ b/modules/ores/init.lua @@ -35,13 +35,13 @@ me.register_node("quartz", { type = "ore", groups = { cracky=3, stone=1 }, drop = "microexpansion:quartz_crystal", - oredef = { - ore_type = "blob", + oredef = {{ + ore_type = "scatter", wherein = "default:stone", - clust_scarcity = 4*4*4, - clust_num_ores = 4, - clust_size = 3, - y_min = -3000, - y_max = -50, - } + clust_scarcity = 10*10*10, + clust_num_ores = 6, + clust_size = 5, + y_min = -31000, + y_max = -5, + }} }) diff --git a/modules/storage/api.lua b/modules/storage/api.lua index ba5b430..8f034a4 100644 --- a/modules/storage/api.lua +++ b/modules/storage/api.lua @@ -2,6 +2,8 @@ local BASENAME = "microexpansion" +--FIXME: either consolidate or forbid crafting with filled cells + -- [function] register cell function microexpansion.register_cell(itemstring, def) if not def.inventory_image then @@ -26,6 +28,10 @@ function microexpansion.register_cell(itemstring, def) if def.recipe then microexpansion.register_recipe(BASENAME..":"..itemstring, def.recipe) end + + if microexpansion.uinv_category_enabled then + unified_inventory.add_category_item("storage", BASENAME..":"..itemstring) + end end -- [function] Get cell size @@ -81,4 +87,4 @@ function microexpansion.move_inv(inv1, inv2, max) end end end -]] \ No newline at end of file +]] diff --git a/modules/storage/drive.lua b/modules/storage/drive.lua index ea09fe5..7b23ef5 100644 --- a/modules/storage/drive.lua +++ b/modules/storage/drive.lua @@ -405,3 +405,7 @@ microexpansion.register_node("drive", { me.send_event(pos,"items",{net=network}) end, }) + +if me.uinv_category_enabled then + unified_inventory.add_category_item("storage", "microexpansion:drive") +end diff --git a/modules/storage/terminal.lua b/modules/storage/terminal.lua index 53b1146..0bbb343 100644 --- a/modules/storage/terminal.lua +++ b/modules/storage/terminal.lua @@ -305,3 +305,7 @@ microexpansion.register_node("term", { end end, }) + +if me.uinv_category_enabled then + unified_inventory.add_category_item("storage", "microexpansion:term") +end diff --git a/register.lua b/register.lua index 00d5be6..5bf5a45 100644 --- a/register.lua +++ b/register.lua @@ -5,6 +5,15 @@ local me = microexpansion local power = me.power +if me.uinv_category_enabled and unified_inventory.registered_categories then + if not unified_inventory.registered_categories["storage"] then + unified_inventory.register_category("storage", { + symbol = "default:chest", + label = "Storage" + }) + end +end + -- [function] Register machine function me.register_machine(itemstring, def) -- Set after_place_node diff --git a/settingtypes.txt b/settingtypes.txt index c908126..f9fc99f 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -1,2 +1,5 @@ #Stack items in networks higher than their max size. microexpansion_huge_stacks (huge stacks) bool true + +#Enable the "simple" craft recipes that do not require basic_materials even if basic_materials is present. +microexpansion_simple_craft (simple craft recipes) bool false