Skip to content

Commit

Permalink
MineClone/MineClonia compatibility (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
nonfreegithub authored Dec 2, 2023
1 parent 722ff85 commit f781039
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 22 deletions.
4 changes: 3 additions & 1 deletion .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ read_globals = {
globals = {
"digilines",
"tubelib",
"tubelib2"
"tubelib2",
"mcl_sounds",
"mcl_formspec"
}
25 changes: 22 additions & 3 deletions init.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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},
}
})

Expand Down
26 changes: 20 additions & 6 deletions inventory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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}]"..
Expand Down Expand Up @@ -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"}
})
21 changes: 15 additions & 6 deletions lcd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
}
})
14 changes: 12 additions & 2 deletions lightsensor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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},
}
})
4 changes: 2 additions & 2 deletions mod.conf
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
19 changes: 17 additions & 2 deletions rtc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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", ""}
}
})

0 comments on commit f781039

Please sign in to comment.