Move holding code into mcl_playerplus
parent
249b5cfd1e
commit
34dbddb40a
|
@ -96,6 +96,8 @@ minetest.register_globalstep(function(dtime)
|
|||
|
||||
local player_velocity = player:get_velocity() or player:get_player_velocity()
|
||||
|
||||
local wielded = player:get_wielded_item()
|
||||
|
||||
-- controls head bone
|
||||
local pitch = - degrees(player:get_look_vertical())
|
||||
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_yaws[name] = player_vel_yaw
|
||||
|
||||
-- controls right and left arms pitch when shooting a bow or punching
|
||||
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
|
||||
-- controls right and left arms pitch when shooting a bow
|
||||
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_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
|
||||
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_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
|
||||
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))
|
||||
|
|
|
@ -114,16 +114,10 @@ minetest.register_entity("wieldview:wieldnode", {
|
|||
-- wield item as cubic
|
||||
if armor.textures[self.wielder].wielditem == "blank.png" then
|
||||
self.object:set_properties({textures = {itemstring}})
|
||||
else -- displayed item as flat
|
||||
else -- wield item as flat
|
||||
self.object:set_properties({textures = {""}})
|
||||
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
|
||||
end
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue