Compare commits

..

8 Commits

Author SHA1 Message Date
SmallJoker
84cf0c4ff2 mesecons: Unify duplicated code
The new comments should help understanding what is going on
to ease maintenance in the long-run.

Co-authored-by: Jude Melton-Houghton <jwmhjwmh@gmail.com>
2025-11-10 19:50:54 +01:00
sfence
e2fc73da98 Support for Hades Revisited (#710) 2025-06-25 21:22:06 +02:00
SX
f24429b9f7 Switch to mineunit-actions (#708) 2025-06-12 09:28:11 +02:00
The4codeblocks
27072542cf Replace on_rotate_horiz with on_rotate and paramtype2 = "4dir"
This raises the minimal Luanti/Minetest version to 5.7.0.
2025-05-17 22:51:06 +02:00
sfan5
b79962402b Try to fix mineunit in CI 2025-05-03 22:36:14 +02:00
sfan5
49879ab13c Update README for Luanti 2025-05-03 22:29:18 +02:00
sfan5
4c142ea871 Add more versions to CI smoke test 2025-05-03 22:29:18 +02:00
Niklp
1513a490dc Replace deprecated image fields in crafitem definitions
This has been a legacy field for at least 13 years now
2025-04-28 21:37:02 +02:00
17 changed files with 178 additions and 124 deletions

View File

@@ -9,9 +9,9 @@ jobs:
- uses: actions/checkout@main
- name: apt
run: sudo apt-get install -y luarocks
- name: luacheck install
- name: install luacheck
run: luarocks install --local luacheck
- name: luacheck run
- name: run luacheck
run: $HOME/.luarocks/bin/luacheck ./
mineunit:
@@ -19,23 +19,27 @@ jobs:
name: "Mineunit tests"
steps:
- uses: actions/checkout@main
- name: apt
run: sudo apt-get install -y luarocks
- name: busted install
run: luarocks install --local busted
- name: luacov install
run: luarocks install --local luacov
- name: mineunit install
run: luarocks install --server=https://luarocks.org/dev --local mineunit
- name: run mesecons tests
working-directory: ./mesecons/
run: $HOME/.luarocks/bin/mineunit -q
uses: mt-mods/mineunit-actions@master
with:
coverage: false
mineunit-args: -q
working-directory: ./mesecons
- name: run mesecons_mvps tests
working-directory: ./mesecons_mvps/
run: $HOME/.luarocks/bin/mineunit -q
uses: mt-mods/mineunit-actions@master
with:
coverage: false
mineunit-args: -q
working-directory: ./mesecons_mvps
- name: run mesecons_fpga tests
working-directory: ./mesecons_fpga/
run: $HOME/.luarocks/bin/mineunit -q
uses: mt-mods/mineunit-actions@master
with:
coverage: false
mineunit-args: -q
working-directory: ./mesecons_fpga
- name: run mesecons_luacontroller tests
working-directory: ./mesecons_luacontroller/
run: $HOME/.luarocks/bin/mineunit -q
uses: mt-mods/mineunit-actions@master
with:
coverage: false
mineunit-args: -q
working-directory: ./mesecons_luacontroller

View File

@@ -10,11 +10,13 @@ jobs:
matrix:
cfg:
- { image: 'registry.gitlab.com/minetest/minetest/server:5.0.1', mtg: false }
- { image: 'ghcr.io/minetest/minetest:5.10.0', mtg: true }
- { image: 'ghcr.io/minetest/minetest:5.9.0', mtg: true }
- { image: 'ghcr.io/luanti-org/luanti:5.11.0', mtg: true }
steps:
- uses: actions/checkout@main
- uses: actions/checkout@main
- name: Download Minetest Game
uses: actions/checkout@main
with:
repository: 'minetest/minetest_game'
path: ./.test/minetest_game

View File

@@ -30,6 +30,7 @@ read_globals = {
"VoxelArea",
"mcl_dyes",
"mcl_sounds",
"hades_sounds",
}
globals = {"mesecon"}

View File

@@ -99,8 +99,9 @@ do
offstate = "mesecons:test_conductor_rot_off",
}}
mesecon.register_node("mesecons:test_conductor_rot", {
paramtype2 = "4dir",
description = "Rotatable Test Conductor",
on_rotate = mesecon.on_rotate_horiz,
on_rotate = mesecon.on_rotate,
}, {mesecons = off_spec}, {mesecons = on_spec})
end

View File

@@ -13,9 +13,10 @@ MESECONS by Jeija and contributors
Mezzee-what?
------------
[Mesecons](https://mesecons.net/)! They're yellow, they're conductive, and they'll add a whole new dimension to Minetest's gameplay.
[Mesecons](https://mesecons.net/)! They're yellow, they're conductive, and they'll add a whole new dimension to Luanti's gameplay.
Mesecons is a mod for [Minetest](https://www.minetest.net/) that implements a ton of items related to digital circuitry, such as wires, buttons, lights, and even programmable controllers. Among other things, there are also pistons, solar panels, pressure plates, and note blocks.
Mesecons is a mod for [Luanti](https://www.luanti.org/) that implements a ton of items related to digital circuitry, such as wires, buttons, lights, and even programmable controllers.
Among other things, there are also pistons, solar panels, pressure plates, and note blocks.
Mesecons has a similar goal to Redstone in Minecraft, but works in its own way, with different rules and mechanics.
@@ -24,15 +25,15 @@ OK, I want in.
Go get it!
[![ContentDB](https://content.minetest.net/packages/Jeija/mesecons/shields/downloads/)](https://content.minetest.net/packages/Jeija/mesecons/)
[![ContentDB](https://content.luanti.org/packages/Jeija/mesecons/shields/downloads/)](https://content.luanti.org/packages/Jeija/mesecons/)
Install it directly from your client by searching it in the Online Content tab.
**Or** if you've downloaded a ZIP file check out [this page](https://wiki.minetest.net/Mods) over at the official Minetest Wiki. For your convenience, here's a quick summary:
**Or** if you've downloaded a ZIP file check out [this page](https://docs.luanti.org/for-players/mods/) over at the official Luanti Wiki. For your convenience, here's a quick summary:
1. If Mesecons is still in a ZIP file, extract the folder inside to somewhere on the computer.
2. Make sure that when you open the folder, you can directly find `README.md` in the listing. If you just see another folder, move that folder up one level and delete the old one.
3. Open up the Minetest mods folder - called `mods`.
3. Open up the Luanti mods folder - called `mods`.
4. Copy the Mesecons folder into the mods folder.
Don't like some parts of Mesecons? Open up the Mesecons folder and delete the subfolder containing the mod you don't want. If you didn't want movestones, for example, all you have to do is delete the `mesecons_movestones` folder and they will no longer be available.

View File

@@ -90,6 +90,16 @@ function mesecon.get_any_rules(node)
mesecon.get_any_outputrules(node))
end
local function get_rules_from_ndef(ndef, node)
local rules = ndef and ndef.rules
if type(rules) == 'function' then
return rules(node)
elseif rules then
return rules
end
return mesecon.rules.default
end
-- Receptors
-- Nodes that can power mesecons
function mesecon.is_receptor_on(nodename)
@@ -117,17 +127,7 @@ function mesecon.is_receptor(nodename)
end
function mesecon.receptor_get_rules(node)
local receptor = mesecon.get_receptor(node.name)
if receptor then
local rules = receptor.rules
if type(rules) == 'function' then
return rules(node)
elseif rules then
return rules
end
end
return mesecon.rules.default
return get_rules_from_ndef(mesecon.get_receptor(node.name), node)
end
-- Effectors
@@ -157,16 +157,7 @@ function mesecon.is_effector(nodename)
end
function mesecon.effector_get_rules(node)
local effector = mesecon.get_effector(node.name)
if effector then
local rules = effector.rules
if type(rules) == 'function' then
return rules(node)
elseif rules then
return rules
end
end
return mesecon.rules.default
return get_rules_from_ndef(mesecon.get_effector(node.name), node)
end
-- #######################
@@ -330,16 +321,7 @@ function mesecon.get_conductor_off(node_on, rulename)
end
function mesecon.conductor_get_rules(node)
local conductor = mesecon.get_conductor(node.name)
if conductor then
local rules = conductor.rules
if type(rules) == 'function' then
return rules(node)
elseif rules then
return rules
end
end
return mesecon.rules.default
return get_rules_from_ndef(mesecon.get_conductor(node.name), node)
end
-- some more general high-level stuff
@@ -545,46 +527,42 @@ function mesecon.turnoff(pos, link)
return true
end
-- @param getter_function Function that returns nested rules (vectors)
-- @return The matching rule or `nil`
local function find_rule_in_rules(pos, rule, getter_function)
local r_pos = vector.add(pos, rule)
local r_node = mesecon.get_node_force(r_pos)
local r_rules = getter_function(r_node)
if not r_rules then
return
end
local dir = vector.subtract(pos, r_pos)
for _, r_rule in ipairs(mesecon.flattenrules(r_rules)) do
if vector.equals(dir, r_rule) then
-- Other matches are duplicates
return r_rule
end
end
end
-- Get all linking inputrules of inputnode (effector or conductor) that is connected to
-- outputnode (receptor or conductor) at position `output` and has an output in direction `rule`
function mesecon.rules_link_rule_all(output, rule)
local input = vector.add(output, rule)
local inputnode = mesecon.get_node_force(input)
local inputrules = mesecon.get_any_inputrules(inputnode)
if not inputrules then
return {}
end
local rules = {}
for _, inputrule in ipairs(mesecon.flattenrules(inputrules)) do
-- Check if input accepts from output
if vector.equals(vector.add(input, inputrule), output) then
table.insert(rules, inputrule)
end
end
return rules
local match = find_rule_in_rules(output, rule, mesecon.get_any_inputrules)
return { match }
end
-- Get all linking outputnodes of outputnode (receptor or conductor) that is connected to
-- inputnode (effector or conductor) at position `input` and has an input in direction `rule`
function mesecon.rules_link_rule_all_inverted(input, rule)
local output = vector.add(input, rule)
local outputnode = mesecon.get_node_force(output)
local outputrules = mesecon.get_any_outputrules(outputnode)
if not outputrules then
return {}
end
local rules = {}
for _, outputrule in ipairs(mesecon.flattenrules(outputrules)) do
if vector.equals(vector.add(output, outputrule), input) then
table.insert(rules, mesecon.invertRule(outputrule))
end
end
return rules
local match = find_rule_in_rules(input, rule, mesecon.get_any_outputrules)
return { match and mesecon.invertRule(match) }
end
-- @param pos Node position (a vector) to check
-- @param rule Optional. Specific rule (i.e. node side) to check.
-- @return Returns a list of vectors that power `pos`, or `false` if unpowered.
function mesecon.is_powered(pos, rule)
local node = mesecon.get_node_force(pos)
local rules = mesecon.get_any_inputrules(node)
@@ -593,26 +571,15 @@ function mesecon.is_powered(pos, rule)
-- List of nodes that send out power to pos
local sourcepos = {}
if not rule then
for _, rule in ipairs(mesecon.flattenrules(rules)) do
local rulenames = mesecon.rules_link_rule_all_inverted(pos, rule)
for _, rname in ipairs(rulenames) do
local np = vector.add(pos, rname)
local nn = mesecon.get_node_force(np)
if (mesecon.is_conductor_on(nn, mesecon.invertRule(rname))
or mesecon.is_receptor_on(nn.name)) then
table.insert(sourcepos, np)
end
end
end
else
local rules_flat = rule and { rule } or mesecon.flattenrules(rules)
for _, rule in ipairs(rules_flat) do
local rulenames = mesecon.rules_link_rule_all_inverted(pos, rule)
for _, rname in ipairs(rulenames) do
local np = vector.add(pos, rname)
local nn = mesecon.get_node_force(np)
if (mesecon.is_conductor_on (nn, mesecon.invertRule(rname))
or mesecon.is_receptor_on (nn.name)) then
if (mesecon.is_conductor_on(nn, mesecon.invertRule(rname))
or mesecon.is_receptor_on(nn.name)) then
table.insert(sourcepos, np)
end
end

View File

@@ -17,6 +17,7 @@ function mesecon.on_rotate(pos, node, _, _, new_param2)
end
-- An on_rotate callback for components which stay horizontal.
-- Deprecated. Use paramtype2 = "4dir" instead.
function mesecon.on_rotate_horiz(pos, node, user, mode, new_param2)
if not minetest.global_exists("screwdriver") or mode ~= screwdriver.ROTATE_FACE then
return false

View File

@@ -18,7 +18,7 @@ minetest.register_node("mesecons_extrawires:corner_on", {
{ name = "jeija_insulated_wire_ends_on.png", backface_culling = true },
},
paramtype = "light",
paramtype2 = "facedir",
paramtype2 = "4dir",
is_ground_content = false,
walkable = false,
sunlight_propagates = true,
@@ -33,7 +33,7 @@ minetest.register_node("mesecons_extrawires:corner_on", {
offstate = "mesecons_extrawires:corner_off"
}},
on_blast = mesecon.on_blastnode,
on_rotate = mesecon.on_rotate_horiz,
on_rotate = mesecon.on_rotate,
})
minetest.register_node("mesecons_extrawires:corner_off", {
@@ -45,7 +45,7 @@ minetest.register_node("mesecons_extrawires:corner_off", {
{ name = "jeija_insulated_wire_ends_off.png", backface_culling = true },
},
paramtype = "light",
paramtype2 = "facedir",
paramtype2 = "4dir",
is_ground_content = false,
walkable = false,
sunlight_propagates = true,
@@ -59,7 +59,7 @@ minetest.register_node("mesecons_extrawires:corner_off", {
onstate = "mesecons_extrawires:corner_on"
}},
on_blast = mesecon.on_blastnode,
on_rotate = mesecon.on_rotate_horiz,
on_rotate = mesecon.on_rotate,
})
minetest.register_craft({

View File

@@ -41,7 +41,7 @@ for k, state in ipairs(doublecorner_states) do
{ name = "jeija_insulated_wire_ends_" .. w2 .. ".png", backface_culling = true },
},
paramtype = "light",
paramtype2 = "facedir",
paramtype2 = "4dir",
is_ground_content = false,
walkable = false,
sunlight_propagates = true,
@@ -56,7 +56,7 @@ for k, state in ipairs(doublecorner_states) do
},
},
on_blast = mesecon.on_blastnode,
on_rotate = mesecon.on_rotate_horiz,
on_rotate = mesecon.on_rotate,
})
end

View File

@@ -29,7 +29,7 @@ minetest.register_node("mesecons_extrawires:tjunction_on", {
"jeija_insulated_wire_ends_on.png"
},
paramtype = "light",
paramtype2 = "facedir",
paramtype2 = "4dir",
is_ground_content = false,
walkable = false,
sunlight_propagates = true,
@@ -45,7 +45,7 @@ minetest.register_node("mesecons_extrawires:tjunction_on", {
offstate = "mesecons_extrawires:tjunction_off"
}},
on_blast = mesecon.on_blastnode,
on_rotate = mesecon.on_rotate_horiz,
on_rotate = mesecon.on_rotate,
})
minetest.register_node("mesecons_extrawires:tjunction_off", {
@@ -60,7 +60,7 @@ minetest.register_node("mesecons_extrawires:tjunction_off", {
"jeija_insulated_wire_ends_off.png"
},
paramtype = "light",
paramtype2 = "facedir",
paramtype2 = "4dir",
is_ground_content = false,
walkable = false,
sunlight_propagates = true,
@@ -75,7 +75,7 @@ minetest.register_node("mesecons_extrawires:tjunction_off", {
onstate = "mesecons_extrawires:tjunction_on"
}},
on_blast = mesecon.on_blastnode,
on_rotate = mesecon.on_rotate_horiz,
on_rotate = mesecon.on_rotate,
})
minetest.register_craft({

View File

@@ -0,0 +1,72 @@
--Aliases
core.register_alias("mesecons_gamecompat:chest", "hades_chests:chest")
core.register_alias("mesecons_gamecompat:chest_locked", "hades_chests:chest_locked")
core.register_alias("mesecons_gamecompat:coalblock", "hades_core:coalblock")
core.register_alias("mesecons_gamecompat:cobble", "hades_core:cobble")
core.register_alias("mesecons_gamecompat:glass", "hades_core:glass")
core.register_alias("mesecons_gamecompat:lava_source", "hades_core:lava_source")
core.register_alias("mesecons_gamecompat:mese", "hades_core:mese")
core.register_alias("mesecons_gamecompat:mese_crystal", "hades_core:mese_crystal")
core.register_alias("mesecons_gamecompat:mese_crystal_fragment", "hades_core:mese_crystal_fragment")
core.register_alias("mesecons_gamecompat:obsidian_glass", "hades_core:obsidian_glass")
core.register_alias("mesecons_gamecompat:stone", "hades_core:stone")
core.register_alias("mesecons_gamecompat:steel_ingot", "hades_core:steel_ingot")
core.register_alias("mesecons_gamecompat:steelblock", "hades_core:steelblock")
core.register_alias("mesecons_gamecompat:torch", "hades_torches:torch")
if core.get_modpath("hades_dye") then
for _, color in ipairs(mesecon.dye_colors) do
core.register_alias("mesecons_gamecompat:dye_" .. color, "hades_dye:" .. color)
end
end
-- Sounds
mesecon.node_sound.default = hades_sounds.node_sound_defaults()
mesecon.node_sound.glass = hades_sounds.node_sound_glass_defaults()
mesecon.node_sound.leaves = hades_sounds.node_sound_leaves_defaults()
mesecon.node_sound.stone = hades_sounds.node_sound_stone_defaults()
mesecon.node_sound.wood = hades_sounds.node_sound_wood_defaults()
if core.get_modpath("hades_fire") then
mesecon.sound_name.fire = "fire_fire"
end
if core.get_modpath("hades_tnt") then
mesecon.sound_name.explode = "tnt_explode"
end
-- Textures
mesecon.texture.steel_block = "default_steel_block.png"
-- MVPS stoppers
if core.get_modpath("mesecons_mvps") then
-- All of the locked and internal nodes in Hades Revisited
for _, name in ipairs({
"hades_chests:chest_locked",
"hades_chests:chest_locked_open",
"hades_doors:hidden",
"hades_doors:hidden_center",
}) do
mesecon.register_mvps_stopper(name)
end
core.register_on_mods_loaded(function()
if core.get_modpath("hades_doors") then
for _,v in pairs(core.registered_nodes) do
if v.groups and (v.groups.door or v.groups.trapdoor) then
mesecon.register_mvps_stopper(v.name)
end
end
end
if core.get_modpath("hades_beds") then
for _,v in pairs(core.registered_nodes) do
if v.groups and v.groups.bed then
mesecon.register_mvps_stopper(v.name)
end
end
end
end)
end

View File

@@ -19,6 +19,11 @@ if minetest.get_modpath("mcl_redstone") then
dofile(minetest.get_modpath("mesecons_gamecompat").."/compat_mcla.lua")
end
if minetest.get_modpath("hades_core") then
minetest.log("info", "Mesecons: detected Hades Revisited Game for game compatibility")
dofile(minetest.get_modpath("mesecons_gamecompat").."/compat_hades.lua")
end
if minetest.get_modpath("doors") then
dofile(minetest.get_modpath("mesecons_gamecompat").."/doors.lua")
end

View File

@@ -1,3 +1,3 @@
name = mesecons_gamecompat
depends = mesecons
optional_depends = fire, default, dye, mesecons_mvps, tnt, doors, beds, mcl_fire, mcl_core, mcl_dye, mcl_tnt
optional_depends = fire, default, dye, mesecons_mvps, tnt, doors, beds, mcl_fire, mcl_core, mcl_dye, mcl_tnt, hades_sounds

View File

@@ -89,7 +89,7 @@ local function register_gate(name, inputnumber, assess, recipe, description)
description = description,
inventory_image = "jeija_gate_off.png^jeija_gate_"..name..".png",
paramtype = "light",
paramtype2 = "facedir",
paramtype2 = "4dir",
is_ground_content = false,
drawtype = "nodebox",
drop = basename.."_off",
@@ -102,7 +102,7 @@ local function register_gate(name, inputnumber, assess, recipe, description)
offstate = basename.."_off",
inputnumber = inputnumber,
after_dig_node = mesecon.do_cooldown,
on_rotate = mesecon.on_rotate_horiz,
on_rotate = mesecon.on_rotate,
},{
tiles = {
"jeija_microcontroller_bottom.png^".."jeija_gate_off.png^"..

View File

@@ -17,7 +17,7 @@ minetest.register_node("mesecons_insulated:insulated_on", {
"jeija_insulated_wire_sides_on.png"
},
paramtype = "light",
paramtype2 = "facedir",
paramtype2 = "4dir",
is_ground_content = false,
walkable = false,
sunlight_propagates = true,
@@ -39,7 +39,7 @@ minetest.register_node("mesecons_insulated:insulated_on", {
rules = insulated_wire_get_rules
}},
on_blast = mesecon.on_blastnode,
on_rotate = mesecon.on_rotate_horiz,
on_rotate = mesecon.on_rotate,
})
minetest.register_node("mesecons_insulated:insulated_off", {
@@ -54,7 +54,7 @@ minetest.register_node("mesecons_insulated:insulated_off", {
"jeija_insulated_wire_sides_off.png"
},
paramtype = "light",
paramtype2 = "facedir",
paramtype2 = "4dir",
is_ground_content = false,
walkable = false,
sunlight_propagates = true,
@@ -75,7 +75,7 @@ minetest.register_node("mesecons_insulated:insulated_off", {
rules = insulated_wire_get_rules
}},
on_blast = mesecon.on_blastnode,
on_rotate = mesecon.on_rotate_horiz,
on_rotate = mesecon.on_rotate,
})
minetest.register_craft({

View File

@@ -2,13 +2,13 @@ local S = minetest.get_translator(minetest.get_current_modname())
-- Glue and fiber
minetest.register_craftitem("mesecons_materials:glue", {
image = "mesecons_glue.png",
inventory_image = "mesecons_glue.png",
on_place_on_ground = minetest.craftitem_place_item,
description = S("Glue"),
})
minetest.register_craftitem("mesecons_materials:fiber", {
image = "mesecons_fiber.png",
inventory_image = "mesecons_fiber.png",
on_place_on_ground = minetest.craftitem_place_item,
description = S("Fiber"),
})
@@ -29,7 +29,7 @@ minetest.register_craft({
-- Silicon
minetest.register_craftitem("mesecons_materials:silicon", {
image = "mesecons_silicon.png",
inventory_image = "mesecons_silicon.png",
on_place_on_ground = minetest.craftitem_place_item,
description = S("Silicon"),
})

View File

@@ -1,5 +1,5 @@
name = mesecons
description = Mod that implements a ton of items related to digital circuitry.
min_minetest_version = 5.0
min_minetest_version = 5.7.0
author = Jeija
title = Mesecons