Throw: with use and zoom keys

master
Coder12a 2020-10-30 17:03:21 -05:00
parent ddea13cc03
commit 85a00396b4
4 changed files with 46 additions and 32 deletions

View File

@ -117,6 +117,9 @@ minetest.register_chatcommand("move_item", {
-- See if the mod armor_3d is a thing here.
if minetest.global_exists("armor") then
return
end
-- Cmd for changing the way you block incoming damage.
minetest.register_chatcommand("use_shield", {
params = "[<boolean>]: Change how you block incoming damage.",
@ -142,4 +145,3 @@ if minetest.global_exists("armor") then
return false, "Only parameters: 'true', and 'false' are accepted."
end
})
end

View File

@ -121,7 +121,12 @@ minetest.register_globalstep(function(dtime)
local full_throw = throw_data.time + tool_capabilities.full_throw
-- If neither dig or place is down then throw the item.
if (floor(control_bits / 128) % 2 ~= 1 and floor(control_bits / 256) % 2 ~= 1) or pp_data.active_dodges or pp_data.active_barrel_rolls then
if (floor(control_bits / 128) % 2 ~= 1 and
floor(control_bits / 256) % 2 ~= 1 and
floor(control_bits / 512) % 2 ~= 1 and
floor(control_bits / 32) % 2 ~= 1) or
pp_data.active_dodges or pp_data.active_barrel_rolls then
local pos = player:get_pos()
pos.y = pos.y + player:get_properties().eye_height

View File

@ -161,7 +161,12 @@ minetest.register_on_mods_loaded(function()
local shield_data = data.shield
-- If in the process of throwing, either dig, place, or item name is not the same then return the old function.
if throw_data or dropper:get_wielded_item():get_name() ~= name or (floor(control_bits / 128) % 2 ~= 1 and floor(control_bits / 256) % 2 ~= 1) then
if throw_data or dropper:get_wielded_item():get_name() ~= name or
(floor(control_bits / 128) % 2 ~= 1 and
floor(control_bits / 256) % 2 ~= 1 and
floor(control_bits / 512) % 2 ~= 1 and
floor(control_bits / 32) % 2 ~= 1) then
return old_on_drop(itemstack, dropper, pos)
end

View File

@ -106,9 +106,7 @@ minetest.register_on_player_inventory_action(function(player)
end
end)
local function break_guard(player)
local name = player:get_player_name()
local function break_guard(player, name)
if not player_data or not player_data[name] then
return
end
@ -131,11 +129,15 @@ local function break_guard(player)
end
minetest.register_on_placenode(function(pos, newnode, placer)
local name = placer:get_player_name()
-- Break guard if player placed a node.
break_guard(placer)
break_guard(placer, name)
end)
minetest.register_on_dignode(function(pos, oldnode, digger)
local name = digger:get_player_name()
-- Break guard if player dug a node.
break_guard(digger)
break_guard(digger, name)
end)