0
0
Fork 0

Move holding code into mcl_playerplus

This commit is contained in:
iliekprogrammar 2021-03-20 08:42:48 +08:00
parent 249b5cfd1e
commit 34dbddb40a
2 changed files with 13 additions and 9 deletions

View File

@ -96,6 +96,8 @@ minetest.register_globalstep(function(dtime)
local player_velocity = player:get_velocity() or player:get_player_velocity() local player_velocity = player:get_velocity() or player:get_player_velocity()
local wielded = player:get_wielded_item()
-- controls head bone -- controls head bone
local pitch = - degrees(player:get_look_vertical()) local pitch = - degrees(player:get_look_vertical())
local yaw = degrees(player:get_look_horizontal()) local yaw = degrees(player:get_look_horizontal())
@ -107,13 +109,21 @@ minetest.register_globalstep(function(dtime)
player_vel_yaw = limit_vel_yaw(player_vel_yaw, yaw) player_vel_yaw = limit_vel_yaw(player_vel_yaw, yaw)
player_vel_yaws[name] = player_vel_yaw player_vel_yaws[name] = player_vel_yaw
-- controls right and left arms pitch when shooting a bow or punching -- controls right and left arms pitch when shooting a bow
if string.find(player:get_wielded_item():get_name(), "mcl_bows:bow") and controls.RMB and not controls.LMB and not controls.up and not controls.down and not controls.left and not controls.right then if string.find(wielded:get_name(), "mcl_bows:bow") and controls.RMB and not controls.LMB and not controls.up and not controls.down and not controls.left and not controls.right then
minetest.chat_send_all("entered 1")
player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(pitch+90,-30,pitch * -1 * .35)) player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(pitch+90,-30,pitch * -1 * .35))
player:set_bone_position("Arm_Left_Pitch_Control", vector.new(3.5,5.785,0), vector.new(pitch+90,43,pitch * .35)) player:set_bone_position("Arm_Left_Pitch_Control", vector.new(3.5,5.785,0), vector.new(pitch+90,43,pitch * .35))
-- when punching
elseif controls.LMB and player:get_attach() == nil then elseif controls.LMB and player:get_attach() == nil then
minetest.chat_send_all("entered 2")
player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(pitch,0,0)) player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(pitch,0,0))
player:set_bone_position("Arm_Left_Pitch_Control", vector.new(3,5.785,0), vector.new(0,0,0)) player:set_bone_position("Arm_Left_Pitch_Control", vector.new(3,5.785,0), vector.new(0,0,0))
-- when holding an item.
elseif wielded:get_name() ~= "" then
player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(20,0,0))
player:set_bone_position("Arm_Left_Pitch_Control", vector.new(3,5.785,0), vector.new(0,0,0))
-- resets arms pitch
else else
player:set_bone_position("Arm_Left_Pitch_Control", vector.new(3,5.785,0), vector.new(0,0,0)) player:set_bone_position("Arm_Left_Pitch_Control", vector.new(3,5.785,0), vector.new(0,0,0))
player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(0,0,0)) player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(0,0,0))

View File

@ -114,16 +114,10 @@ minetest.register_entity("wieldview:wieldnode", {
-- wield item as cubic -- wield item as cubic
if armor.textures[self.wielder].wielditem == "blank.png" then if armor.textures[self.wielder].wielditem == "blank.png" then
self.object:set_properties({textures = {itemstring}}) self.object:set_properties({textures = {itemstring}})
else -- displayed item as flat else -- wield item as flat
self.object:set_properties({textures = {""}}) self.object:set_properties({textures = {""}})
end end
if itemstring == "" then -- holding item
player:set_bone_position("Arm_Right", vector.new(0, 0, 0), vector.new(0, 0, 0))
else -- empty hands
player:set_bone_position("Arm_Right", vector.new(0, 0, 0), vector.new(20, 0, 0))
end
self.itemstring = itemstring self.itemstring = itemstring
end end
else else