API: https://github.com/raymoo/multiblock/bl ... er/API.txt
Depends: Nothing (default is required for the demo)
License: LGPL2 or any later version
Download: https://github.com/raymoo/multiblock/archive/master.zip
Multiblock is a pattern matching library for node structures. Suppose I want to make a node duplication altar. Then I can make a pattern like this:
Code: Select all
local pattern = {
size = {x=5, y=2, z=5},
center = {x=3, y=2, z=3},
pattern = {
"default:cobble", "default:cobble", "default:cobble", "default:cobble", "default:cobble",
"default:cobble", "default:cobble", "default:cobble", "default:cobble", "default:cobble",
"default:cobble", "default:cobble", "default:cobble", "default:cobble", "default:cobble",
"default:cobble", "default:cobble", "default:cobble", "default:cobble", "default:cobble",
"default:cobble", "default:cobble", "default:cobble", "default:cobble", "default:cobble",
"?air", "?air", "?air", "?air", "?air",
"?air", "mat!", "mat!", "mat!", "?air",
"?air", "mat!", "multiblock:test_core", "mat!", "?air",
"?air", "mat!", "mat!", "mat!", "?air",
"?air", "?air", "?air", "?air", "?air",
},
}
Later, I can invoke it like this:
Code: Select all
local function fill_out_possibly(pos, clicker)
local captures = multiblock.match(pattern, pos)
if not captures then
minetest.chat_send_player(clicker:get_player_name(), "Match failed.")
return
end
local mat = captures.mat[1]
for i, capture in ipairs(captures[""]) do
minetest.place_node(capture.pos, mat)
end
end
Trying the demo:
1. Give yourself a multiblock:test_core with /giveme
2. Place a 5x5 base of cobble
3. Place the test core on top, in the middle
4. Surround the core with 8 identical nodes of your choice
5. Right-click the core
6. Rejoice in your duplication hax
It is possible to use this mod as a standalone library. Copy multiblock.lua and do
Code: Select all
local multiblock = dofile(path_to_multiblock_lua)