Compare commits
10 Commits
058627536e
...
1393289b1d
Author | SHA1 | Date | |
---|---|---|---|
|
1393289b1d | ||
|
1b756aabd4 | ||
|
4ab318691e | ||
|
828b451e81 | ||
|
9816030773 | ||
|
d2f945f940 | ||
|
41edfbcf13 | ||
|
c220a56526 | ||
|
86dce43db0 | ||
|
ddd2514506 |
1
.luacheckrc
Normal file
1
.luacheckrc
Normal file
@ -0,0 +1 @@
|
||||
read_globals = {"dump", "minetest", "vector"}
|
@ -1,3 +1,3 @@
|
||||
Sounds (CC by 3.0) from http://www.freesound.org/people/suonho/sounds/8103/
|
||||
Texture created with gimp (WTFPL)
|
||||
rest WTFPL
|
||||
Sounds (CC BY 3.0) from http://www.freesound.org/people/suonho/sounds/8103/
|
||||
Texture created with gimp: CC BY 4.0
|
||||
Code: MIT
|
||||
|
19
README.md
19
README.md
@ -1,17 +1,2 @@
|
||||
[Mod] superpick [superpick]
|
||||
|
||||
I made a tool which can dig every node very fast and show information about the punched node.
|
||||
|
||||
**Depends:** see [depends.txt](https://raw.githubusercontent.com/HybridDog/superpick/master/depends.txt)
|
||||
**License:** see [LICENSE.txt](https://raw.githubusercontent.com/HybridDog/superpick/master/LICENSE.txt)
|
||||
**Download:** [zip](https://github.com/HybridDog/superpick/archive/master.zip), [tar.gz](https://github.com/HybridDog/superpick/archive/master.tar.gz)
|
||||
|
||||
![I'm a screenshot!](http://bit.ly/1wOCWpq)
|
||||
|
||||
If you got ideas or found bugs, please tell them to me.
|
||||
|
||||
[How to install a mod?](http://wiki.minetest.net/Installing_Mods)
|
||||
|
||||
|
||||
TODO:
|
||||
— maybe allow other mods to make it give information
|
||||
For a description about this mod, please refer to the
|
||||
[forum topic](https://forum.minetest.net/viewtopic.php?f=11&t=3691).
|
||||
|
@ -1 +0,0 @@
|
||||
creative
|
338
init.lua
338
init.lua
@ -1,191 +1,179 @@
|
||||
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},
|
||||
}
|
||||
|
||||
if minetest.setting_getbool"creative_mode" then
|
||||
newhand.range = 14
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
local caps = {}
|
||||
for _,i in pairs{
|
||||
"unbreakable", "immortal", "fleshy", "choppy", "bendy", "cracky",
|
||||
"crumbly", "snappy", "level", "nether", "oddly_breakable_by_hand",
|
||||
"not_in_creative_inventory"
|
||||
} do
|
||||
caps[i] = {times={[1]=0, [2]=0, [3]=0}, uses=0, maxlevel=3}
|
||||
local function rightclick_info(player, pt)
|
||||
if not player
|
||||
or not pt then
|
||||
return
|
||||
end
|
||||
|
||||
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},
|
||||
{"light", light or 0},
|
||||
}
|
||||
|
||||
-- nodename (if not shown by F5)
|
||||
local nam = node.name
|
||||
local data = minetest.registered_nodes[nam]
|
||||
if not data then
|
||||
table.insert(infos, 1, {"name", nam})
|
||||
end
|
||||
|
||||
-- nodedef dump
|
||||
if pcontrol.sneak
|
||||
and pcontrol.aux1
|
||||
and not pcontrol.up
|
||||
and not pcontrol.right then
|
||||
infos[#infos+1] = {"nodedata", dump(data)}
|
||||
end
|
||||
|
||||
if pcontrol.left
|
||||
and pcontrol.right then
|
||||
if pcontrol.aux1 then
|
||||
-- node timer
|
||||
local nt = minetest.get_node_timer(pos)
|
||||
infos[#infos+1] = {"nodetimer",
|
||||
"started:"..tostring(nt:is_started())..
|
||||
",elapsed:"..tostring(nt:get_elapsed())..
|
||||
",timeout:"..tostring(nt:get_timeout())
|
||||
}
|
||||
else
|
||||
-- meta
|
||||
local t = minetest.get_meta(pos):to_table()
|
||||
local show
|
||||
for i in pairs(t) do
|
||||
if i ~= "inventory"
|
||||
and i ~= "fields" then
|
||||
show = true
|
||||
end
|
||||
end
|
||||
if not show then
|
||||
if next(t.inventory)
|
||||
or next(t.fields) then
|
||||
show = true
|
||||
end
|
||||
end
|
||||
infos[#infos+1] = {"meta", show and dump(t) or "default"}
|
||||
end
|
||||
end
|
||||
|
||||
-- make msg and show it
|
||||
local msg = ""
|
||||
for i = 1,#infos do
|
||||
local n,i = unpack(infos[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
|
||||
minetest.log("action", "[superpick] "..pname..": "..msg)
|
||||
minetest.chat_send_player(pname, msg)
|
||||
local pname = player:get_player_name()
|
||||
if not minetest.check_player_privs(pname, {server=true}) then
|
||||
minetest.chat_send_player(pname,
|
||||
"Usage of this tool requires the server privilege.")
|
||||
return
|
||||
end
|
||||
|
||||
--newhand.on_place = rc_info
|
||||
|
||||
minetest.register_tool(":creative:pick", {
|
||||
description = "LX 113",
|
||||
inventory_image = "superpick.png",
|
||||
wield_scale = {x=2,y=2,z=2},
|
||||
liquids_pointable = true,
|
||||
range = 14,
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 0,
|
||||
max_drop_level=3,
|
||||
groupcaps=caps,
|
||||
damage_groups = {fleshy = 20},
|
||||
},
|
||||
on_place = rc_info,
|
||||
})
|
||||
|
||||
minetest.register_on_punchnode(function(pos, node, player)
|
||||
if player:get_wield_index() ~= 1
|
||||
or player:get_wielded_item():to_string() ~= "creative:pick"
|
||||
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
|
||||
end
|
||||
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)
|
||||
local pos = pt.under
|
||||
local node = minetest.get_node_or_nil(pos)
|
||||
if not node then
|
||||
minetest.chat_send_player(pname, "Node not loaded")
|
||||
return
|
||||
end
|
||||
local pcontrol = player:get_player_control()
|
||||
if pcontrol.down
|
||||
and pcontrol.up then
|
||||
add_to_inv(player, node)
|
||||
end)
|
||||
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},
|
||||
{"light", light or 0},
|
||||
}
|
||||
|
||||
local function cleaninventory(name)
|
||||
-- nodename (if not shown by F5)
|
||||
local nam = node.name
|
||||
local data = minetest.registered_nodes[nam]
|
||||
if not data then
|
||||
table.insert(infos, 1, {"name", nam})
|
||||
end
|
||||
|
||||
-- nodedef dump
|
||||
if pcontrol.sneak
|
||||
and pcontrol.aux1
|
||||
and not pcontrol.up
|
||||
and not pcontrol.right then
|
||||
infos[#infos+1] = {"nodedata", dump(data)}
|
||||
end
|
||||
|
||||
if pcontrol.left
|
||||
and pcontrol.right then
|
||||
if pcontrol.aux1 then
|
||||
-- node timer
|
||||
local nt = minetest.get_node_timer(pos)
|
||||
infos[#infos+1] = {"nodetimer",
|
||||
("started: %s, elapsed: %.5g, timeout: %.5g"):format(
|
||||
tostring(nt:is_started()), nt:get_elapsed(),
|
||||
nt:get_timeout())
|
||||
}
|
||||
else
|
||||
-- meta
|
||||
local t = minetest.get_meta(pos):to_table()
|
||||
local show
|
||||
for i in pairs(t) do
|
||||
if i ~= "inventory"
|
||||
and i ~= "fields" then
|
||||
show = true
|
||||
end
|
||||
end
|
||||
if not show then
|
||||
if next(t.inventory)
|
||||
or next(t.fields) then
|
||||
show = true
|
||||
end
|
||||
end
|
||||
infos[#infos+1] = {"meta", show and dump(t) or "default"}
|
||||
end
|
||||
end
|
||||
|
||||
-- make msg and show it
|
||||
local msg = ""
|
||||
for i = 1,#infos do
|
||||
local n,v = unpack(infos[i])
|
||||
if v ~= 0 then
|
||||
msg = msg .. n .. "=" .. v .. ", "
|
||||
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
|
||||
minetest.log("action", "[superpick] "..pname..": "..msg)
|
||||
minetest.chat_send_player(pname, msg)
|
||||
end
|
||||
|
||||
minetest.register_on_punchnode(function(pos, node, player)
|
||||
if player:get_wielded_item():get_name() ~= "superpick:tool"
|
||||
or node.name == "air" then
|
||||
return
|
||||
end
|
||||
local pname = player:get_player_name()
|
||||
if not minetest.check_player_privs(pname, {server=true}) then
|
||||
minetest.chat_send_player(pname,
|
||||
"Usage of this tool requires the server privilege.")
|
||||
return
|
||||
end
|
||||
minetest.after(0.1, function()
|
||||
if minetest.get_node(pos).name ~= "air"
|
||||
and not minetest.is_protected(pos, pname) then
|
||||
minetest.log("info", "[superpick] force destroying node at " ..
|
||||
minetest.pos_to_string(pos))
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
end)
|
||||
add_to_inv(player, node)
|
||||
end)
|
||||
|
||||
local caps = {}
|
||||
for _,i in pairs{
|
||||
"unbreakable", "immortal", "fleshy", "choppy", "bendy", "cracky",
|
||||
"crumbly", "snappy", "level", "nether", "oddly_breakable_by_hand",
|
||||
"not_in_creative_inventory"
|
||||
} do
|
||||
caps[i] = {
|
||||
times = {0, 0, 0},
|
||||
uses = 0,
|
||||
maxlevel = 3
|
||||
}
|
||||
end
|
||||
|
||||
minetest.register_tool("superpick:tool", {
|
||||
description = "Superpickaxe",
|
||||
inventory_image = "superpick.png",
|
||||
wield_scale = {x=2,y=2,z=2},
|
||||
liquids_pointable = true,
|
||||
range = 14,
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 0,
|
||||
max_drop_level=3,
|
||||
groupcaps=caps,
|
||||
damage_groups = {fleshy = 20},
|
||||
},
|
||||
on_place = function(stack, player, pt)
|
||||
rightclick_info(player, pt)
|
||||
return stack
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
-- Add the cleaninv command
|
||||
|
||||
minetest.register_chatcommand("cleaninv",{
|
||||
description = "Tidy up your inventory.",
|
||||
params = "",
|
||||
privs = {give=true},
|
||||
func = function(name)
|
||||
if not name
|
||||
or name == "" then
|
||||
return
|
||||
end
|
||||
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]})
|
||||
inv:set_list("main", {"superpick:tool", list[2], list[3]})
|
||||
minetest.log("info", "[superpick] "..name.." has cleaned his inventory")
|
||||
minetest.chat_send_player(name, 'Inventory Cleaned!')
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("cleaninv",{
|
||||
description = "Tidy up your inventory.",
|
||||
params = "",
|
||||
privs = {give=true},
|
||||
func = cleaninventory
|
||||
})
|
||||
end
|
||||
|
||||
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))
|
||||
})
|
||||
|
BIN
sounds/superpick.1.ogg
Normal file
BIN
sounds/superpick.1.ogg
Normal file
Binary file not shown.
@ -1 +0,0 @@
|
||||
7436a4c718d5f371eef276f23de227ac928f8482
|
BIN
sounds/superpick.2.ogg
Normal file
BIN
sounds/superpick.2.ogg
Normal file
Binary file not shown.
@ -1 +0,0 @@
|
||||
ebf9f4da730a744f375654d6b15d2cb924bb7dc3
|
BIN
sounds/superpick.3.ogg
Normal file
BIN
sounds/superpick.3.ogg
Normal file
Binary file not shown.
@ -1 +0,0 @@
|
||||
4cabe89181c24241f87119670dd8d193308e2807
|
BIN
sounds/superpick.4.ogg
Normal file
BIN
sounds/superpick.4.ogg
Normal file
Binary file not shown.
@ -1 +0,0 @@
|
||||
96f17ceceba8b064bfbd52d58d702609ce9d67f2
|
BIN
sounds/superpick.5.ogg
Normal file
BIN
sounds/superpick.5.ogg
Normal file
Binary file not shown.
@ -1 +0,0 @@
|
||||
39c1b0b000b39cc454e03b1be2074464b1ee1eab
|
BIN
sounds/superpick.6.ogg
Normal file
BIN
sounds/superpick.6.ogg
Normal file
Binary file not shown.
@ -1 +0,0 @@
|
||||
deea5c6f064b4e6d8e5335ca3372ba7355f05588
|
Binary file not shown.
Before Width: | Height: | Size: 74 B |
Loading…
x
Reference in New Issue
Block a user