1
0
mirror of https://github.com/minetest/minetest_game.git synced 2024-12-22 23:10:17 +01:00

Allow mods to override animation globalstep

This commit is contained in:
LoneWolfHT 2022-02-07 11:44:02 -08:00 committed by Lars Müller
parent a6f3b89596
commit f665382017

View File

@ -178,8 +178,8 @@ function minetest.calculate_knockback(player, ...)
end end
-- Check each player and apply animations -- Check each player and apply animations
minetest.register_globalstep(function() function player_api.globalstep()
for _, player in pairs(minetest.get_connected_players()) do for _, player in ipairs(minetest.get_connected_players()) do
local name = player:get_player_name() local name = player:get_player_name()
local player_data = players[name] local player_data = players[name]
local model = player_data and models[player_data.model] local model = player_data and models[player_data.model]
@ -208,6 +208,11 @@ minetest.register_globalstep(function()
end end
end end
end end
end
-- Mods can modify the globalstep by overriding player_api.globalstep
minetest.register_globalstep(function(...)
player_api.globalstep(players, ...)
end) end)
for _, api_function in pairs({"get_animation", "set_animation", "set_model", "set_textures"}) do for _, api_function in pairs({"get_animation", "set_animation", "set_model", "set_textures"}) do