diff --git a/config.lua b/config.lua index f8c31f8..d60510d 100644 --- a/config.lua +++ b/config.lua @@ -28,7 +28,6 @@ yl_speak_up.mesh_data = {} yl_speak_up.mesh_data["error"] = { texture_index = 1, can_show_wielded_items = false, - skin_preview = yl_speak_up.skin_preview_normal, } -- this model is used by mobs_npc yl_speak_up.mesh_data["mobs_character.b3d"] = { @@ -36,8 +35,6 @@ yl_speak_up.mesh_data["mobs_character.b3d"] = { texture_index = 1, -- there is no support for capes or wielded items can_show_wielded_items = false, - -- which function can be used to draw the skin? - skin_preview = yl_speak_up.skin_preview_normal, -- textures are applied directly textures_to_skin = false, } @@ -46,8 +43,6 @@ yl_speak_up.mesh_data["skinsdb_3d_armor_character_5.b3d"] = { texture_index = 2, -- they can wear and show capes and wield items can_show_wielded_items = true, - -- this model needs its own preview function - skin_preview = yl_speak_up.skin_preview_skinsdb_3d_armor_character_5, -- call textures2skin in order to convert the textures (wielded items) textures_to_skin = true, } diff --git a/fs_fashion.lua b/fs_fashion.lua index bcdcd78..dcf64be 100644 --- a/fs_fashion.lua +++ b/fs_fashion.lua @@ -38,6 +38,48 @@ yl_speak_up.get_mob_type = function(pname) end +-- this makes use of the "model" option of formspecs +yl_speak_up.skin_preview_3d = function(mesh, textures) + local tstr = "" + for i, t in ipairs(textures) do + tstr = tstr..minetest.formspec_escape(t).."," + end + return "container[0.5,0.5]".. + "model[2,1;6,12;skin_animation_front;"..mesh..";"..tstr..";0,180;false;true;;]".. + "model[8,1;6,12;skin_animation_back;"..mesh..";"..tstr..";0,0;false;true;;]".. + "container_end[]" +end + + +-- this is a suitable version for most models/meshes that use normal player skins +-- (i.e. mobs_redo) with skins in either 64 x 32 or 64 x 64 MC skin format +yl_speak_up.skin_preview_normal = function(skin) + return "image[3,0.7;2,2;[combine:8x8:-8,-8="..skin.."]".. + "image[2.85,0.55;2.3,2.3;[combine:8x8:-40,-8="..skin.."]".. -- head, beard + "image[3,2.75;2,3;[combine:8x12:-20,-20="..skin..":-20,-36="..skin.."]".. -- body + "image[3,5.75;1,3;[combine:4x12:-4,-20="..skin..":-4,-36="..skin.."]".. -- left leg + ov + "image[4,5.75;1,3;[combine:4x12:-4,-20="..skin.."^[transformFX]".. -- right leg + "image[4,5.75;1,3;[combine:4x12:-20,-52="..skin..":-4,-52="..skin.."]".. -- right leg ov + "image[2.0,2.75;1,3;[combine:4x12:-44,-20="..skin..":-44,-36="..skin.."]".. -- left hand + "image[5.0,2.75;1,3;[combine:4x12:-44,-20="..skin.."^[transformFX]".. -- right hand + "image[5.0,2.75;1,3;[combine:4x12:-36,-52="..skin..":-52,-52="..skin.."]".. -- right hand ov + + "image[8,0.7;2,2;[combine:8x8:-24,-8="..skin.."]".. -- back head + "image[7.85,0.55;2.3,2.3;[combine:8x8:-56,-8="..skin.."]".. -- head, beard + "image[8,2.75;2,3;[combine:8x12:-32,-20="..skin..":-32,-36="..skin.."]".. -- body back + "image[8,5.75;1,3;[combine:4x12:-12,-20="..skin.."]".. -- left leg back + "image[8,5.75;1,3;[combine:4x12:-28,-52="..skin..":-12,-52="..skin.."]".. -- r. leg back ov + "image[9,5.75;1,3;[combine:4x12:-12,-20="..skin.."^[transformFX]".. -- right leg back + "image[9,5.75;1,3;[combine:4x12:-12,-36="..skin.."]".. -- right leg back ov + "image[7,2.75;1,3;[combine:4x12:-52,-20="..skin..":-40,-52="..skin..":-60,-52="..skin.."]".. -- l. hand back ov + "image[10,2.75;1,3;[combine:4x12:-52,-20="..skin.."^[transformFX]".. -- right hand back + "image[10,2.75;1,3;[combine:4x12:-52,-20="..skin..":-52,-36="..skin.."]".. -- left hand back + + "" + --local legs_back = "[combine:4x12:-12,-20="..skins.skins[name]..".png" +end + + local function cape2texture(t) return "yl_speak_up_mask_cape.png^[combine:32x64:56,20=" .. t diff --git a/init.lua b/init.lua index 33efe92..607a482 100644 --- a/init.lua +++ b/init.lua @@ -26,9 +26,6 @@ yl_speak_up.fs_version = {} yl_speak_up.custom_server_functions = {} --- this file defines preview functions for skins - which are needed in config.lua --- (skin preview depends on model) -dofile(modpath .. "skin_preview.lua") -- the server-specific configuration dofile(modpath .. "config.lua") -- players *and* npc need privs for certain things diff --git a/skin_preview.lua b/skin_preview.lua deleted file mode 100644 index 1527bc1..0000000 --- a/skin_preview.lua +++ /dev/null @@ -1,90 +0,0 @@ --- this file contains the preview images for the skins of the NPC; --- it does depend on the model used - - --- this makes use of the "model" option of formspecs -yl_speak_up.skin_preview_3d = function(mesh, textures) - local tstr = "" - for i, t in ipairs(textures) do - tstr = tstr..minetest.formspec_escape(t).."," - end - return "container[0.5,0.5]".. - "model[2,1;6,12;skin_animation_front;"..mesh..";"..tstr..";0,180;false;true;;]".. - "model[8,1;6,12;skin_animation_back;"..mesh..";"..tstr..";0,0;false;true;;]".. - "container_end[]" -end - - --- this is a suitable version for most models/meshes that use normal player skins --- (i.e. mobs_redo) with skins in either 64 x 32 or 64 x 64 MC skin format -yl_speak_up.skin_preview_normal = function(skin) - return "image[3,0.7;2,2;[combine:8x8:-8,-8="..skin.."]".. - "image[2.85,0.55;2.3,2.3;[combine:8x8:-40,-8="..skin.."]".. -- head, beard - "image[3,2.75;2,3;[combine:8x12:-20,-20="..skin..":-20,-36="..skin.."]".. -- body - "image[3,5.75;1,3;[combine:4x12:-4,-20="..skin..":-4,-36="..skin.."]".. -- left leg + ov - "image[4,5.75;1,3;[combine:4x12:-4,-20="..skin.."^[transformFX]".. -- right leg - "image[4,5.75;1,3;[combine:4x12:-20,-52="..skin..":-4,-52="..skin.."]".. -- right leg ov - "image[2.0,2.75;1,3;[combine:4x12:-44,-20="..skin..":-44,-36="..skin.."]".. -- left hand - "image[5.0,2.75;1,3;[combine:4x12:-44,-20="..skin.."^[transformFX]".. -- right hand - "image[5.0,2.75;1,3;[combine:4x12:-36,-52="..skin..":-52,-52="..skin.."]".. -- right hand ov - - "image[8,0.7;2,2;[combine:8x8:-24,-8="..skin.."]".. -- back head - "image[7.85,0.55;2.3,2.3;[combine:8x8:-56,-8="..skin.."]".. -- head, beard - "image[8,2.75;2,3;[combine:8x12:-32,-20="..skin..":-32,-36="..skin.."]".. -- body back - "image[8,5.75;1,3;[combine:4x12:-12,-20="..skin.."]".. -- left leg back - "image[8,5.75;1,3;[combine:4x12:-28,-52="..skin..":-12,-52="..skin.."]".. -- r. leg back ov - "image[9,5.75;1,3;[combine:4x12:-12,-20="..skin.."^[transformFX]".. -- right leg back - "image[9,5.75;1,3;[combine:4x12:-12,-36="..skin.."]".. -- right leg back ov - "image[7,2.75;1,3;[combine:4x12:-52,-20="..skin..":-40,-52="..skin..":-60,-52="..skin.."]".. -- l. hand back ov - "image[10,2.75;1,3;[combine:4x12:-52,-20="..skin.."^[transformFX]".. -- right hand back - "image[10,2.75;1,3;[combine:4x12:-52,-20="..skin..":-52,-36="..skin.."]".. -- left hand back - - "" - --local legs_back = "[combine:4x12:-12,-20="..skins.skins[name]..".png" -end - --- this is a version for the yl_speak_up mobs -yl_speak_up.skin_preview_skinsdb_3d_armor_character_5 = function(main_skin) - if(true) then - return yl_speak_up.skin_preview_normal(main_skin) - end - if main_skin == nil or main_skin == "" then - main_skin = "default_greyscale.png" - end - - local player_skin = "(" .. main_skin .. ")" - local skin = -- Consistent on both sizes: - --Chest - "([combine:16x32:-16,-12="..player_skin.."^[mask:yl_speak_up_mask_chest.png)^".. - - --Head - "([combine:16x32:-4,-8="..player_skin.."^[mask:yl_speak_up_mask_head.png)^".. - - --Hat - "([combine:16x32:-36,-8="..player_skin.."^[mask:yl_speak_up_mask_head.png)^".. - --Right Arm - "([combine:16x32:-44,-12="..player_skin.."^[mask:yl_speak_up_mask_rarm.png)^".. - --Right Leg - "([combine:16x32:0,0="..player_skin.."^[mask:yl_speak_up_mask_rleg.png)^".. - - -- Left Arm - "([combine:16x32:-24,-44="..player_skin.."^[mask:(yl_speak_up_mask_rarm.png^[transformFX))^".. - --Left Leg - "([combine:16x32:-12,-32="..player_skin.."^[mask:(yl_speak_up_mask_rleg.png^[transformFX))^".. - - -- Add overlays for 64x skins. these wont appear if skin is 32x because it will be cropped out - --Chest Overlay - "([combine:16x32:-16,-28="..player_skin.."^[mask:yl_speak_up_mask_chest.png)^".. - --Right Arm Overlay - "([combine:16x32:-44,-28="..player_skin.."^[mask:yl_speak_up_mask_rarm.png)^".. - --Right Leg Overlay - "([combine:16x32:0,-16="..player_skin.."^[mask:yl_speak_up_mask_rleg.png)^".. - --Left Arm Overlay - "([combine:16x32:-40,-44="..player_skin.."^[mask:(yl_speak_up_mask_rarm.png^[transformFX))^".. - --Left Leg Overlay - "([combine:16x32:4,-32="..player_skin.."^[mask:(yl_speak_up_mask_rleg.png^[transformFX))" - - -- Full Preview - skin = "((("..skin..")^[resize:64x128)^[mask:yl_speak_up_transform.png)" - return "image[4.5,1.8;9,10.5;"..skin.."]" -end