1
0
mirror of https://github.com/LoneWolfHT/headanim.git synced 2024-11-14 14:30:40 +01:00

Use new set_bone_override() method (Credit: rudzik8)

This commit is contained in:
LoneWolfHT 2024-10-28 08:46:22 -07:00
parent 7d4fb05ecb
commit d7839acfdc
3 changed files with 55 additions and 8 deletions

45
.luacheckrc Normal file
View File

@ -0,0 +1,45 @@
read_globals = {
"DIR_DELIM", "INIT",
"minetest", "core",
"dump", "dump2",
"Raycast",
"Settings",
"PseudoRandom",
"PerlinNoise",
"VoxelManip",
"SecureRandom",
"VoxelArea",
"PerlinNoiseMap",
"PcgRandom",
"ItemStack",
"AreaStore",
"vector",
table = {
fields = {
"copy",
"indexof",
"insert_all",
"key_value_swap",
"shuffle",
}
},
string = {
fields = {
"split",
"trim",
}
},
math = {
fields = {
"hypot",
"sign",
"factorial"
}
},
}

View File

@ -1,17 +1,19 @@
local get_connected_players = minetest.get_connected_players
local abs = math.abs
local deg = math.deg
local basepos = vector.new(0, 6.35, 0)
local lastdir = {}
minetest.register_globalstep(function(dtime)
minetest.register_globalstep(function()
for _, player in pairs(get_connected_players()) do
local pname = player:get_player_name()
local ldeg = -deg(player:get_look_vertical())
local ldeg = -player:get_look_vertical()
if abs((lastdir[pname] or 0) - ldeg) > 4 then
if (lastdir[pname] or 0) ~= ldeg then
lastdir[pname] = ldeg
player:set_bone_position("Head", basepos, {x = ldeg, y = 0, z = 0})
player:set_bone_override("Head", {
rotation = {
vec = {x = ldeg, y = 0, z = 0},
interpolation = 0.14,
}
})
end
end
end)

View File

@ -1,3 +1,3 @@
name = headanim
depends = player_api
min_minetest_version = 5.3
min_minetest_version = 5.9