Prevent tools & nodes from being dropped (#11)

Adds a function to message a player that they cannot drop tools/nodes registered by maptools
This commit is contained in:
shivajiva101 2018-07-27 11:10:09 +01:00 committed by SmallJoker
parent 7459fc3389
commit 106bba39b9
4 changed files with 71 additions and 3 deletions

View File

@ -17,6 +17,7 @@ minetest.register_node("maptools:stone", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_stone_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:stonebrick", {
@ -27,6 +28,7 @@ minetest.register_node("maptools:stonebrick", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_stone_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:tree", {
@ -37,7 +39,8 @@ minetest.register_node("maptools:tree", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_wood_defaults(),
on_place = minetest.rotate_node
on_place = minetest.rotate_node,
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:jungletree", {
@ -48,7 +51,8 @@ minetest.register_node("maptools:jungletree", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_wood_defaults(),
on_place = minetest.rotate_node
on_place = minetest.rotate_node,
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:cactus", {
@ -59,7 +63,8 @@ minetest.register_node("maptools:cactus", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_wood_defaults(),
on_place = minetest.rotate_node
on_place = minetest.rotate_node,
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:papyrus", {
@ -80,6 +85,7 @@ minetest.register_node("maptools:papyrus", {
},
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_leaves_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:dirt", {
@ -90,6 +96,7 @@ minetest.register_node("maptools:dirt", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_dirt_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:wood", {
@ -100,6 +107,7 @@ minetest.register_node("maptools:wood", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_wood_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:junglewood", {
@ -110,6 +118,7 @@ minetest.register_node("maptools:junglewood", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_wood_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:glass", {
@ -123,6 +132,7 @@ minetest.register_node("maptools:glass", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_glass_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:leaves", {
@ -135,6 +145,7 @@ minetest.register_node("maptools:leaves", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_leaves_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:sand", {
@ -145,6 +156,7 @@ minetest.register_node("maptools:sand", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_sand_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:gravel", {
@ -158,6 +170,7 @@ minetest.register_node("maptools:gravel", {
footstep = {name="default_gravel_footstep", gain=0.35},
dug = {name="default_gravel_footstep", gain=0.6},
}),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:clay", {
@ -168,6 +181,7 @@ minetest.register_node("maptools:clay", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_dirt_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:desert_sand", {
@ -178,6 +192,7 @@ minetest.register_node("maptools:desert_sand", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_sand_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:sandstone", {
@ -188,6 +203,7 @@ minetest.register_node("maptools:sandstone", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_stone_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:sandstone_brick", {
@ -198,6 +214,7 @@ minetest.register_node("maptools:sandstone_brick", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_stone_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:desert_stone", {
@ -208,6 +225,7 @@ minetest.register_node("maptools:desert_stone", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_stone_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:desert_cobble", {
@ -218,6 +236,7 @@ minetest.register_node("maptools:desert_cobble", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_stone_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:desert_stonebrick", {
@ -228,6 +247,7 @@ minetest.register_node("maptools:desert_stonebrick", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_stone_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:grass", {
@ -241,6 +261,7 @@ minetest.register_node("maptools:grass", {
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain = 0.4},
}),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:fullgrass", {
@ -253,6 +274,7 @@ minetest.register_node("maptools:fullgrass", {
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.4},
}),
on_drop = maptools.drop_msg
})
for slab_num = 1,3,1 do
@ -272,6 +294,7 @@ for slab_num = 1,3,1 do
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_dirt_defaults({footstep = {name="default_grass_footstep", gain = 0.4}}),
on_drop = maptools.drop_msg
})
end
@ -283,6 +306,7 @@ minetest.register_node("maptools:cobble", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_stone_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:mossycobble", {
@ -293,6 +317,7 @@ minetest.register_node("maptools:mossycobble", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_stone_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:brick", {
@ -303,6 +328,7 @@ minetest.register_node("maptools:brick", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_stone_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:coalblock", {
@ -313,6 +339,7 @@ minetest.register_node("maptools:coalblock", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_stone_defaults(),
on_drop = maptools.drop_msg
})
@ -324,6 +351,7 @@ minetest.register_node("maptools:steelblock", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_stone_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:goldblock", {
@ -334,6 +362,7 @@ minetest.register_node("maptools:goldblock", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_stone_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:copperblock", {
@ -344,6 +373,7 @@ minetest.register_node("maptools:copperblock", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_stone_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:bronzeblock", {
@ -354,6 +384,7 @@ minetest.register_node("maptools:bronzeblock", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_stone_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:diamondblock", {
@ -364,6 +395,7 @@ minetest.register_node("maptools:diamondblock", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_stone_defaults(),
on_drop = maptools.drop_msg
})
-- Farming:
@ -376,6 +408,7 @@ minetest.register_node("maptools:soil_wet", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative, soil = 3, wet = 1, grassland = 1},
sounds = default.node_sound_dirt_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:desert_sand_soil_wet", {
@ -386,4 +419,5 @@ minetest.register_node("maptools:desert_sand_soil_wet", {
tiles = {"farming_desert_sand_soil_wet.png", "farming_desert_sand_soil_wet_side.png"},
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative, soil = 3, wet = 1, desert = 1},
sounds = default.node_sound_sand_defaults(),
on_drop = maptools.drop_msg
})

View File

@ -20,6 +20,11 @@ maptools.intllib = S
local modpath = minetest.get_modpath("maptools")
maptools.drop_msg = function(itemstack, player)
local name = player:get_player_name()
minetest.chat_send_player(name, S("[maptools] tools/nodes do not drop!"))
end
dofile(modpath .. "/config.lua")
dofile(modpath .. "/aliases.lua")
dofile(modpath .. "/craftitems.lua")

View File

@ -16,6 +16,7 @@ minetest.register_node(":default:cloud", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_defaults(),
on_drop = maptools.drop_msg
})
-- Nodes
@ -30,6 +31,7 @@ minetest.register_node("maptools:black", {
post_effect_color = {a=255, r=0, g=0, b=0},
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_stone_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:white", {
@ -41,6 +43,7 @@ minetest.register_node("maptools:white", {
post_effect_color = {a=255, r=128, g=128, b=128},
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_stone_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:playerclip", {
@ -54,6 +57,7 @@ minetest.register_node("maptools:playerclip", {
sunlight_propagates = true,
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:fake_walkable", {
@ -74,6 +78,7 @@ minetest.register_node("maptools:fake_walkable", {
},
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:fullclip", {
@ -86,6 +91,7 @@ minetest.register_node("maptools:fullclip", {
sunlight_propagates = true,
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:fake_walkable_pointable", {
@ -105,6 +111,7 @@ minetest.register_node("maptools:fake_walkable_pointable", {
},
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:ignore_like", {
@ -117,6 +124,7 @@ minetest.register_node("maptools:ignore_like", {
sunlight_propagates = true,
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:ignore_like_no_clip", {
@ -130,6 +138,7 @@ minetest.register_node("maptools:ignore_like_no_clip", {
sunlight_propagates = true,
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
on_drop = maptools.drop_msg
})
@ -144,6 +153,7 @@ minetest.register_node("maptools:ignore_like_no_point", {
sunlight_propagates = true,
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:ignore_like_no_clip_no_point", {
@ -158,6 +168,7 @@ minetest.register_node("maptools:ignore_like_no_clip_no_point", {
sunlight_propagates = true,
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:fullclip_face", {
@ -176,6 +187,7 @@ minetest.register_node("maptools:fullclip_face", {
},
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative, fall_damage_add_percent=-100},
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:playerclip_bottom", {
@ -194,6 +206,7 @@ minetest.register_node("maptools:playerclip_bottom", {
},
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative, fall_damage_add_percent=-100},
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:playerclip_top", {
@ -212,6 +225,7 @@ minetest.register_node("maptools:playerclip_top", {
},
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative, fall_damage_add_percent=-100},
on_drop = maptools.drop_msg
})
for pusher_num=1,10,1 do
@ -231,6 +245,7 @@ minetest.register_node("maptools:pusher_" .. pusher_num, {
},
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative, fall_damage_add_percent=-100, bouncy=pusher_num*100},
on_drop = maptools.drop_msg
})
end
@ -247,6 +262,7 @@ minetest.register_node("maptools:lightbulb", {
sunlight_propagates = true,
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:nobuild", {
@ -261,6 +277,7 @@ minetest.register_node("maptools:nobuild", {
sunlight_propagates = true,
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:nointeract", {
@ -274,6 +291,7 @@ minetest.register_node("maptools:nointeract", {
sunlight_propagates = true,
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:climb", {
@ -289,6 +307,7 @@ minetest.register_node("maptools:climb", {
sunlight_propagates = true,
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
on_drop = maptools.drop_msg
})
for damage_num=1,5,1 do
@ -305,6 +324,7 @@ minetest.register_node("maptools:damage_" .. damage_num, {
sunlight_propagates = true,
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
on_drop = maptools.drop_msg
})
end
@ -321,6 +341,7 @@ minetest.register_node("maptools:kill", {
sunlight_propagates = true,
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:smoke", {
@ -334,6 +355,7 @@ minetest.register_node("maptools:smoke", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
post_effect_color = {a=192, r=96, g=96, b=96},
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:ladder", {
@ -354,6 +376,7 @@ minetest.register_node("maptools:ladder", {
drop = "",
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sounds = default.node_sound_wood_defaults(),
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:permanent_fire", {
@ -373,6 +396,7 @@ minetest.register_node("maptools:permanent_fire", {
sunlight_propagates = true,
walkable = false,
damage_per_second = 4,
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:fake_fire", {
@ -391,6 +415,7 @@ minetest.register_node("maptools:fake_fire", {
groups = {unbreakable = 1, not_in_creative_inventory = maptools.creative},
sunlight_propagates = true,
walkable = false,
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:igniter", {
@ -406,6 +431,7 @@ minetest.register_node("maptools:igniter", {
sunlight_propagates = true,
pointable = false,
walkable = false,
on_drop = maptools.drop_msg
})
minetest.register_node("maptools:superapple", {
@ -426,4 +452,5 @@ minetest.register_node("maptools:superapple", {
groups = {fleshy=3, dig_immediate=3, not_in_creative_inventory = maptools.creative},
on_use = minetest.item_eat(20),
sounds = default.node_sound_defaults(),
on_drop = maptools.drop_msg
})

View File

@ -28,6 +28,7 @@ minetest.register_tool("maptools:pick_admin", {
},
damage_groups = {fleshy = 1000},
},
on_drop = maptools.drop_msg
})
minetest.register_tool("maptools:pick_admin_with_drops", {
@ -49,6 +50,7 @@ minetest.register_tool("maptools:pick_admin_with_drops", {
},
damage_groups = {fleshy = 1000},
},
on_drop = maptools.drop_msg
})
minetest.register_on_punchnode(function(pos, node, puncher)