Compare commits

..

1 Commits

Author SHA1 Message Date
cora d0540c3a1c add a setting to opt-in for selftests 2021-12-14 00:21:34 +01:00
12 changed files with 37 additions and 77 deletions

View File

@ -21,7 +21,7 @@ The basic digging time groups determine by which tools a node can be dug.
* `swordy=1`: Diggable by sword (any material), and this node is *not* a cobweb * `swordy=1`: Diggable by sword (any material), and this node is *not* a cobweb
* `swordy_cobweb=1`: Diggable by sword (any material), and this node is a cobweb * `swordy_cobweb=1`: Diggable by sword (any material), and this node is a cobweb
* `shearsy=1`: Diggable by shears, and this node is *not* wool * `shearsy=1`: Diggable by shears, and this node is *not* wool
* `shearsy_wool=1`: Diggable by shears, and this node is wool * `shearsy=wool=1`: Diggable by shears, and this node is wool
* `handy=1`: Breakable by hand and this node gives it useful drop when dug by hand. All nodes which are breakable by pickaxe, axe, shovel, sword or shears are also automatically breakable by hand, but not neccess * `handy=1`: Breakable by hand and this node gives it useful drop when dug by hand. All nodes which are breakable by pickaxe, axe, shovel, sword or shears are also automatically breakable by hand, but not neccess
* `creative_breakable=1`: Block is breakable by hand in creative mode. This group is implied if the node belongs to any other digging group * `creative_breakable=1`: Block is breakable by hand in creative mode. This group is implied if the node belongs to any other digging group

View File

@ -1,41 +1,6 @@
local S = minetest.get_translator("mcl_chests") local S = minetest.get_translator("mcl_chests")
local mod_doc = minetest.get_modpath("doc") local mod_doc = minetest.get_modpath("doc")
-- Christmas chest setup
local it_is_christmas = false
local date = os.date("*t")
if (
date.month == 12 and (
date.day == 24 or
date.day == 25 or
date.day == 26
)
) then
it_is_christmas = true
end
local tiles_chest_normal_small = {"mcl_chests_normal.png"}
local tiles_chest_normal_double = {"mcl_chests_normal_double.png"}
if it_is_christmas then
tiles_chest_normal_small = {"mcl_chests_normal_present.png^mcl_chests_noise.png"}
tiles_chest_normal_double = {"mcl_chests_normal_double_present.png^mcl_chests_noise_double.png"}
end
local tiles_chest_trapped_small = {"mcl_chests_trapped.png"}
local tiles_chest_trapped_double = {"mcl_chests_trapped_double.png"}
if it_is_christmas then
tiles_chest_trapped_small = {"mcl_chests_trapped_present.png^mcl_chests_noise.png"}
tiles_chest_trapped_double = {"mcl_chests_trapped_double_present.png^mcl_chests_noise_double.png"}
end
local tiles_chest_ender_small = {"mcl_chests_ender.png"}
if it_is_christmas then
tiles_chest_ender_small = {"mcl_chests_ender_present.png^mcl_chests_noise.png"}
end
-- Chest Entity -- Chest Entity
local animate_chests = (minetest.settings:get_bool("animated_chests") ~= false) local animate_chests = (minetest.settings:get_bool("animated_chests") ~= false)
local entity_animations = { local entity_animations = {
@ -256,12 +221,12 @@ local chest_update_after_close = function(pos)
minetest.swap_node(pos, {name="mcl_chests:trapped_chest_small", param2 = node.param2}) minetest.swap_node(pos, {name="mcl_chests:trapped_chest_small", param2 = node.param2})
if animate_chests then if animate_chests then
find_or_create_entity(pos, "mcl_chests:trapped_chest_small", tiles_chest_trapped_small, node.param2, false, "default_chest", "mcl_chests_chest", "chest"):reinitialize("mcl_chests:trapped_chest_small") find_or_create_entity(pos, "mcl_chests:trapped_chest_small", {"mcl_chests_trapped.png"}, node.param2, false, "default_chest", "mcl_chests_chest", "chest"):reinitialize("mcl_chests:trapped_chest_small")
end end
mesecon.receptor_off(pos, trapped_chest_mesecons_rules) mesecon.receptor_off(pos, trapped_chest_mesecons_rules)
elseif node.name == "mcl_chests:trapped_chest_on_left" then elseif node.name == "mcl_chests:trapped_chest_on_left" then
minetest.swap_node(pos, {name="mcl_chests:trapped_chest_left", param2 = node.param2}) minetest.swap_node(pos, {name="mcl_chests:trapped_chest_left", param2 = node.param2})
find_or_create_entity(pos, "mcl_chests:trapped_chest_left", tiles_chest_trapped_double, node.param2, true, "default_chest", "mcl_chests_chest", "chest"):reinitialize("mcl_chests:trapped_chest_left") find_or_create_entity(pos, "mcl_chests:trapped_chest_left", {"mcl_chests_trapped_double.png"}, node.param2, true, "default_chest", "mcl_chests_chest", "chest"):reinitialize("mcl_chests:trapped_chest_left")
mesecon.receptor_off(pos, trapped_chest_mesecons_rules) mesecon.receptor_off(pos, trapped_chest_mesecons_rules)
local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "left") local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "left")
@ -273,7 +238,7 @@ local chest_update_after_close = function(pos)
local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "right") local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "right")
minetest.swap_node(pos_other, {name="mcl_chests:trapped_chest_left", param2 = node.param2}) minetest.swap_node(pos_other, {name="mcl_chests:trapped_chest_left", param2 = node.param2})
find_or_create_entity(pos_other, "mcl_chests:trapped_chest_left", tiles_chest_trapped_double, node.param2, true, "default_chest", "mcl_chests_chest", "chest"):reinitialize("mcl_chests:trapped_chest_left") find_or_create_entity(pos_other, "mcl_chests:trapped_chest_left", {"mcl_chests_trapped_double.png"}, node.param2, true, "default_chest", "mcl_chests_chest", "chest"):reinitialize("mcl_chests:trapped_chest_left")
mesecon.receptor_off(pos_other, trapped_chest_mesecons_rules) mesecon.receptor_off(pos_other, trapped_chest_mesecons_rules)
end end
end end
@ -884,8 +849,8 @@ register_chest("chest",
chestusage, chestusage,
S("27 inventory slots") .. "\n" .. S("Can be combined to a large chest"), S("27 inventory slots") .. "\n" .. S("Can be combined to a large chest"),
{ {
small = tiles_chest_normal_small, small = {"mcl_chests_normal.png"},
double = tiles_chest_normal_double, double = {"mcl_chests_normal_double.png"},
inv = {"default_chest_top.png", "mcl_chests_chest_bottom.png", inv = {"default_chest_top.png", "mcl_chests_chest_bottom.png",
"mcl_chests_chest_right.png", "mcl_chests_chest_left.png", "mcl_chests_chest_right.png", "mcl_chests_chest_left.png",
"mcl_chests_chest_back.png", "default_chest_front.png"}, "mcl_chests_chest_back.png", "default_chest_front.png"},
@ -900,8 +865,8 @@ register_chest("chest",
) )
local traptiles = { local traptiles = {
small = tiles_chest_trapped_small, small = {"mcl_chests_trapped.png"},
double = tiles_chest_trapped_double, double = {"mcl_chests_trapped_double.png"},
inv = {"mcl_chests_chest_trapped_top.png", "mcl_chests_chest_trapped_bottom.png", inv = {"mcl_chests_chest_trapped_top.png", "mcl_chests_chest_trapped_bottom.png",
"mcl_chests_chest_trapped_right.png", "mcl_chests_chest_trapped_left.png", "mcl_chests_chest_trapped_right.png", "mcl_chests_chest_trapped_left.png",
"mcl_chests_chest_trapped_back.png", "mcl_chests_chest_trapped_front.png"}, "mcl_chests_chest_trapped_back.png", "mcl_chests_chest_trapped_front.png"},
@ -927,7 +892,7 @@ register_chest("trapped_chest",
function(pos, node, clicker) function(pos, node, clicker)
minetest.swap_node(pos, {name="mcl_chests:trapped_chest_on_small", param2 = node.param2}) minetest.swap_node(pos, {name="mcl_chests:trapped_chest_on_small", param2 = node.param2})
if animate_chests then if animate_chests then
find_or_create_entity(pos, "mcl_chests:trapped_chest_on_small", tiles_chest_trapped_small, node.param2, false, "default_chest", "mcl_chests_chest", "chest"):reinitialize("mcl_chests:trapped_chest_on_small") find_or_create_entity(pos, "mcl_chests:trapped_chest_on_small", {"mcl_chests_trapped.png"}, node.param2, false, "default_chest", "mcl_chests_chest", "chest"):reinitialize("mcl_chests:trapped_chest_on_small")
end end
mesecon.receptor_on(pos, trapped_chest_mesecons_rules) mesecon.receptor_on(pos, trapped_chest_mesecons_rules)
end, end,
@ -936,7 +901,7 @@ register_chest("trapped_chest",
meta:set_int("players", 1) meta:set_int("players", 1)
minetest.swap_node(pos, {name="mcl_chests:trapped_chest_on_left", param2 = node.param2}) minetest.swap_node(pos, {name="mcl_chests:trapped_chest_on_left", param2 = node.param2})
find_or_create_entity(pos, "mcl_chests:trapped_chest_on_left", tiles_chest_trapped_double, node.param2, true, "default_chest", "mcl_chests_chest", "chest"):reinitialize("mcl_chests:trapped_chest_on_left") find_or_create_entity(pos, "mcl_chests:trapped_chest_on_left", {"mcl_chests_trapped_double.png"}, node.param2, true, "default_chest", "mcl_chests_chest", "chest"):reinitialize("mcl_chests:trapped_chest_on_left")
mesecon.receptor_on(pos, trapped_chest_mesecons_rules) mesecon.receptor_on(pos, trapped_chest_mesecons_rules)
local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "left") local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "left")
@ -950,7 +915,7 @@ register_chest("trapped_chest",
mesecon.receptor_on(pos, trapped_chest_mesecons_rules) mesecon.receptor_on(pos, trapped_chest_mesecons_rules)
minetest.swap_node(pos_other, {name="mcl_chests:trapped_chest_on_left", param2 = node.param2}) minetest.swap_node(pos_other, {name="mcl_chests:trapped_chest_on_left", param2 = node.param2})
find_or_create_entity(pos_other, "mcl_chests:trapped_chest_on_left", tiles_chest_trapped_double, node.param2, true, "default_chest", "mcl_chests_chest", "chest"):reinitialize("mcl_chests:trapped_chest_on_left") find_or_create_entity(pos_other, "mcl_chests:trapped_chest_on_left", {"mcl_chests_trapped_double.png"}, node.param2, true, "default_chest", "mcl_chests_chest", "chest"):reinitialize("mcl_chests:trapped_chest_on_left")
mesecon.receptor_on(pos_other, trapped_chest_mesecons_rules) mesecon.receptor_on(pos_other, trapped_chest_mesecons_rules)
end end
) )
@ -972,14 +937,14 @@ local function close_if_trapped_chest(pos, player)
if node.name == "mcl_chests:trapped_chest_on_small" then if node.name == "mcl_chests:trapped_chest_on_small" then
minetest.swap_node(pos, {name="mcl_chests:trapped_chest_small", param2 = node.param2}) minetest.swap_node(pos, {name="mcl_chests:trapped_chest_small", param2 = node.param2})
if animate_chests then if animate_chests then
find_or_create_entity(pos, "mcl_chests:trapped_chest_small", tiles_chest_trapped_small, node.param2, false, "default_chest", "mcl_chests_chest", "chest"):reinitialize("mcl_chests:trapped_chest_small") find_or_create_entity(pos, "mcl_chests:trapped_chest_small", {"mcl_chests_trapped.png"}, node.param2, false, "default_chest", "mcl_chests_chest", "chest"):reinitialize("mcl_chests:trapped_chest_small")
end end
mesecon.receptor_off(pos, trapped_chest_mesecons_rules) mesecon.receptor_off(pos, trapped_chest_mesecons_rules)
player_chest_close(player) player_chest_close(player)
elseif node.name == "mcl_chests:trapped_chest_on_left" then elseif node.name == "mcl_chests:trapped_chest_on_left" then
minetest.swap_node(pos, {name="mcl_chests:trapped_chest_left", param2 = node.param2}) minetest.swap_node(pos, {name="mcl_chests:trapped_chest_left", param2 = node.param2})
find_or_create_entity(pos, "mcl_chests:trapped_chest_left", tiles_chest_trapped_double, node.param2, true, "default_chest", "mcl_chests_chest", "chest"):reinitialize("mcl_chests:trapped_chest_left") find_or_create_entity(pos, "mcl_chests:trapped_chest_left", {"mcl_chests_trapped_double.png"}, node.param2, true, "default_chest", "mcl_chests_chest", "chest"):reinitialize("mcl_chests:trapped_chest_left")
mesecon.receptor_off(pos, trapped_chest_mesecons_rules) mesecon.receptor_off(pos, trapped_chest_mesecons_rules)
local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "left") local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "left")
@ -993,7 +958,7 @@ local function close_if_trapped_chest(pos, player)
local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "right") local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "right")
minetest.swap_node(pos_other, {name="mcl_chests:trapped_chest_left", param2 = node.param2}) minetest.swap_node(pos_other, {name="mcl_chests:trapped_chest_left", param2 = node.param2})
find_or_create_entity(pos_other, "mcl_chests:trapped_chest_left", tiles_chest_trapped_double, node.param2, true, "default_chest", "mcl_chests_chest", "chest"):reinitialize("mcl_chests:trapped_chest_left") find_or_create_entity(pos_other, "mcl_chests:trapped_chest_left", {"mcl_chests_trapped_double.png"}, node.param2, true, "default_chest", "mcl_chests_chest", "chest"):reinitialize("mcl_chests:trapped_chest_left")
mesecon.receptor_off(pos_other, trapped_chest_mesecons_rules) mesecon.receptor_off(pos_other, trapped_chest_mesecons_rules)
player_chest_close(player) player_chest_close(player)
@ -1041,7 +1006,7 @@ minetest.register_node("mcl_chests:ender_chest", {
_doc_items_usagehelp = S("Rightclick the ender chest to access your personal interdimensional inventory."), _doc_items_usagehelp = S("Rightclick the ender chest to access your personal interdimensional inventory."),
drawtype = "mesh", drawtype = "mesh",
mesh = "mcl_chests_chest.obj", mesh = "mcl_chests_chest.obj",
tiles = tiles_chest_ender_small, tiles = {"mcl_chests_ender.png"},
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false,
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
@ -1094,8 +1059,8 @@ minetest.register_node("mcl_chests:ender_chest_small", {
type = "fixed", type = "fixed",
fixed = {-0.4375, -0.5, -0.4375, 0.4375, 0.375, 0.4375}, fixed = {-0.4375, -0.5, -0.4375, 0.4375, 0.375, 0.4375},
}, },
tiles = animate_chests and {"mcl_chests_blank.png"} or tiles_chest_ender_small, tiles = animate_chests and {"mcl_chests_blank.png"} or {"mcl_chests_ender.png"},
_chest_entity_textures = tiles_chest_ender_small, _chest_entity_textures = {"mcl_chests_ender.png"},
_chest_entity_sound = "mcl_chests_enderchest", _chest_entity_sound = "mcl_chests_enderchest",
_chest_entity_mesh = "mcl_chests_chest", _chest_entity_mesh = "mcl_chests_chest",
_chest_entity_animation_type = "chest", _chest_entity_animation_type = "chest",
@ -1117,11 +1082,11 @@ minetest.register_node("mcl_chests:ender_chest_small", {
meta:set_string("formspec", formspec_ender_chest) meta:set_string("formspec", formspec_ender_chest)
if animate_chests then if animate_chests then
create_entity(pos, "mcl_chests:ender_chest_small", tiles_chest_ender_small, minetest.get_node(pos).param2, false, "mcl_chests_enderchest", "mcl_chests_chest", "chest") create_entity(pos, "mcl_chests:ender_chest_small", {"mcl_chests_ender.png"}, minetest.get_node(pos).param2, false, "mcl_chests_enderchest", "mcl_chests_chest", "chest")
end end
end, end,
on_rightclick = function(pos, node, clicker) on_rightclick = function(pos, node, clicker)
player_chest_open(clicker, pos, "mcl_chests:ender_chest_small", tiles_chest_ender_small, node.param2, false, "mcl_chests_enderchest", "mcl_chests_chest") player_chest_open(clicker, pos, "mcl_chests:ender_chest_small", {"mcl_chests_ender.png"}, node.param2, false, "mcl_chests_enderchest", "mcl_chests_chest")
end, end,
on_receive_fields = function(pos, formname, fields, sender) on_receive_fields = function(pos, formname, fields, sender)
if fields.quit then if fields.quit then

Binary file not shown.

Before

Width:  |  Height:  |  Size: 286 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 286 B

View File

@ -388,11 +388,12 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s
{ x=0, y=0, z=-1 }, { x=0, y=0, z=-1 },
{ x=0, y=0, z=1 }, { x=0, y=0, z=1 },
} }
local floorpos, floor
for n=#neighbors, 1, -1 do for n=#neighbors, 1, -1 do
local offset = neighbors[n] local offset = neighbors[n]
local blockpos = vector.add(stempos, offset) local blockpos = vector.add(stempos, offset)
local floorpos = { x=blockpos.x, y=blockpos.y-1, z=blockpos.z } floorpos = { x=blockpos.x, y=blockpos.y-1, z=blockpos.z }
local floor = minetest.get_node(floorpos) floor = minetest.get_node(floorpos)
local block = minetest.get_node(blockpos) local block = minetest.get_node(blockpos)
local soilgroup = minetest.get_item_group(floor.name, "soil") local soilgroup = minetest.get_item_group(floor.name, "soil")
if not ((minetest.get_item_group(floor.name, "grass_block") == 1 or floor.name=="mcl_core:dirt" or soilgroup == 2 or soilgroup == 3) and block.name == "air") then if not ((minetest.get_item_group(floor.name, "grass_block") == 1 or floor.name=="mcl_core:dirt" or soilgroup == 2 or soilgroup == 3) and block.name == "air") then
@ -406,8 +407,6 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s
local r = math.random(1, #neighbors) local r = math.random(1, #neighbors)
local offset = neighbors[r] local offset = neighbors[r]
local blockpos = vector.add(stempos, offset) local blockpos = vector.add(stempos, offset)
local floorpos = { x=blockpos.x, y=blockpos.y-1, z=blockpos.z }
local floor = minetest.get_node(floorpos)
local p2 local p2
if offset.x == 1 then if offset.x == 1 then
minetest.set_node(stempos, {name=connected_stem_names[1]}) minetest.set_node(stempos, {name=connected_stem_names[1]})

View File

@ -75,25 +75,15 @@ local test_minetest_find_nodes_in_area_can_count = function(dtime)
local nodes_expected = math.pow( 1 + (2 * radius), 3 ) local nodes_expected = math.pow( 1 + (2 * radius), 3 )
local nodes_counted = nnum[nodename] local nodes_counted = nnum[nodename]
local nodes_difference = nodes_expected - nodes_counted local nodes_difference = nodes_expected - nodes_counted
-- Originally, there was an assertion here that made the game -- Yes, the following line is supposed to crash the game in
-- crash at startup if Minetest forgot how to count. This was -- the case that Minetest forgot how to count the number of
-- originally intended to avoid buggy engine releases, but it -- nodes in a three dimensional volume it just filled. This
-- mostly made people upset and hindered debugging. Also, the -- function contains an excellent explanation on what not to
-- assertion contained no error message hinting at the reason -- do further up. I strongly suggest to pester Minetest core
-- for the crash, making it exceptionally user-unfriendly. It -- devs about this issue and not the author of the function,
-- follows that a game or mod should only assert on behaviour -- should this test ever fail.
-- of the Lua code, not the underlying implementation, unless assert ( 0 == nodes_difference )
-- engine bugs are bad enough to permanently corrupt a world.
if ( 0 ~= nodes_difference ) then
minetest.debug(
"minetest.find_nodes_in_area() failed to find " ..
nodes_difference .. " nodes that were placed. " ..
"Downgrading to Minetest 5.4.1 might fix this."
)
end end
end
minetest.after( 0, test_minetest_find_nodes_in_area_can_count )
local test_minetest_find_nodes_in_area_crash = function(dtime) local test_minetest_find_nodes_in_area_crash = function(dtime)
-- And now for our feature presentation, where we call the -- And now for our feature presentation, where we call the
@ -118,4 +108,7 @@ local test_minetest_find_nodes_in_area_crash = function(dtime)
-- That's all, folks! -- That's all, folks!
end end
if minetest.settings:get_bool("mclRunSelftests") then
minetest.after( 0, test_minetest_find_nodes_in_area_can_count )
minetest.after( 0, test_minetest_find_nodes_in_area_crash ) minetest.after( 0, test_minetest_find_nodes_in_area_crash )
end

View File

@ -146,3 +146,6 @@ basic_pseudobiome_villages (Enables very basic, and experimental "pseudobiome-ba
# If enabled, will run an LBM to fix the top 1/2 of double plants in mcimported worlds; defaults to true. # If enabled, will run an LBM to fix the top 1/2 of double plants in mcimported worlds; defaults to true.
fix_doubleplants (Mcimport double plant fixes) bool true fix_doubleplants (Mcimport double plant fixes) bool true
# Run tests on startup, crash if they fail. Particularly useful for development.
mclRunSelftests (Run Selftests on Startup) bool false