Closed evrooije closed 7 years ago
In wieldview/init.lua, method wieldview.update_wielded_item, maybe change:
wieldview.update_wielded_item = function(self, player)
if not player then
return
end
local name = player:get_player_name()
local stack = player:get_wielded_item()
local item = stack:get_name()
if not item then
return
end
if self.wielded_item[name] then
if self.wielded_item[name] == item then
return
end
armor.textures[name].wielditem = self:get_item_texture(item)
armor:update_player_visuals(player)
end
self.wielded_item[name] = item
end
To:
wieldview.update_wielded_item = function(self, player)
if not player then
return
end
local name = player:get_player_name()
local stack = player:get_wielded_item()
local item = stack:get_name()
if not item then
return
end
if self.wielded_item[name] then
if self.wielded_item[name] == item then
return
end
armor.textures[name].wielditem = self:get_item_texture(item)
armor:update_player_visuals(player)
armor:run_callbacks("on_update", player)
end
self.wielded_item[name] = item
end
?
Or would you rather have a separate event e.g. on_wielded_item_change/ on_wielded_item_update for this?
Really speaking the on_update
callback was only meant to be called when armor changes, however, it should do no harm to call it every time the player visuals are updated. Rather than include this in the wieldview mod, it is probably better to simply move run_callbacks("on_update", player)
from the end of set_player_armor
to the end of the update_player_visuals
function.
IMO something like on_wielded_item_change
should be included the the core api.
I have an on_update hook which does additional work on the player's texture. This work is however lost whenever I switch the wielded item. The wieldview mod sets the textures and obviously it only takes into account whatever textures the armor mod had set. But since no on_update is called, the additional textures I set are as such removed.