Add headanim
This commit is contained in:
parent
3e8a4fc37c
commit
f624d1fe36
21
mods/headanim/LICENSE
Normal file
21
mods/headanim/LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020-2021 LoneWolfHT
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
7
mods/headanim/README.md
Normal file
7
mods/headanim/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# Headanim
|
||||
[![ContentDB](https://content.minetest.net/packages/Lone_Wolf/headanim/shields/downloads/)](https://content.minetest.net/packages/Lone_Wolf/headanim/)
|
||||
|
||||
Makes player heads follow their look dir in Minetest. Requires version 5.3+
|
||||
|
||||
## Similar mods
|
||||
* https://github.com/minetest-mods/playeranim: A lot more complex (and possibly slower?) than Headanim but looks nicer as a result
|
21
mods/headanim/init.lua
Normal file
21
mods/headanim/init.lua
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
for _, player in pairs(get_connected_players()) do
|
||||
local pname = player:get_player_name()
|
||||
local ldeg = -deg(player:get_look_vertical())
|
||||
|
||||
if abs((lastdir[pname] or 0) - ldeg) > 4 then
|
||||
lastdir[pname] = ldeg
|
||||
player:set_bone_position("Head", basepos, {x = ldeg, y = 0, z = 0})
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
lastdir[player:get_player_name()] = nil
|
||||
end)
|
2
mods/headanim/mod.conf
Normal file
2
mods/headanim/mod.conf
Normal file
@ -0,0 +1,2 @@
|
||||
name = headanim
|
||||
min_minetest_version = 5.3
|
Loading…
x
Reference in New Issue
Block a user