mirror of
https://github.com/minetest-mods/3d_armor.git
synced 2024-12-02 00:33:47 +01:00
Improve API for third party mods (#21)
* Add `armor:update_skin(player_name)` function (useful for skin mods) * Add option to prevent physics override (useful for Techage Jetpack mod) * Add documentation
This commit is contained in:
parent
3f1a952afb
commit
7436fcdffe
@ -172,6 +172,10 @@ armor:unequip(player, armor_name)
|
|||||||
|
|
||||||
Unequip the armor, adding the itemstack to the main inventory.
|
Unequip the armor, adding the itemstack to the main inventory.
|
||||||
|
|
||||||
|
armor:update_skin(player_name)
|
||||||
|
|
||||||
|
Triggers a skin update with the same action as if a field with `skins_set` was submitted.
|
||||||
|
|
||||||
Item Callbacks:
|
Item Callbacks:
|
||||||
|
|
||||||
on_equip = func(player, index, stack)
|
on_equip = func(player, index, stack)
|
||||||
@ -201,3 +205,8 @@ armor:register_on_update(function(player)
|
|||||||
print(player:get_player_name().." armor updated!")
|
print(player:get_player_name().." armor updated!")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
Note:
|
||||||
|
|
||||||
|
The player physics modifications won't be applied via `set_physics_override` if `player_physics_locked` is set to 1
|
||||||
|
in the respective player's meta.
|
||||||
|
@ -315,8 +315,11 @@ armor.set_player_armor = function(self, player)
|
|||||||
})
|
})
|
||||||
pova.do_override(player)
|
pova.do_override(player)
|
||||||
else
|
else
|
||||||
|
local player_physics_locked = player:get_meta():get_int("player_physics_locked")
|
||||||
|
if player_physics_locked == nil or player_physics_locked == 0 then
|
||||||
player:set_physics_override(physics)
|
player:set_physics_override(physics)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
self.textures[name].armor = texture
|
self.textures[name].armor = texture
|
||||||
self.textures[name].preview = preview
|
self.textures[name].preview = preview
|
||||||
self.def[name].level = self.def[name].groups.fleshy or 0
|
self.def[name].level = self.def[name].groups.fleshy or 0
|
||||||
@ -490,6 +493,16 @@ armor.get_player_skin = function(self, name)
|
|||||||
return armor.default_skin..".png"
|
return armor.default_skin..".png"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
armor.update_skin = function(self, name)
|
||||||
|
minetest.after(0, function()
|
||||||
|
local pplayer = minetest.get_player_by_name(name)
|
||||||
|
if pplayer then
|
||||||
|
self.textures[name].skin = self:get_player_skin(name)
|
||||||
|
self:set_player_armor(pplayer)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
armor.add_preview = function(self, preview)
|
armor.add_preview = function(self, preview)
|
||||||
skin_previews[preview] = true
|
skin_previews[preview] = true
|
||||||
end
|
end
|
||||||
|
@ -295,14 +295,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
for field, _ in pairs(fields) do
|
for field, _ in pairs(fields) do
|
||||||
if string.find(field, "skins_set") then
|
if string.find(field, "skins_set") then
|
||||||
minetest.after(0, function()
|
armor:update_skin(player_name)
|
||||||
local pplayer = minetest.get_player_by_name(player_name)
|
|
||||||
if player then
|
|
||||||
local skin = armor:get_player_skin(name)
|
|
||||||
armor.textures[name].skin = skin
|
|
||||||
armor:set_player_armor(pplayer)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user