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,29 +117,31 @@ minetest.register_chatcommand("move_item", {
-- See if the mod armor_3d is a thing here. -- See if the mod armor_3d is a thing here.
if minetest.global_exists("armor") then if minetest.global_exists("armor") then
-- Cmd for changing the way you block incoming damage. return
minetest.register_chatcommand("use_shield", {
params = "[<boolean>]: Change how you block incoming damage.",
description = "If set to true, the shield plate placed in the armor inventory will be used to block all incoming damage when block key is pressed.",
privs = {
interact = true,
},
func = function(name, param)
-- Check the given param.
if param == "true" then
-- block key will now use the shield in the armor inv to block any incoming damage.
player_persistent_data[name].use_shield = true
return true, "Shield from armor inventory will now be used to block damage."
elseif param == "false" then
-- block key will now use whatever tool selected to block any incoming damage.
player_persistent_data[name].use_shield = nil
return true, "Tools will now be used to block damage."
end
-- use_shield cmd help.
return false, "Only parameters: 'true', and 'false' are accepted."
end
})
end end
-- Cmd for changing the way you block incoming damage.
minetest.register_chatcommand("use_shield", {
params = "[<boolean>]: Change how you block incoming damage.",
description = "If set to true, the shield plate placed in the armor inventory will be used to block all incoming damage when block key is pressed.",
privs = {
interact = true,
},
func = function(name, param)
-- Check the given param.
if param == "true" then
-- block key will now use the shield in the armor inv to block any incoming damage.
player_persistent_data[name].use_shield = true
return true, "Shield from armor inventory will now be used to block damage."
elseif param == "false" then
-- block key will now use whatever tool selected to block any incoming damage.
player_persistent_data[name].use_shield = nil
return true, "Tools will now be used to block damage."
end
-- use_shield cmd help.
return false, "Only parameters: 'true', and 'false' are accepted."
end
})

View File

@ -121,7 +121,12 @@ minetest.register_globalstep(function(dtime)
local full_throw = throw_data.time + tool_capabilities.full_throw local full_throw = throw_data.time + tool_capabilities.full_throw
-- If neither dig or place is down then throw the item. -- 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() local pos = player:get_pos()
pos.y = pos.y + player:get_properties().eye_height 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 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 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) return old_on_drop(itemstack, dropper, pos)
end end

View File

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