Compare commits

...

10 Commits

Author SHA1 Message Date
HybridDog
1393289b1d depends.txt -> mod.conf 2021-10-10 12:52:21 +02:00
HybridDog
1b756aabd4 Add a .luacheckrc 2020-10-11 17:41:59 +02:00
HybridDog
4ab318691e Remove the now unused wield_dummy.png 2020-07-21 20:51:39 +02:00
HybridDog
828b451e81 README.md: Remove todos; they are old and fixed
Former-commit-id: c8cc8069b552c26736204e5dcf46930c498e9a90
Former-commit-id: 3b6baca00cd63aa13ef8196a002745e458e208a9
2020-07-21 20:18:30 +02:00
HybridDog
9816030773 Remove the wield hand changing among other changes
Rename the tool
Show a chat message when the server priv is missing
Change node timer text format


Former-commit-id: 2e39ab87c614ef30c82247fb047cd3d61131db65
Former-commit-id: eff91560e7d23e94e240a29ccd1579832f21746f
2020-07-21 20:01:51 +02:00
HybridDog
d2f945f940 Change license: do not use WTFPL
WTFPL allows relicensing.


Former-commit-id: 7a9a2f95bc5e883d46e489a8c23726830b6a0f4d
Former-commit-id: 7cf207cf61bea170b7c3c3bd9820c2d3f5d95a66
2020-07-21 19:48:15 +02:00
HybridDog
41edfbcf13 Changes and code restructuring
Remove the first wield slot and creative requirements
Reduce the force-removal time delay
Simplify the code a bit
Update the Readme


Former-commit-id: ee8312c039a984ab3bd4cd122a0c6573b86666fb
Former-commit-id: a7edd0eb5eeec485ae6280f8bd9dade0c9b7ebab
2020-07-20 21:44:52 +02:00
Hybrid Dog
c220a56526 Use new settings interface
Former-commit-id: 0eed36eadfdeeb6b30aac2247167e0dfb4ebc6b2
Former-commit-id: b25bb46b40450e4c6839543a6757775aad4e1d3b
2017-06-11 09:18:56 +02:00
Hybrid Dog
86dce43db0 Make superpick use click-digging
Former-commit-id: 69634282440feb0d5e72b346662588e10ddabde7
Former-commit-id: 698fd4e042206e24b8d4fba411e2de043bbac354
2017-04-30 10:27:51 +02:00
Hybrid Dog
ddd2514506 Limit digging speed
Former-commit-id: 93a1aeaf9afa793e468301dc105d574e90820d2b
Former-commit-id: 534453f04ef40cd3a6bececbaf10633a4d50b21f
2017-04-24 16:36:19 +02:00
19 changed files with 170 additions and 202 deletions

1
.luacheckrc Normal file
View File

@ -0,0 +1 @@
read_globals = {"dump", "minetest", "vector"}

View File

@ -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

View File

@ -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).

View File

@ -1 +0,0 @@
creative

338
init.lua
View File

@ -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))
})

1
mod.conf Normal file
View File

@ -0,0 +1 @@
name = superpick

BIN
sounds/superpick.1.ogg Normal file

Binary file not shown.

View File

@ -1 +0,0 @@
7436a4c718d5f371eef276f23de227ac928f8482

BIN
sounds/superpick.2.ogg Normal file

Binary file not shown.

View File

@ -1 +0,0 @@
ebf9f4da730a744f375654d6b15d2cb924bb7dc3

BIN
sounds/superpick.3.ogg Normal file

Binary file not shown.

View File

@ -1 +0,0 @@
4cabe89181c24241f87119670dd8d193308e2807

BIN
sounds/superpick.4.ogg Normal file

Binary file not shown.

View File

@ -1 +0,0 @@
96f17ceceba8b064bfbd52d58d702609ce9d67f2

BIN
sounds/superpick.5.ogg Normal file

Binary file not shown.

View File

@ -1 +0,0 @@
39c1b0b000b39cc454e03b1be2074464b1ee1eab

BIN
sounds/superpick.6.ogg Normal file

Binary file not shown.

View File

@ -1 +0,0 @@
deea5c6f064b4e6d8e5335ca3372ba7355f05588

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 B