translate moreblock node names back into stairs: nodenames for more portability between worlds
parent
61bfe9e71c
commit
878e3ebe9e
|
@ -233,5 +233,13 @@ handle_schematics.analyze_file = function( file_name, origin_offset, store_as_mt
|
|||
end
|
||||
end
|
||||
|
||||
-- some node names need to be replaced right here after reading the file
|
||||
-- because further replacement functions rely on consistant node names
|
||||
for i, name in ipairs(nodenames) do
|
||||
if( replacements_group["after_read_file"][ name ]) then
|
||||
nodenames[ i ] = replacements_group["after_read_file"][ name ]
|
||||
end
|
||||
end
|
||||
|
||||
return res;
|
||||
end
|
||||
|
|
11
init.lua
11
init.lua
|
@ -84,9 +84,20 @@ dofile(handle_schematics.modpath.."/handle_schematics_meta.lua");
|
|||
-- these functions are responsible for the optional dependencies; they check
|
||||
-- which nodes are available and may be offered as possible replacements
|
||||
replacements_group = {};
|
||||
|
||||
-- these replacements need to be applied immediately after a file is read
|
||||
-- (because else the node names would be incompatible for the other possible replacements)
|
||||
dofile(handle_schematics.modpath.."/replacements_after_read_file.lua")
|
||||
|
||||
-- the replacement groups do add some non-ground nodes; needed by mg_villages
|
||||
replacements_group.node_is_ground = {}
|
||||
dofile(handle_schematics.modpath.."/replacements_discontinued_nodes.lua")
|
||||
|
||||
-- moreblocks registers so many aliasses that it is a pain to move from a moreblocks world to one without;
|
||||
-- also, replacement functions expect stairs:stair_* and not moreblock names;
|
||||
-- therefore, repalce moreblock names with stairs:* names after reading the file
|
||||
dofile(handle_schematics.modpath.."/replacements_moreblocks.lua")
|
||||
|
||||
dofile(handle_schematics.modpath.."/replacements_wood.lua")
|
||||
dofile(handle_schematics.modpath.."/replacements_realtest.lua")
|
||||
dofile(handle_schematics.modpath.."/replacements_mineclone2.lua")
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
replacements_group["after_read_file"] = {}
|
||||
|
||||
-- Some mods (like i.e. moreblocks) define aliasses for nodes.
|
||||
-- Schematics are saved with those aliassed names. When we want to restore such a
|
||||
-- schematic, it has "wrong" node names (alias_name) stored ("wrong" in the sense
|
||||
-- of "mod not installed in this world" or "replacements expect other name").
|
||||
--
|
||||
-- The replacements here are applied directly in handle_schematics.analyze_file(..)
|
||||
-- and do not have to be applied manually.
|
||||
--
|
||||
handle_schematics.replacements_revert_alias = function( orig_node_name, alias_name )
|
||||
-- no problem if older definitions are overwritten
|
||||
-- (lets just hope the most recent one is the best one)
|
||||
replacements_group["after_read_file"][ alias_name ] = orig_node_name
|
||||
end
|
|
@ -0,0 +1,89 @@
|
|||
--
|
||||
-- this is taken from Calinous moreblocks mod with his permission.
|
||||
-- See original file here:
|
||||
-- https://github.com/minetest-mods/moreblocks/blob/master/stairsplus/registrations.lua
|
||||
--
|
||||
-- We do need to revert the aliases defined there in moreblocks stairplus mod
|
||||
-- because a) moreblocks might not be installed and b) replacement functions
|
||||
-- expect node names in the stairs:* naming space.
|
||||
|
||||
|
||||
-- default registrations
|
||||
local default_nodes = { -- Default stairs/slabs/panels/microblocks:
|
||||
"stone",
|
||||
"stone_block",
|
||||
"cobble",
|
||||
"mossycobble",
|
||||
"brick",
|
||||
"sandstone",
|
||||
"steelblock",
|
||||
"goldblock",
|
||||
"copperblock",
|
||||
"bronzeblock",
|
||||
"diamondblock",
|
||||
"tinblock",
|
||||
"desert_stone",
|
||||
"desert_stone_block",
|
||||
"desert_cobble",
|
||||
"meselamp",
|
||||
"glass",
|
||||
"tree",
|
||||
"wood",
|
||||
"jungletree",
|
||||
"junglewood",
|
||||
"pine_tree",
|
||||
"pine_wood",
|
||||
"acacia_tree",
|
||||
"acacia_wood",
|
||||
"aspen_tree",
|
||||
"aspen_wood",
|
||||
"obsidian",
|
||||
"obsidian_block",
|
||||
"obsidianbrick",
|
||||
"obsidian_glass",
|
||||
"stonebrick",
|
||||
"desert_stonebrick",
|
||||
"sandstonebrick",
|
||||
"silver_sandstone",
|
||||
"silver_sandstone_brick",
|
||||
"silver_sandstone_block",
|
||||
"desert_sandstone",
|
||||
"desert_sandstone_brick",
|
||||
"desert_sandstone_block",
|
||||
"sandstone_block",
|
||||
"coral_skeleton",
|
||||
"ice",
|
||||
}
|
||||
|
||||
for _, name in pairs(default_nodes) do
|
||||
local mod = "default"
|
||||
local nodename = mod .. ":" .. name
|
||||
mod = "moreblocks"
|
||||
handle_schematics.replacements_revert_alias("stairs:stair_" .. name, mod .. ":stair_" .. name)
|
||||
handle_schematics.replacements_revert_alias("stairs:stair_outer_" .. name, mod .. ":stair_" .. name .. "_outer")
|
||||
handle_schematics.replacements_revert_alias("stairs:stair_inner_" .. name, mod .. ":stair_" .. name .. "_inner")
|
||||
handle_schematics.replacements_revert_alias("stairs:slab_" .. name, mod .. ":slab_" .. name)
|
||||
end
|
||||
|
||||
-- farming registrations
|
||||
if minetest.get_modpath("farming") then
|
||||
local farming_nodes = {"straw"}
|
||||
for _, name in pairs(farming_nodes) do
|
||||
local mod = "farming"
|
||||
local nodename = mod .. ":" .. name
|
||||
|
||||
mod = "moreblocks"
|
||||
handle_schematics.replacements_revert_alias("stairs:stair_" .. name, mod .. ":stair_" .. name)
|
||||
handle_schematics.replacements_revert_alias("stairs:stair_outer_" .. name, mod .. ":stair_" .. name .. "_outer")
|
||||
handle_schematics.replacements_revert_alias("stairs:stair_inner_" .. name, mod .. ":stair_" .. name .. "_inner")
|
||||
handle_schematics.replacements_revert_alias("stairs:slab_" .. name, mod .. ":slab_" .. name)
|
||||
end
|
||||
end
|
||||
|
||||
-- basic_materials, keeping the original other-mod-oriented names
|
||||
-- for backwards compatibility
|
||||
|
||||
if minetest.get_modpath("basic_materials") then
|
||||
handle_schematics.replacements_revert_alias("prefab:concrete_stair","technic:stair_concrete")
|
||||
handle_schematics.replacements_revert_alias("prefab:concrete_slab","technic:slab_concrete")
|
||||
end
|
Loading…
Reference in New Issue