1 (edited by android272 2019-01-10 04:29:27)

Topic: script: convert old skins to the new format

I posted this in an old thread but no one seems to have noticed so I thought I would repost it in an new thread.

I have seen youtube and in forms that the new skin system will DESTROY!!!!!!!!!!! TEEWORLDS because all the old skins will no longer work in the new version.  When I first saw this I thought dude its not that bad just crop out your skin into the folders.  Then I thought about how many skins there are for Teeworlds, how some people might just download the skins and not be able to do this, and how lazy we can get.  So I made the script below. 

All you have to do is place this script into the skin folder, make sure it is set as exhaustible and run it.  It will check to see if you have the folders needed for the new system and if you don't will create them for you. Then it will loop through all the .pngs in the skin folder copy them to the various folders, crop, rearrange the skin, save them, and make you a skin.skn file in your skin folder.  The developers will need to help with the skin.skn file as I did not know what to put for _hue, _sat, _lgt, _alp to not mess with the skin.

the only thing you need to do now is modify the eyes.  If your skin does not use the standard eyes then you need to modify them so that both eyes are in the one tile as the new system does not duplicate and flip them. If your skin does use the standard eyes then you will have to modify the skin.skn file and replace the last skin.png with standard.png.

I did write the lines to delete the old skin but I figured some might want to keep the old files for later.  If you want to delete the old skin then take away the '#' from '#deleteSkin

#!/bin/bash
checkEnv () {
    if test ! -d "./body"; then
          mkdir body
    fi

    if test ! -d "./decoration"; then
          mkdir decoration
    fi

    if test ! -d "./eyes"; then
          mkdir eyes
    fi        

    if test ! -d "./feet"; then
          mkdir feet
    fi

    if test ! -d "./hands"; then
          mkdir hands
    fi

    if test ! -d "./marking"; then
          mkdir marking
    fi

    if test ! -d "./0.6_skins"; then
          mkdir 0.6_skins
    fi
}

stripBody() {
    cp $f "./body"

    cd "./body"

    convert $f -crop 96x96+0+0 output.png
    convert $f -crop 96x96+96+0 output2.png

    montage -geometry +1+1 output2.png output.png -background none output3.png

    mogrify -extent 192x192+0+0 -background none output3.png
    
    cp output3.png $f

    rm output.png output2.png output3.png

    cd ..
}

stripEyes() {
    cp $f "./eyes"

    cd "./eyes"

    #Normal Eye
    convert $f -crop 24x32+64+96 normaleye.png
    convert $f -crop 8x32+64+96 space.png

    convert space.png normaleye.png +append -background none lefteye.png
    
    convert -flop lefteye.png righteye.png

    convert lefteye.png righteye.png +append -background none normal.png


    #Angry Eye
    convert $f -crop 24x32+96+96 angryeye.png

    convert space.png angryeye.png +append -background none lefteye.png
    
    convert -flop lefteye.png righteye.png

    convert lefteye.png righteye.png +append -background none angry.png

    #Hurt Eye
    convert $f -crop 24x32+128+96 hurteye.png

    convert space.png hurteye.png +append lefteye.png
    
    convert -flop lefteye.png righteye.png

    convert lefteye.png righteye.png +append -background none hurt.png

    #Happy Eye
    convert $f -crop 24x32+160+96 happyeye.png

    convert space.png happyeye.png +append -background none lefteye.png
    
    convert -flop lefteye.png righteye.png

    convert lefteye.png righteye.png +append -background none happy.png

    #Ninja Eye
    convert $f -crop 24x32+224+96 ninjaeye.png

    convert space.png ninjaeye.png +append -background none lefteye.png
    
    convert -flop lefteye.png righteye.png

    convert lefteye.png righteye.png +append -background none ninja.png

    #Merge Eyes
    convert normal.png angry.png +append -background none output3.png
    convert hurt.png happy.png +append -background none output4.png
    convert ninja.png space.png +append -background none output5.png

    convert output3.png output4.png -append -background none output6.png
    convert output6.png output5.png -append -background none output7.png
    convert output7.png space.png -append -background none output8.png

    cp output8.png $f

    #Clean Up
    rm normaleye.png normal.png angryeye.png angry.png hurteye.png hurt.png happyeye.png happy.png ninjaeye.png ninja.png lefteye.png righteye.png space.png output1.png output2.png output3.png output4.png output5.png output6.png output7.png output8.png

    cd ..
}

stripFeet() {
    cp $f "./feet"

    cd "./feet"

    convert $f -crop 64x32+192+32 output.png
    convert $f -crop 64x32+192+64 output2.png

    convert output.png output2.png +append output3.png

    cp output3.png $f

    rm output.png output2.png output3.png

    cd ..
}

stripHands() {
    cp $f "./hands"

    cd "./hands"

    convert $f -crop 64x32+192+0 output.png

    cp output.png $f

    rm output.png

    cd ..
}

createSkin() {
    name=$(echo $f | cut -f 1 -d '.')
    touch "$name.skn"

    echo "{"skin": {
        "body": {
            "filename": "$name",
            "custom_colors": "false"
        },
        "hands": {
            "filename": "$name",
            "custom_colors": "false"
        },
        "feet": {
            "filename": "$name",
            "custom_colors": "false"
        },
        "eyes": {
            "filename": "$name",
            "custom_colors": "false"
        }}
    }" >> $name.skn
}

moveskin() {
    cp $f "./0.6_skins"    
}

deletSkin() {
    rm $f
}

checkEnv

for f in *.png; do
    stripBody
    stripEyes
    stripFeet
    stripHands
    createSkin
    moveskin
    deletSkin
done

________________________________________________________________________________
License: GPL
TL;DR

CAN:                             CANNOT:            MUST:
Commercial Use          Sublicense            Include Original
Distribute                     Hold Liable            Disclose Source
Modify                                                        Include Copyright
Place Warranty                                          State Changes
                                                                  Include License
Note: I don't care too much about giving me credit or that you state changes as much as this copy right must stay with what ever is copied or modified.

Jesus is my Lord and Savior. Praise be unto God for giving us a way to live with him.

Check out my DeviantArt for all my TeeWorlds art and ideas for Teeoworlds

2

Re: script: convert old skins to the new format

Looks nice, well done!

Please delete my account.

3

Re: script: convert old skins to the new format

It would be nice if a developer could modify the script a little. I don't know how the .skn file is constructed. Landil made a great pdf that was very helpful to make this script but I still don't know how the .skn file should be made exactly.

Jesus is my Lord and Savior. Praise be unto God for giving us a way to live with him.

Check out my DeviantArt for all my TeeWorlds art and ideas for Teeoworlds

4

Re: script: convert old skins to the new format

maybe this is helpful to understand whats going on: https://github.com/teeworlds/teeworlds/ … asrc/skins

as far as I got it all imagefiles with skins are greyscaled and their colors are defined by .json files, eg. this one: https://github.com/teeworlds/teeworlds/ … kitty.json
Those files obviously define the skins that can be used by telling tw which bodyparts with which color are supposed to be composed to the finally displayed skin.

Luck is allowed

5 (edited by android272 2015-08-31 03:10:36)

Re: script: convert old skins to the new format

below is the part of my new script that will make the .skn file.  Can I simply write "custom_colors": "false" for everything since the old skins will already be colored? Can I leave out "marking":{...} and "decoration":{...}? as I can not extract the markings or the decoration form these old skins, they will just have to part of the body. Can I leave out  "hue": ###, "sat": ###, "lgt": ###, "alp": ### and just use "custom_colors": "false"?

{"skin": {
        "body": {
            "filename": "$name",
            "custom_colors": "false"
        },
        "hands": {
            "filename": "$name",
            "custom_colors": "false"
        },
        "feet": {
            "filename": "$name",
            "custom_colors": "false"
        },
        "eyes": {
            "filename": "$name",
            "custom_colors": "false"
        }}
}

after looking at the new skin files I will have to update the script before it can be used to convert old skins to new ones.

Jesus is my Lord and Savior. Praise be unto God for giving us a way to live with him.

Check out my DeviantArt for all my TeeWorlds art and ideas for Teeoworlds

6

Re: script: convert old skins to the new format

I thought I lost this. I don't know if this will still work as I can not test it currently. But I thought I might bump this to the top.

Jesus is my Lord and Savior. Praise be unto God for giving us a way to live with him.

Check out my DeviantArt for all my TeeWorlds art and ideas for Teeoworlds

7

Re: script: convert old skins to the new format

The script does not output files in the correct format / is outdated:
https://i.imgur.com/kPIrvLW.png
https://i.imgur.com/KJhyVQm.png

Not Luck, Just Magic.

8

Re: script: convert old skins to the new format

Thanks, Dune I updated the script so that it positions everything correctly. There is still a problem that I have to work out in regard to the size of the skins produced. I think the 0.6 skins were a bit smaller than 0.7 skins. So I need to scale them up which should not be all that hard. There is also a problem with the eyes. I was unable to find a solution for giving it a transparent background so there is a strange black box at the bottom. The eyes will also need to be moved a little bit. right now there is way too much space between them.

Jesus is my Lord and Savior. Praise be unto God for giving us a way to live with him.

Check out my DeviantArt for all my TeeWorlds art and ideas for Teeoworlds