better creative mode checks, fix crash when digging walls in MCL

This commit is contained in:
FaceDeer 2022-08-24 20:41:24 -06:00
parent 464f0f161b
commit 0cd2c9590f
9 changed files with 22 additions and 8 deletions

View File

@ -1,3 +1,5 @@
The DF_Caverns modpack was originally written based on the minetest_game. It made extensive use of various nodes and helper functions that came from minetest_game's constituent mods.
When Mineclone games rose in popularity, the task of making it compatible was a daunting one - there were dependencies on minetest_game's mods scattered everywhere. To make the task manageable, I created this mod to serve as a central location where analogous objects could be taken from those games to be referenced in a generic way.
This requires abusing the "dependencies" system of Minetest, unfortunately. This mod is an enormous collection of either/or dependencies - things that can come from either mod A or mod B, but must come from one of them.

View File

@ -167,7 +167,7 @@ local place_seed = function(itemstack, placer, pointed_thing, plantname)
end
end
if not minetest.settings:get_bool("creative_mode", false) then
if not minetest.is_creative_enabled(placer:get_player_name()) then
itemstack:take_item()
end
return itemstack

View File

@ -77,7 +77,7 @@ local plump_helmet_on_place = function(itemstack, placer, pointed_thing, plantn
end
end
if not minetest.settings:get_bool("creative_mode", false) then
if not minetest.is_creative_enabled(placer:get_player_name()) then
itemstack:take_item()
end
return itemstack

View File

@ -59,7 +59,7 @@ df_mapitems.place_against_surface = function(itemstack, placer, pointed_thing)
end
-- add the node and remove 1 item from the itemstack
minetest.add_node(above_pos, {name = itemstack:get_name(), param2 = param2})
if not minetest.settings:get_bool("creative_mode", false) and not minetest.check_player_privs(placer, "creative") then
if not minetest.is_creative_enabled(placer:get_player_name()) then
itemstack:take_item()
end
return itemstack

View File

@ -70,7 +70,7 @@ local stem_on_place = function(itemstack, placer, pointed_thing)
end
end
if (not minetest.settings:get_bool("creative_mode", false)) and take_item then
if not minetest.is_creative_enabled(placer:get_player_name()) and take_item then
itemstack:take_item()
end
return itemstack

View File

@ -71,7 +71,7 @@ local stal_on_place = function(itemstack, placer, pointed_thing)
end
end
if (not minetest.settings:get_bool("creative_mode", false)) and take_item then
if not minetest.is_creative_enabled(placer:get_player_name()) and take_item then
itemstack:take_item()
end
return itemstack

View File

@ -47,7 +47,7 @@ local punch_fix = function(pos, node, puncher, pointed_thing)
if wielded:get_name() == mese_crystal_node then
minetest.set_node(pos, {name="df_underworld_items:ancient_lantern_slade"})
minetest.get_node_timer(pos):stop()
if not (creative and creative.is_enabled_for and creative.is_enabled_for(puncher:get_player_name())) then
if not minetest.is_creative_enabled(puncher:get_player_name()) then
wielded:take_item()
puncher:set_wielded_item(wielded)
end

View File

@ -57,7 +57,9 @@ if invulnerable then
end
minetest.register_node("df_underworld_items:slade_brick", slade_brick_def)
local slade_wall_groups = {wall=1}
-- can't use "wall=1" because MCL has special handling for nodes in that group that explodes if it tries handling this one.
-- fortunately minetest_game walls also connect to group fence, so this should be fine.
local slade_wall_groups = {fence=1}
for key, val in pairs(slade_groups) do
slade_wall_groups[key]=val
end

View File

@ -1,5 +1,15 @@
looped_node_sound = {}
--looped_node_sound.register({
-- node_list = {},
-- sound = <SimpleSoundSpec>,
-- radius = ,
-- cycle_time =,
-- gain_per_node =,
-- max_gain =,
-- max_hear_distance =,
--})
looped_node_sound.register = function(def)
local handles = {}
local timer = 0