1 (edited by android272 2019-02-06 01:16:00)

Topic: SkinMe script: convert old skins to the new format

Teeworlds 0.7 comes with an all-new skin system that is amazing. The only problem is that this system renders 0.6 skins completely useless. Over the years many skins have been created for 0.6 and it would be a shame to let those die off. So I decided to create this script that will run through your skins folder cut up all your 0.6 skins and convert them into 0.7 skins. Naturally, it would be better to recreate these old skins and migrate them to the new system. But as the community has thinned out not all skins will get this treatment. So this might be the best option for some.

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.json file in your skin folder. The script will even make a backup of the old skins and place them into a "0.6 skins" folder for you in case you want to go back to the old version.

Depending on the skin the eyes may be a problem. so some eyes may still need to be modified manually.

#!/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 -resize 128x128^ output.png
    convert $f -crop 96x96+96+0 -resize 128x128^ output2.png

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

    mogrify -extent 256x256+0+0 -background none -strip 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

    convert output8.png -resize 120x120^ -strip output9.png

    cp output9.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 output9.png

    cd ..
}

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

    cd "./feet"

    convert $f -crop 32x32+208+32 -resize 64x64^ output.png
        convert $f -crop 32x32+208+64 -resize 64x64^ output2.png

        convert output.png output2.png +append -strip 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 -resize 128x64^ -strip output.png

    cp output.png $f

    rm output.png

    cd ..
}

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

    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.json
}

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: SkinMe script: convert old skins to the new format

Looks nice, well done!

Please delete my account.

3

Re: SkinMe 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: SkinMe 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: SkinMe 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: SkinMe 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: SkinMe 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: SkinMe 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

9

Re: SkinMe script: convert old skins to the new format

The script is now complete. Just place your 0.6 skins in the same directory with the script and run it.  place the .json files in your teewolds home folder or the skins will not show up in the skins editor. the body parts will still be made available no matter where you place them but for some reason, the json file needs to be placed in your home folder.

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