APercy / airutils

Airport Utils for Minetest
Other
4 stars 9 forks source link

Hints for skinsdb usage #17

Closed bell07 closed 3 months ago

bell07 commented 3 months ago

I looked into pilot_skin_manager.lua (because I still follow whynot game conversations sometimes) and see the implementation could be improved. Skinsdb does have a great (but not well documented) API, that should be used in this mod. Unfortunately I don't have time to create pull request.

I think the best way is to enhance / replace the skins.skin_class.apply_skin_to_player method in your code. Then your code is called each time the skin update is requested from any place: Untested code:

local apply_skin_to_player = skins.skin_class.apply_skin_to_player
function skins.skin_class.apply_skin_to_player(player)
   local orig_texture = self:get_texture()
   local pilot_skin = airutils.get_pilot_skin(player)
   if skin then
     local orig_get_texture = self.get_texture
     function self:get_texture()
         return "[combine:64x32:0,0="..orig_texture.."^"..pilot_skin
     end
     apply_skin_to_player(player)
     self.get_texture = orig_get_texture
  else
     apply_skin_to_player(player)
  end
end

airutils.get_pilot_skin(player) needs to be implemented for this. function that just return the pilot skin, if active

The function airutils.set_player_skin(player, skin) can just do skins.get_player_skin(player):apply_skin_to_player(player) with skinsdb

The change to "character.b3d" should be not necessary. I guess the mod is able to enhance format 1.8 skins, if the model is not changed. This should work with 3d_armor too.

Unfortunately the inventory preview cannot be enhanced, because function skin_class:get_preview()does not have the "player" parameter.

EDIT: sorry for a lot of edits. Seen the code cannot be working after I submitted the issue. Now it should work, but is hacky solution too. I miss my enhancements from my skinsdb5 fork in player_api_modpack, that just support skin modifiers function, that can be used for this. But I given up my fork, because there is no chance to get needed enhancements into player_api

Lazerbeak12345 commented 3 months ago

See also #2

dacmot commented 3 months ago

I think this can now be closed.