2023-06-30 17:52:49 +03:00
|
|
|
local S = minetest.get_translator("xdecor")
|
|
|
|
|
2023-07-17 17:00:05 +03:00
|
|
|
xdecor.xbg = default.gui_bg .. default.gui_bg_img .. default.gui_slots
|
2015-06-09 15:04:57 +03:00
|
|
|
local default_inventory_size = 32
|
2015-12-21 02:46:16 +03:00
|
|
|
|
2015-06-09 15:04:57 +03:00
|
|
|
local default_inventory_formspecs = {
|
2015-12-30 22:08:39 +03:00
|
|
|
["8"] = [[ size[8,6]
|
|
|
|
list[context;main;0,0;8,1;]
|
|
|
|
list[current_player;main;0,2;8,4;]
|
|
|
|
listring[current_player;main]
|
2019-07-23 15:03:20 +03:00
|
|
|
listring[context;main] ]] ..
|
|
|
|
default.get_hotbar_bg(0,2),
|
2015-06-09 15:04:57 +03:00
|
|
|
|
2015-12-30 22:08:39 +03:00
|
|
|
["16"] = [[ size[8,7]
|
|
|
|
list[context;main;0,0;8,2;]
|
|
|
|
list[current_player;main;0,3;8,4;]
|
|
|
|
listring[current_player;main]
|
2019-07-23 15:03:20 +03:00
|
|
|
listring[context;main] ]] ..
|
|
|
|
default.get_hotbar_bg(0,3),
|
2015-06-09 15:04:57 +03:00
|
|
|
|
2015-12-30 22:08:39 +03:00
|
|
|
["24"] = [[ size[8,8]
|
|
|
|
list[context;main;0,0;8,3;]
|
|
|
|
list[current_player;main;0,4;8,4;]
|
|
|
|
listring[current_player;main]
|
2019-07-23 15:03:20 +03:00
|
|
|
listring[context;main]" ]] ..
|
|
|
|
default.get_hotbar_bg(0,4),
|
2015-06-09 15:04:57 +03:00
|
|
|
|
2015-12-30 22:08:39 +03:00
|
|
|
["32"] = [[ size[8,9]
|
|
|
|
list[context;main;0,0.3;8,4;]
|
|
|
|
list[current_player;main;0,4.85;8,1;]
|
|
|
|
list[current_player;main;0,6.08;8,3;8]
|
|
|
|
listring[current_player;main]
|
2019-07-23 15:03:20 +03:00
|
|
|
listring[context;main] ]] ..
|
|
|
|
default.get_hotbar_bg(0,4.85)
|
2015-06-09 15:04:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
local function get_formspec_by_size(size)
|
|
|
|
local formspec = default_inventory_formspecs[tostring(size)]
|
|
|
|
return formspec or default_inventory_formspecs
|
|
|
|
end
|
|
|
|
|
2016-04-02 22:34:00 +03:00
|
|
|
local default_can_dig = function(pos)
|
|
|
|
local inv = minetest.get_meta(pos):get_inventory()
|
|
|
|
return inv:is_empty("main")
|
2015-12-06 20:39:30 +03:00
|
|
|
end
|
|
|
|
|
2019-07-23 15:03:20 +03:00
|
|
|
local function xdecor_stairs_alternative(nodename, def)
|
2017-08-28 08:41:14 +03:00
|
|
|
local mod, name = nodename:match("(.*):(.*)")
|
2019-07-23 15:03:20 +03:00
|
|
|
|
2017-08-28 08:41:14 +03:00
|
|
|
for groupname, value in pairs(def.groups) do
|
2018-03-08 23:12:21 +03:00
|
|
|
if groupname ~= "cracky" and groupname ~= "choppy" and
|
|
|
|
groupname ~= "flammable" and groupname ~= "crumbly" and
|
2019-07-23 15:03:20 +03:00
|
|
|
groupname ~= "snappy" then
|
2017-08-28 08:41:14 +03:00
|
|
|
def.groups.groupname = nil
|
|
|
|
end
|
2018-03-08 23:12:21 +03:00
|
|
|
end
|
|
|
|
|
2017-08-28 08:41:14 +03:00
|
|
|
if minetest.get_modpath("moreblocks") then
|
|
|
|
stairsplus:register_all(
|
|
|
|
mod,
|
|
|
|
name,
|
|
|
|
nodename,
|
|
|
|
{
|
|
|
|
description = def.description,
|
|
|
|
tiles = def.tiles,
|
|
|
|
groups = def.groups,
|
|
|
|
sounds = def.sounds,
|
|
|
|
}
|
|
|
|
)
|
2019-07-23 15:03:20 +03:00
|
|
|
elseif minetest.get_modpath("stairs") then
|
2023-06-30 21:40:17 +03:00
|
|
|
local custom_tiles = xdecor.glasscuts[nodename]
|
|
|
|
if custom_tiles and (custom_tiles.slab or custom_tiles.stair) then
|
|
|
|
if custom_tiles.stair then
|
|
|
|
stairs.register_stair(name, nodename,
|
|
|
|
def.groups, custom_tiles.stair, S("@1 Stair", def.description),
|
|
|
|
def.sounds)
|
|
|
|
stairs.register_stair_inner(name, nodename,
|
|
|
|
def.groups, custom_tiles.stair_inner, "", def.sounds, nil, S("Inner @1 Stair", def.description))
|
|
|
|
stairs.register_stair_outer(name, nodename,
|
|
|
|
def.groups, custom_tiles.stair_outer, "", def.sounds, nil, S("Outer @1 Stair", def.description))
|
|
|
|
end
|
|
|
|
if custom_tiles.slab then
|
|
|
|
stairs.register_slab(name, nodename,
|
|
|
|
def.groups, custom_tiles.slab, S("@1 Slab", def.description),
|
|
|
|
def.sounds)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
stairs.register_stair_and_slab(name,nodename,
|
|
|
|
def.groups,
|
|
|
|
def.tiles,
|
|
|
|
S("@1 Stair", def.description),
|
|
|
|
S("@1 Slab", def.description),
|
2023-06-30 21:54:54 +03:00
|
|
|
def.sounds, nil,
|
|
|
|
S("Inner @1 Stair", def.description),
|
|
|
|
S("Outer @1 Stair", def.description)
|
2023-06-30 21:40:17 +03:00
|
|
|
)
|
|
|
|
end
|
2019-07-23 15:03:20 +03:00
|
|
|
end
|
2017-08-28 08:41:14 +03:00
|
|
|
end
|
2018-03-08 23:12:21 +03:00
|
|
|
|
2019-07-23 15:03:20 +03:00
|
|
|
function xdecor.register(name, def)
|
2016-12-05 14:58:35 +03:00
|
|
|
def.drawtype = def.drawtype or (def.mesh and "mesh") or (def.node_box and "nodebox")
|
2015-06-16 19:47:29 +03:00
|
|
|
def.sounds = def.sounds or default.node_sound_defaults()
|
2015-12-21 02:46:16 +03:00
|
|
|
|
|
|
|
if not (def.drawtype == "normal" or def.drawtype == "signlike" or
|
|
|
|
def.drawtype == "plantlike" or def.drawtype == "glasslike_framed" or
|
|
|
|
def.drawtype == "glasslike_framed_optional") then
|
2015-06-13 15:43:36 +03:00
|
|
|
def.paramtype2 = def.paramtype2 or "facedir"
|
|
|
|
end
|
2015-06-09 15:04:57 +03:00
|
|
|
|
2016-10-09 20:54:56 +03:00
|
|
|
if def.sunlight_propagates ~= false and
|
|
|
|
(def.drawtype == "plantlike" or def.drawtype == "torchlike" or
|
|
|
|
def.drawtype == "signlike" or def.drawtype == "fencelike") then
|
2015-08-07 02:33:38 +03:00
|
|
|
def.sunlight_propagates = true
|
|
|
|
end
|
|
|
|
|
2016-10-09 20:54:56 +03:00
|
|
|
if not def.paramtype and
|
|
|
|
(def.light_source or def.sunlight_propagates or
|
|
|
|
def.drawtype == "nodebox" or def.drawtype == "mesh") then
|
|
|
|
def.paramtype = "light"
|
|
|
|
end
|
|
|
|
|
2015-06-09 15:04:57 +03:00
|
|
|
local infotext = def.infotext
|
|
|
|
local inventory = def.inventory
|
|
|
|
def.inventory = nil
|
|
|
|
|
|
|
|
if inventory then
|
|
|
|
def.on_construct = def.on_construct or function(pos)
|
|
|
|
local meta = minetest.get_meta(pos)
|
2016-02-12 17:00:44 +03:00
|
|
|
if infotext then meta:set_string("infotext", infotext) end
|
2015-12-21 02:46:16 +03:00
|
|
|
|
2015-06-09 15:04:57 +03:00
|
|
|
local size = inventory.size or default_inventory_size
|
2015-08-16 22:57:17 +03:00
|
|
|
local inv = meta:get_inventory()
|
2019-07-23 15:03:20 +03:00
|
|
|
|
2015-08-16 22:57:17 +03:00
|
|
|
inv:set_size("main", size)
|
2019-07-23 15:03:20 +03:00
|
|
|
meta:set_string("formspec",
|
2023-07-21 16:04:47 +03:00
|
|
|
(inventory.formspec or get_formspec_by_size(size)) .. xdecor.xbg)
|
2015-06-09 15:04:57 +03:00
|
|
|
end
|
2019-07-23 15:03:20 +03:00
|
|
|
|
2016-04-02 22:34:00 +03:00
|
|
|
def.can_dig = def.can_dig or default_can_dig
|
2019-07-23 15:03:20 +03:00
|
|
|
|
2015-06-09 15:04:57 +03:00
|
|
|
elseif infotext and not def.on_construct then
|
|
|
|
def.on_construct = function(pos)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
meta:set_string("infotext", infotext)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-07-23 15:03:20 +03:00
|
|
|
minetest.register_node("xdecor:" .. name, def)
|
2018-03-08 23:12:21 +03:00
|
|
|
|
2018-04-02 19:27:16 +03:00
|
|
|
local workbench = minetest.settings:get_bool("enable_xdecor_workbench")
|
|
|
|
|
|
|
|
if workbench == false and
|
2019-07-23 15:03:20 +03:00
|
|
|
(minetest.get_modpath("moreblocks") or minetest.get_modpath("stairs")) then
|
2017-08-28 08:41:14 +03:00
|
|
|
if xdecor.stairs_valid_def(def) then
|
|
|
|
xdecor_stairs_alternative("xdecor:"..name, def)
|
|
|
|
end
|
|
|
|
end
|
2015-06-09 15:04:57 +03:00
|
|
|
end
|
2023-07-20 01:48:49 +03:00
|
|
|
|
|
|
|
-- Registers aliases for a node that had a name collision
|
|
|
|
-- with a node from the moreblocks mod
|
|
|
|
function xdecor.register_moreblocks_aliases(original_basename, new_basename)
|
|
|
|
minetest.register_alias("xdecor:"..original_basename, "xdecor:"..new_basename)
|
|
|
|
minetest.register_alias("xdecor:"..original_basename.."_panel", "xdecor:"..new_basename.."_panel")
|
|
|
|
minetest.register_alias("xdecor:"..original_basename.."_doublepanel", "xdecor:"..new_basename.."_doublepanel")
|
|
|
|
minetest.register_alias("xdecor:"..original_basename.."_micropanel", "xdecor:"..new_basename.."_micropanel")
|
|
|
|
minetest.register_alias("xdecor:"..original_basename.."_halfstair", "xdecor:"..new_basename.."_halfstair")
|
|
|
|
minetest.register_alias("xdecor:"..original_basename.."_thinstair", "xdecor:"..new_basename.."_thinstair")
|
|
|
|
minetest.register_alias("xdecor:"..original_basename.."_cube", "xdecor:"..new_basename.."_cube")
|
|
|
|
minetest.register_alias("xdecor:"..original_basename.."_microslab", "xdecor:"..new_basename.."_microslab")
|
|
|
|
minetest.register_alias("xdecor:"..original_basename.."_nanoslab", "xdecor:"..new_basename.."_nanoslab")
|
|
|
|
if not minetest.get_modpath("moreblocks") then
|
|
|
|
minetest.register_alias("stairs:slab_"..original_basename, "stairs:slab_"..new_basename)
|
|
|
|
minetest.register_alias("stairs:stair_"..original_basename, "stairs:stair_"..new_basename)
|
|
|
|
minetest.register_alias("stairs:stair_outer_"..original_basename, "stairs:stair_outer_"..new_basename)
|
|
|
|
minetest.register_alias("stairs:stair_inner_"..original_basename, "stairs:stair_inner"..new_basename)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|