From f03aaee525a4257e12772652f6d2bddfc02c34bf Mon Sep 17 00:00:00 2001 From: wsor4035 <24964441+wsor4035@users.noreply.github.com> Date: Sat, 7 Sep 2024 15:36:56 -0400 Subject: [PATCH] prototype animation ignoring --- src/player/minetest.lua | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/player/minetest.lua b/src/player/minetest.lua index ed4241b..1182f8f 100644 --- a/src/player/minetest.lua +++ b/src/player/minetest.lua @@ -24,6 +24,28 @@ function papi.set_animation(player, anim_name, speed, loop) return player_api.set_animation(player, anim_name, speed, loop) end ---todo: handle ignoring animations (maybe metatables?) + +local papi_metatable = { + __newindex = function (table, key, value) + player_api.player_attached[key] = value + + rawset(table, key, value) + end +} + +local player_api_metatable = { + __newindex = function (table, key, value) + rawset(papi.player_attached, key, value) + rawset(table, key, value) + end +} + +papi.player_attached = {} + +--when a value is set in xcompat api, this will also set it in the player api +setmetatable(papi.player_attached, papi_metatable) + +--when a value is set in player api, this will also set it in the xcompat api +setmetatable(player_api.player_attached, player_api_metatable) return papi \ No newline at end of file