autotool: reset old wield index when node dug
This commit is contained in:
parent
941b979be6
commit
6851ebdbfd
@ -1,4 +1,5 @@
|
||||
autotool={}
|
||||
local odx=nil
|
||||
function autotool.check_tool(stack, node_groups, old_best_time)
|
||||
local toolcaps = stack:get_tool_capabilities()
|
||||
if not toolcaps then return end
|
||||
@ -15,6 +16,7 @@ function autotool.check_tool(stack, node_groups, old_best_time)
|
||||
return best_time < old_best_time, best_time
|
||||
end
|
||||
|
||||
|
||||
minetest.register_on_punchnode(function(pos, node)
|
||||
--minetest.display_chat_message(dump(node))
|
||||
if not minetest.settings:get_bool("autotool") then return end
|
||||
@ -30,7 +32,21 @@ minetest.register_on_punchnode(function(pos, node)
|
||||
new_index = index - 1
|
||||
end
|
||||
end
|
||||
odx=player:get_wield_index()
|
||||
player:set_wield_index(new_index)
|
||||
minetest.after("0.5",function()
|
||||
local nd=minetest.get_node_or_nil(pos)
|
||||
if nd.name == "air" then
|
||||
minetest.localplayer:set_wield_index(odx)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
minetest.register_on_dignode(function(pos, node)
|
||||
if odx then
|
||||
minetest.localplayer:set_wield_index(odx)
|
||||
odx=nil
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_cheat("AutoTool", "Inventory", "autotool")
|
||||
|
Loading…
x
Reference in New Issue
Block a user