Compare commits

...

7 Commits

Author SHA1 Message Date
Brandon 55551069b0 Remove some Crafter files 2020-07-18 15:57:08 -04:00
Brandon 3bbe7a6826 Update api_hook for mcl_mobs definition 2020-07-17 17:47:52 -04:00
Brandon 796c45d4b3 add head code and interaction code from crafter 2020-07-16 19:56:35 -04:00
Brandon 0e797e2c3f localize variables once - not in every loop 2020-07-16 19:48:30 -04:00
Brandon 53d52b3cac formatting 2020-07-16 19:26:56 -04:00
Brandon 0637adf7ef update local calls 2020-07-16 19:25:22 -04:00
Brandon 266fd6fc71 update for head tracking 2020-07-14 20:41:45 -04:00
1 changed files with 18 additions and 6 deletions

View File

@ -6,6 +6,13 @@ local mcl_playerplus_internal = {}
local def = {} local def = {}
local time = 0 local time = 0
-- converts yaw to degrees
local function degrees(rad)
return rad * 180.0 / math.pi
end
local pitch, name, node_stand, node_stand_below, node_head, node_feet, pos
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
time = time + dtime time = time + dtime
@ -13,18 +20,23 @@ minetest.register_globalstep(function(dtime)
-- Update jump status immediately since we need this info in real time. -- Update jump status immediately since we need this info in real time.
-- WARNING: This section is HACKY as hell since it is all just based on heuristics. -- WARNING: This section is HACKY as hell since it is all just based on heuristics.
for _,player in pairs(minetest.get_connected_players()) do for _,player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name() name = player:get_player_name()
-- controls head bone
pitch = degrees(player:get_look_vertical()) * -1
player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch,0,0))
if mcl_playerplus_internal[name].jump_cooldown > 0 then if mcl_playerplus_internal[name].jump_cooldown > 0 then
mcl_playerplus_internal[name].jump_cooldown = mcl_playerplus_internal[name].jump_cooldown - dtime mcl_playerplus_internal[name].jump_cooldown = mcl_playerplus_internal[name].jump_cooldown - dtime
end end
if player:get_player_control().jump and mcl_playerplus_internal[name].jump_cooldown <= 0 then if player:get_player_control().jump and mcl_playerplus_internal[name].jump_cooldown <= 0 then
local pos = player:get_pos() pos = player:get_pos()
local node_stand = mcl_playerinfo[name].node_stand node_stand = mcl_playerinfo[name].node_stand
local node_stand_below = mcl_playerinfo[name].node_stand_below node_stand_below = mcl_playerinfo[name].node_stand_below
local node_head = mcl_playerinfo[name].node_head node_head = mcl_playerinfo[name].node_head
local node_feet = mcl_playerinfo[name].node_feet node_feet = mcl_playerinfo[name].node_feet
if not node_stand or not node_stand_below or not node_head or not node_feet then if not node_stand or not node_stand_below or not node_head or not node_feet then
return return
end end