2015-07-05 21:01:27 +02:00
|
|
|
local load_time_start = os.clock()
|
|
|
|
|
|
|
|
local newhand = {
|
|
|
|
wield_image = "wield_dummy.png^[combine:16x16:2,2=wield_dummy.png:-52,-23=character.png^[transformfy",
|
|
|
|
wield_scale = {x=1.8,y=1,z=2.8},
|
|
|
|
}
|
|
|
|
|
2013-11-20 16:32:21 +01:00
|
|
|
if minetest.setting_getbool("creative_mode") then
|
2015-07-05 21:01:27 +02:00
|
|
|
newhand.range = 14
|
2014-03-15 14:42:32 +01:00
|
|
|
|
|
|
|
local function add_to_inv(puncher, node)
|
|
|
|
local inv = puncher:get_inventory()
|
|
|
|
if inv then
|
|
|
|
if not inv:contains_item("main", node) then
|
|
|
|
inv:add_item("main", node)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-02-28 15:51:57 +01:00
|
|
|
local supported_groups = {
|
|
|
|
"unbreakable", "immortal", "fleshy", "choppy", "bendy",
|
|
|
|
"cracky", "crumbly", "snappy", "level", "nether",
|
|
|
|
"oddly_breakable_by_hand", "not_in_creative_inventory"
|
|
|
|
}
|
|
|
|
local caps = {}
|
|
|
|
for _,i in pairs(supported_groups) do
|
|
|
|
caps[i] = {times={[1]=0, [2]=0, [3]=0}, uses=0, maxlevel=3}
|
|
|
|
end
|
|
|
|
|
2015-07-05 21:01:27 +02:00
|
|
|
local function rc_info(_, player, pt)
|
|
|
|
if not player
|
|
|
|
or not pt
|
|
|
|
or player:get_wield_index() ~= 1 then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local pname = player:get_player_name()
|
|
|
|
if not minetest.check_player_privs(pname, {server=true}) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local pos = pt.under
|
|
|
|
local node = minetest.get_node_or_nil(pos)
|
|
|
|
if not node then
|
|
|
|
minetest.chat_send_player(pname, "?")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local pcontrol = player:get_player_control()
|
|
|
|
if pcontrol.down
|
|
|
|
and pcontrol.up then
|
|
|
|
add_to_inv(player, node)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local light = minetest.get_node_light(pos)
|
|
|
|
if not light
|
|
|
|
or light == 0 then
|
|
|
|
light = minetest.get_node_light(pt.above)
|
|
|
|
end
|
|
|
|
local infos = {
|
|
|
|
{"param1", node.param1},
|
|
|
|
{"param2", node.param2},
|
2016-03-10 20:48:08 +01:00
|
|
|
{"light", light or 0},
|
2015-07-05 21:01:27 +02:00
|
|
|
}
|
|
|
|
local nam = node.name
|
|
|
|
local data = minetest.registered_nodes[nam]
|
|
|
|
if not data then
|
|
|
|
table.insert(infos, 1, {"name", nam})
|
|
|
|
end
|
|
|
|
if pcontrol.sneak
|
|
|
|
and pcontrol.aux1
|
|
|
|
and not pcontrol.up then
|
2016-03-10 20:48:08 +01:00
|
|
|
infos[#infos+1] = {"nodedata", dump(data)}
|
2015-07-05 21:01:27 +02:00
|
|
|
end
|
|
|
|
local msg = ""
|
|
|
|
for _,i in ipairs(infos) do
|
|
|
|
local n,i = unpack(i)
|
|
|
|
if i ~= 0 then
|
|
|
|
msg = msg..n.."="..i..", "
|
|
|
|
end
|
|
|
|
end
|
|
|
|
minetest.sound_play("superpick", {pos = pos, gain = 0.4, max_hear_distance = 10})
|
|
|
|
if msg == "" then
|
|
|
|
msg = data.description or nam
|
|
|
|
else
|
|
|
|
msg = string.sub(msg, 0, -3)
|
|
|
|
end
|
2016-03-10 20:48:08 +01:00
|
|
|
minetest.log("action", "[superpick] "..pname..": "..msg)
|
2015-07-05 21:01:27 +02:00
|
|
|
minetest.chat_send_player(pname, msg)
|
|
|
|
end
|
|
|
|
|
|
|
|
--newhand.on_place = rc_info
|
|
|
|
|
2013-11-30 23:11:32 +01:00
|
|
|
minetest.register_tool(":creative:pick", {
|
2013-11-20 16:32:21 +01:00
|
|
|
description = "LX 113",
|
|
|
|
inventory_image = "superpick.png",
|
|
|
|
wield_scale = {x=2,y=2,z=2},
|
|
|
|
liquids_pointable = true,
|
2014-03-15 14:42:32 +01:00
|
|
|
range = 14,
|
2013-11-20 16:32:21 +01:00
|
|
|
tool_capabilities = {
|
|
|
|
full_punch_interval = 0,
|
|
|
|
max_drop_level=3,
|
2015-02-28 15:51:57 +01:00
|
|
|
groupcaps=caps,
|
2013-11-20 16:32:21 +01:00
|
|
|
damage_groups = {fleshy = 20},
|
2013-05-11 12:50:50 +02:00
|
|
|
},
|
2015-07-05 21:01:27 +02:00
|
|
|
on_place = rc_info,
|
2013-11-20 16:32:21 +01:00
|
|
|
})
|
2013-03-16 10:10:26 +01:00
|
|
|
|
2015-07-05 21:01:27 +02:00
|
|
|
minetest.register_on_punchnode(function(pos, node, player)
|
|
|
|
if player:get_wield_index() ~= 1
|
2016-01-31 12:17:35 +01:00
|
|
|
or player:get_wielded_item():to_string() ~= "creative:pick"
|
2015-07-05 21:01:27 +02:00
|
|
|
or node.name == "air" then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local item = player:get_wielded_item():get_name()
|
|
|
|
if item ~= "creative:pick"
|
|
|
|
and item then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local pname = player:get_player_name()
|
|
|
|
if not minetest.check_player_privs(pname, {server=true}) then
|
|
|
|
return
|
2013-08-24 12:40:13 +02:00
|
|
|
end
|
2015-07-05 21:01:27 +02:00
|
|
|
minetest.after(0.3, function(pos, name)
|
|
|
|
if minetest.get_node(pos).name ~= "air"
|
|
|
|
and not minetest.is_protected(pos, name) then
|
|
|
|
minetest.log("info", "[superpick] force destroying node at ("..pos.x.."|"..pos.y.."|"..pos.z..")")
|
|
|
|
minetest.remove_node(pos)
|
|
|
|
end
|
|
|
|
end, pos, pname)
|
|
|
|
add_to_inv(player, node)
|
2013-11-20 16:32:21 +01:00
|
|
|
end)
|
2013-08-24 12:40:13 +02:00
|
|
|
|
2013-11-20 16:32:21 +01:00
|
|
|
local function cleaninventory(name)
|
2015-07-05 21:01:27 +02:00
|
|
|
if not name
|
2013-11-20 16:32:21 +01:00
|
|
|
or name == "" then
|
|
|
|
return
|
|
|
|
end
|
2015-03-21 20:19:28 +01:00
|
|
|
local inv = minetest.get_player_by_name(name):get_inventory()
|
|
|
|
local list = inv:get_list("main")
|
|
|
|
inv:set_list("main", {"creative:pick", list[2], list[3]})
|
2015-01-31 14:48:20 +01:00
|
|
|
minetest.log("info", "[superpick] "..name.." has cleaned his inventory")
|
2013-11-20 16:32:21 +01:00
|
|
|
minetest.chat_send_player(name, 'Inventory Cleaned!')
|
2013-08-24 12:40:13 +02:00
|
|
|
end
|
|
|
|
|
2015-06-16 19:30:18 +02:00
|
|
|
minetest.register_chatcommand("cleaninv",{
|
|
|
|
description = "Tidy up your inventory.",
|
2013-08-24 12:40:13 +02:00
|
|
|
params = "",
|
2015-06-16 19:30:18 +02:00
|
|
|
privs = {give=true},
|
2013-08-24 12:40:13 +02:00
|
|
|
func = cleaninventory
|
|
|
|
})
|
|
|
|
end
|
2015-07-05 21:01:27 +02:00
|
|
|
|
|
|
|
minetest.after(0, function(nh)
|
|
|
|
minetest.override_item("", nh)
|
|
|
|
end, newhand)
|
|
|
|
|
|
|
|
minetest.log("info", string.format("[superpick] loaded after ca. %.2fs", os.clock() - load_time_start))
|