merge upstream

This commit is contained in:
Milan 2022-08-25 17:51:59 +02:00
commit f3be63d874
697 changed files with 8307 additions and 2471 deletions

View file

@ -10,6 +10,8 @@ stairs = {}
-- Load support for MT game translation.
local S = minetest.get_translator("stairs")
-- Same as S, but will be ignored by translation file update scripts
local T = S
-- Register aliases for new pine node names
@ -33,7 +35,13 @@ local function rotate_and_place(itemstack, placer, pointed_thing)
if placer then
local placer_pos = placer:get_pos()
if placer_pos then
param2 = minetest.dir_to_facedir(vector.subtract(p1, placer_pos))
local diff = vector.subtract(p1, placer_pos)
param2 = minetest.dir_to_facedir(diff)
-- The player places a node on the side face of the node he is standing on
if p0.y == p1.y and math.abs(diff.x) <= 0.5 and math.abs(diff.z) <= 0.5 and diff.y < 0 then
-- reverse node direction
param2 = (param2 + 2) % 4
end
end
local finepos = minetest.pointed_thing_to_face_pos(placer, pointed_thing)
@ -58,12 +66,25 @@ local function warn_if_exists(nodename)
end
end
-- get node settings to use for stairs
local function get_node_vars(nodename)
local def = minetest.registered_nodes[nodename]
if def then
return def.light_source, def.use_texture_alpha, def.sunlight_propagates
end
return nil, nil, nil
end
-- Register stair
-- Node will be called stairs:stair_<subname>
function stairs.register_stair(subname, recipeitem, groups, images, description,
sounds, worldaligntex)
local light_source, texture_alpha, sunlight = get_node_vars(recipeitem)
-- Set backface culling and world-aligned textures
local stair_images = {}
for i, image in ipairs(images) do
@ -92,6 +113,9 @@ function stairs.register_stair(subname, recipeitem, groups, images, description,
description = description,
drawtype = "nodebox",
tiles = stair_images,
use_texture_alpha = texture_alpha,
sunlight_propagates = sunlight,
light_source = light_source,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
@ -163,6 +187,8 @@ end
function stairs.register_slab(subname, recipeitem, groups, images, description,
sounds, worldaligntex)
local light_source, texture_alpha, sunlight = get_node_vars(recipeitem)
-- Set world-aligned textures
local slab_images = {}
for i, image in ipairs(images) do
@ -187,6 +213,9 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
description = description,
drawtype = "nodebox",
tiles = slab_images,
use_texture_alpha = texture_alpha,
sunlight_propagates = sunlight,
light_source = light_source,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
@ -200,8 +229,6 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
local under = minetest.get_node(pointed_thing.under)
local wield_item = itemstack:get_name()
local player_name = placer and placer:get_player_name() or ""
local creative_enabled = (creative and creative.is_enabled_for
and creative.is_enabled_for(player_name))
if under and under.name:find("^stairs:slab_") then
-- place slab using under node orientation
@ -220,7 +247,7 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
-- else attempt to place node with proper param2
minetest.item_place_node(ItemStack(wield_item), placer, pointed_thing, p2)
if not creative_enabled then
if not minetest.is_creative_enabled(player_name) then
itemstack:take_item()
end
return itemstack
@ -300,6 +327,8 @@ end
function stairs.register_stair_inner(subname, recipeitem, groups, images,
description, sounds, worldaligntex, full_description)
local light_source, texture_alpha, sunlight = get_node_vars(recipeitem)
-- Set backface culling and world-aligned textures
local stair_images = {}
for i, image in ipairs(images) do
@ -333,6 +362,9 @@ function stairs.register_stair_inner(subname, recipeitem, groups, images,
description = description,
drawtype = "nodebox",
tiles = stair_images,
use_texture_alpha = texture_alpha,
sunlight_propagates = sunlight,
light_source = light_source,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
@ -387,6 +419,8 @@ end
function stairs.register_stair_outer(subname, recipeitem, groups, images,
description, sounds, worldaligntex, full_description)
local light_source, texture_alpha, sunlight = get_node_vars(recipeitem)
-- Set backface culling and world-aligned textures
local stair_images = {}
for i, image in ipairs(images) do
@ -420,6 +454,9 @@ function stairs.register_stair_outer(subname, recipeitem, groups, images,
description = description,
drawtype = "nodebox",
tiles = stair_images,
use_texture_alpha = texture_alpha,
sunlight_propagates = sunlight,
light_source = light_source,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
@ -471,13 +508,14 @@ end
-- Nodes will be called stairs:{stair,slab}_<subname>
function stairs.register_stair_and_slab(subname, recipeitem, groups, images,
desc_stair, desc_slab, sounds, worldaligntex)
desc_stair, desc_slab, sounds, worldaligntex,
desc_stair_inner, desc_stair_outer)
stairs.register_stair(subname, recipeitem, groups, images, desc_stair,
sounds, worldaligntex)
stairs.register_stair_inner(subname, recipeitem, groups, images, desc_stair,
sounds, worldaligntex)
stairs.register_stair_outer(subname, recipeitem, groups, images, desc_stair,
sounds, worldaligntex)
stairs.register_stair_inner(subname, recipeitem, groups, images,
desc_stair, sounds, worldaligntex, desc_stair_inner)
stairs.register_stair_outer(subname, recipeitem, groups, images,
desc_stair, sounds, worldaligntex, desc_stair_outer)
stairs.register_slab(subname, recipeitem, groups, images, desc_slab,
sounds, worldaligntex)
end
@ -488,9 +526,9 @@ local function my_register_stair_and_slab(subname, recipeitem, groups, images,
stairs.register_stair(subname, recipeitem, groups, images, S(desc_stair),
sounds, worldaligntex)
stairs.register_stair_inner(subname, recipeitem, groups, images, "",
sounds, worldaligntex, S("Inner " .. desc_stair))
sounds, worldaligntex, T("Inner " .. desc_stair))
stairs.register_stair_outer(subname, recipeitem, groups, images, "",
sounds, worldaligntex, S("Outer " .. desc_stair))
sounds, worldaligntex, T("Outer " .. desc_stair))
stairs.register_slab(subname, recipeitem, groups, images, S(desc_slab),
sounds, worldaligntex)
end
@ -857,7 +895,7 @@ my_register_stair_and_slab(
{"default_ice.png"},
"Ice Stair",
"Ice Slab",
default.node_sound_glass_defaults(),
default.node_sound_ice_defaults(),
true
)