From f781039f435db58618ba26ffc66a307ae0340e58 Mon Sep 17 00:00:00 2001 From: "Github is a non-free platform owned by Microsoft. Reasonable alternatives exist, such as Gitea, Sourcehut. We need a federated, mastodon-like forge based on ForgeFed. See: https://forgefed.org" Date: Sat, 2 Dec 2023 21:45:07 +0100 Subject: [PATCH] MineClone/MineClonia compatibility (#80) --- .luacheckrc | 4 +++- init.lua | 25 ++++++++++++++++++++++--- inventory.lua | 26 ++++++++++++++++++++------ lcd.lua | 21 +++++++++++++++------ lightsensor.lua | 14 ++++++++++++-- mod.conf | 4 ++-- rtc.lua | 19 +++++++++++++++++-- 7 files changed, 91 insertions(+), 22 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index 5b7a057..d12836d 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -13,5 +13,7 @@ read_globals = { globals = { "digilines", "tubelib", - "tubelib2" + "tubelib2", + "mcl_sounds", + "mcl_formspec" } diff --git a/init.lua b/init.lua index d861c7c..a0ea69c 100644 --- a/init.lua +++ b/init.lua @@ -1,6 +1,13 @@ digilines = {} digilines.S = minetest.get_translator("digilines") +digilines.mcl = minetest.get_modpath("mcl_core") + +-- sounds check +if minetest.get_modpath("default") then digilines.sounds = default end +if digilines.mcl then digilines.sounds = mcl_sounds end + + -- Backwards compatibility code. -- We define a proxy table whose methods can be called with the -- `foo:bar` notation, and it will redirect the call to the @@ -55,12 +62,24 @@ function digilines.receptor_send(pos, rules, channel, msg) end end +local fiber = "mesecons_materials:fiber" +local insulated = "mesecons_insulated:insulated_off" +local gold_ingot = "default:gold_ingot" + +if digilines.mcl then + gold_ingot = "mcl_core:gold_ingot" + -- MCL dont support mesecons insulated + if not minetest.get_modpath("mesecons_insulated") then + insulated = "mesecons:redstone" + end +end + minetest.register_craft({ output = 'digilines:wire_std_00000000 2', recipe = { - {'mesecons_materials:fiber', 'mesecons_materials:fiber', 'mesecons_materials:fiber'}, - {'mesecons_insulated:insulated_off', 'mesecons_insulated:insulated_off', 'default:gold_ingot'}, - {'mesecons_materials:fiber', 'mesecons_materials:fiber', 'mesecons_materials:fiber'}, + {fiber, fiber, fiber}, + {insulated, insulated, gold_ingot}, + {fiber, fiber, fiber}, } }) diff --git a/inventory.lua b/inventory.lua index 9fc4542..741d995 100644 --- a/inventory.lua +++ b/inventory.lua @@ -146,7 +146,15 @@ local tube_insert_object = function(pos, _, original_stack, direction) return stack end +local formspec_header = "" + +if minetest.get_modpath("mcl_formspec") then + formspec_header = mcl_formspec.get_itemslot_bg(0,1,8,4).. + mcl_formspec.get_itemslot_bg(0,6,8,4) +end + minetest.register_alias("digilines_inventory:chest", "digilines:chest") + minetest.register_node("digilines:chest", { description = S("Digiline Chest"), tiles = { @@ -159,15 +167,15 @@ minetest.register_node("digilines:chest", { }, paramtype2 = "facedir", legacy_facedir_simple = true, - groups = {choppy=2, oddly_breakable_by_hand=2, tubedevice=1, tubedevice_receiver=1}, - sounds = default.node_sound_wood_defaults(), + groups = {choppy=2, oddly_breakable_by_hand=2, tubedevice=1, tubedevice_receiver=1, axey=1, handy=1}, + sounds = digilines.sounds.node_sound_wood_defaults(), + _mcl_blast_resistance = 1, + _mcl_hardness = 0.8, on_construct = function(pos) local meta = minetest.get_meta(pos) meta:set_string("infotext", S("Digiline Chest")) meta:set_string("formspec", "size[8,10]".. - ((default and default.gui_bg) or "").. - ((default and default.gui_bg_img) or "").. - ((default and default.gui_slots) or "").. + formspec_header.. "label[0,0;" .. S("Digiline Chest") .. "]" .. "list[current_name;main;0,1;8,4;]".. "field[2,5.5;5,1;channel;" .. S("Channel") .. ";${channel}]".. @@ -405,8 +413,14 @@ if minetest.global_exists("tubelib") then }) end +local chest = "default:chest" + +if minetest.get_modpath("mcl_chests") then + chest = "mcl_chests:chest" +end + minetest.register_craft({ type = "shapeless", output = "digilines:chest", - recipe = {"default:chest", "digilines:wire_std_00000000"} + recipe = {chest, "digilines:wire_std_00000000"} }) diff --git a/lcd.lua b/lcd.lua index 1bad0c5..0faac6c 100644 --- a/lcd.lua +++ b/lcd.lua @@ -286,6 +286,8 @@ minetest.register_node("digilines:lcd", { node_box = lcd_box, selection_box = lcd_box, groups = {choppy = 3, dig_immediate = 2}, + _mcl_blast_resistance = 1, + _mcl_hardness = 0.8, after_place_node = function(pos) local param2 = minetest.get_node(pos).param2 if param2 == 0 or param2 == 1 then @@ -339,14 +341,21 @@ minetest.register_entity(":digilines_lcd:text", { on_activate = set_texture, }) +local steel_ingot = "default:steel_ingot" +local glass = "default:glass" +local lightstone = "mesecons_lightstone:lightstone_green_off" + +if digilines.mcl then + steel_ingot = "mcl_core:iron_ingot" + glass = "mcl_core:glass" + lightstone = "mesecons_lightstone:lightstone_off" +end + minetest.register_craft({ output = "digilines:lcd 2", recipe = { - {"default:steel_ingot", "digilines:wire_std_00000000", "default:steel_ingot"}, - {"mesecons_lightstone:lightstone_green_off", - "mesecons_lightstone:lightstone_green_off", - "mesecons_lightstone:lightstone_green_off"}, - - {"default:glass","default:glass","default:glass"} + {steel_ingot, "digilines:wire_std_00000000", steel_ingot}, + {lightstone, lightstone, lightstone}, + {glass, glass, glass} } }) diff --git a/lightsensor.lua b/lightsensor.lua index 5f11e13..f97abb4 100644 --- a/lightsensor.lua +++ b/lightsensor.lua @@ -39,6 +39,8 @@ minetest.register_node("digilines:lightsensor", { paramtype = "light", groups = {dig_immediate=2}, + _mcl_blast_resistance = 1, + _mcl_hardness = 0.8, selection_box = lsensor_selbox, node_box = lsensor_nodebox, digilines = @@ -63,10 +65,18 @@ minetest.register_node("digilines:lightsensor", { end, }) +local steel_ingot = "default:steel_ingot" +local glass = "default:glass" + +if digilines.mcl then + steel_ingot = "mcl_core:iron_ingot" + glass = "mcl_core:glass" +end + minetest.register_craft({ output = "digilines:lightsensor", recipe = { - {"default:glass","default:glass","default:glass"}, - {"default:steel_ingot", "digilines:wire_std_00000000", "default:steel_ingot"}, + {glass, glass, glass}, + {steel_ingot, "digilines:wire_std_00000000", steel_ingot}, } }) diff --git a/mod.conf b/mod.conf index bfc83a5..18d8cd8 100644 --- a/mod.conf +++ b/mod.conf @@ -1,6 +1,6 @@ name = digilines -depends = default -optional_depends = tubelib,tubelib2 +depends = +optional_depends = mcl_core, mcl_sounds, default, tubelib, tubelib2 description = """ This mod adds digiline wires, an RTC (Real Time Clock), a light sensor as well as an LCD Screen. Can be used together with the luacontroller from mesecons. diff --git a/rtc.lua b/rtc.lua index dac60e8..a7a422a 100644 --- a/rtc.lua +++ b/rtc.lua @@ -35,6 +35,8 @@ minetest.register_node("digilines:rtc", { paramtype = "light", paramtype2 = "facedir", groups = {dig_immediate=2}, + _mcl_blast_resistance = 1, + _mcl_hardness = 0.8, selection_box = rtc_selbox, node_box = rtc_nodebox, digilines = @@ -59,11 +61,24 @@ minetest.register_node("digilines:rtc", { end, }) +local steel_ingot = "default:steel_ingot" +local mese_crystal = "default:mese_crystal_fragment" +local dye_black = "dye:black" + +if digilines.mcl then + steel_ingot = "mcl_core:iron_ingot" + mese_crystal = "mesecons:redstone" +end + +if minetest.get_modpath("mcl_dye") then + dye_black = "mcl_dye:black" +end + minetest.register_craft({ output = "digilines:rtc", recipe = { - {"", "dye:black", ""}, - {"default:steel_ingot", "default:mese_crystal_fragment", "default:steel_ingot"}, + {"", dye_black, ""}, + {steel_ingot, mese_crystal, steel_ingot}, {"", "digilines:wire_std_00000000", ""} } })