Added skins mod, and modmenu as submodule

This commit is contained in:
Pitriss 2013-10-25 23:06:08 +02:00
parent 3d395f2dc9
commit 516e544754
135 changed files with 524 additions and 0 deletions

3
.gitmodules vendored
View File

@ -1,3 +1,6 @@
[submodule "mapp"]
path = mapp
url = https://github.com/Pitriss/mapp.git
[submodule "modmenu"]
path = modmenu
url = https://github.com/bhull2010/minetest-mod-modmenu.git

1
modmenu Submodule

@ -0,0 +1 @@
Subproject commit 7e5c84c536d4b2fe48c6ad731de4ebe971a98bc1

4
skins/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*~
.previews/output
.previews/blender_out
.previews/pngcrush_output

Binary file not shown.

76
skins/README Normal file
View File

@ -0,0 +1,76 @@
minetest-skins
==============
Skins mod for minetest.
To add 3D skins:
./install_skin.sh -3d <files>
To add 2D skins:
./install_skin.sh -2d <files>
If you add a 3D skin, please re-run ./generate_previews.sh
Please run ./set_meta.sh after adding any skin, this will allow you to set the name, author and description for them.
Alternatively, you can directly edit the meta file in skins/meta/*.txt
Feel free to send your skins via pull request or PM on the forum ! (with license information)
Credits (also applies to back and previews of skins, please tell me if I missed someone):
From minetest_game (CC BY-SA 3.0):
player_1.png
MirceaKitsune (WTFPL) + bundled script by Zeg9 (WTFPL too):
skin_previews.blend
Jordach (CC BY-SA 3.0):
character_1.png
Zeg9 (CC BY-SA 3.0):
character_2.png
jmf (WTFPL):
player_2.png
character_3.png
character_4.png
character_5.png
character_6.png
character_7.png
character_8.png
character_9.png
character_10.png
character_11.png
Chinchow (WTFPL):
character_12.png
character_13.png
character_14.png
HybridDog (CC BY-SA 3.0):
character_15.png
character_16.png
character_17.png
character_18.png
HybridDog (WTFPL):
player_10.png
Jordach (CC BY-NC-SA):
character_19.png
character_20.png
character_21.png
character_22.png
character_23.png
character_24.png
character_25.png
character_26.png
Stuart Jones (WTFPL):
character_27.png
klunk (WTFPL):
player_3.png
InfinityProject:
player_4.png
player_5.png
player_6.png
player_7.png
player_8.png
player_9.png
prof_turbo (WTFPL):
player_11.png
character_28.png
character_29.png
jojoa1997 (CC BY-SA 3.0):
character_30.png
cisoun (WTFPL):
player_12.png

48
skins/generate_previews.sh Executable file
View File

@ -0,0 +1,48 @@
#!/bin/sh
# This script is used to generate the previews needed by the mod
# It requires blender with the latest python API (2.6x is tested)
# A script that works with older blenders and, maybe, without python, is available in older commits.
# This script can also use pngcrush and imagemagick to reduce output size,
# please enable them if you want to push to the git repository of the mod.
# Pngcrush output will be written to .previews/pngcrush_output
# Warning: any file in .previews/ and skins/textures might be deleted without asking.
PNGCRUSH=true
IMAGEMAGICK=true
cd .previews
rm ../skins/textures/*_preview*.png # Remove all previous previews
blender -b skin_previews.blend --python-text "Generate previews" > /dev/null
if $IMAGEMAGICK
then echo "Stripping metadata from generated files..."
else echo "Moving files..."
fi
rm -rf output # remove my output
mkdir -p output
for i in blender_out/character_*_00.png;
do
out_name=$(basename $i | sed -e 's/_00.png//g')
out_file=output/"$out_name"_preview.png
if $IMAGEMAGICK
then
convert -strip $i $out_file
else
mv $i $out_file
fi
done
for i in blender_out/character_*_01.png;
do
out_name=$(basename $i | sed -e 's/_01.png//g')
out_file=output/"$out_name"_preview_back.png
if $IMAGEMAGICK
then
convert -strip $i $out_file
else
mv $i $out_file
fi
done
if $PNGCRUSH
then
echo "Running pngcrush..."
pngcrush -d ../skins/textures/ output/*_preview*.png 2> pngcrush_output
else mv output/*_preview*.png ../skins/textures/
fi
echo "Done !"

63
skins/install_skin.sh Executable file
View File

@ -0,0 +1,63 @@
#!/bin/sh
# This script can use pngcrush to reduce the size of your skins.
# You can disable it below.
# Settings:
PNGCRUSH=true
OUT=skins/textures/
#-------------------
USAGE="Usage: $0 <-2d|-3d> <files...>"
if [ "$1" = '-2d' ]
then texture_type="player"
elif [ "$1" = '-3d' ]
then texture_type="character"
fi
if [ "$texture_type" = "player" ] || [ "$texture_type" = "character" ]
then
lastid=0
for i in $OUT/${texture_type}_*.png
do
id=$(basename $i | sed "s/[^0-9]//g") # remove everything non-number from it
if [ "$id" -gt "$lastid" ]
then lastid=$id
fi
done
nextid=$lastid
for i in $@
do
if [ $i != $0 ] && [ $i != $1 ] && [ -f $i ]
then
extension="${i##*.}"
filename="${i%.*}"
if [ $extension = "png" ]
then
if [ $texture_type = "character" ] || [ -f "${filename}_back.png" ]
then
(( nextid=(nextid+1) ))
OUTPUT="$OUT/${texture_type}_$nextid.png"
echo "$i => $OUTPUT"
if $PNGCRUSH
then pngcrush $i $OUTPUT
else cp $i $OUTPUT
fi
if [ $texture_type = "player" ]
then
OUTPUT_BACK="$OUT/${texture_type}_${nextid}_back.png"
if $PNGCRUSH
then pngcrush "${filename}_back.png" $OUTPUT_BACK
else cp "${filename}_back.png" $OUTPUT_BACK
fi
fi
else
echo "Couldn't find back texture for $i."
fi
else
echo "Please use png extension for $i."
fi
fi
done
else
echo $USAGE
fi

0
skins/modpack.txt Normal file
View File

59
skins/set_meta.sh Executable file
View File

@ -0,0 +1,59 @@
#!/bin/bash
SPRITES=$(find -regextype sed -regex '.*/player_[0-9]\{1,\}.png' | sort -V)
MODELS=$(find -regextype sed -regex '.*/character_[0-9]\{1,\}.png' | sort -V)
function ask_for_meta {
convert $2 -scale 100x200 /tmp/skins_set_meta
SNAME=$(basename $1)
SNAME=${SNAME%.*}
METAFILE=skins/meta/$SNAME.txt
FORCE=$3
if $FORCE || ! [ -f $METAFILE ]
then
echo $METAFILE
YADOUT=$(yad --form --image=/tmp/skins_set_meta --field $SNAME:LBL --field=Name --field=Author --field=Description --field=Comment)
if [ -z "$YADOUT" ]; then exit; fi # canceled
OIFS="$IFS"
IFS='|'
read -a VALUES <<< "$YADOUT"
IFS="$OIFS"
NAME=${VALUES[1]}
AUTHOR=${VALUES[2]}
DESCRIPTION=${VALUES[3]}
COMMENT=${VALUES[4]}
if [ -n "$NAME" ] && [ -n "$AUTHOR" ]
then
echo -n > $METAFILE # clear it
echo 'name = "'$NAME'",' >> $METAFILE
echo 'author = "'$AUTHOR'",' >> $METAFILE
# only write description and comment if they are specified
if [ -n "$DESCRIPTION" ]
then
echo 'description = "'$DESCRIPTION'",' >> $METAFILE
fi
if [ -n "$COMMENT" ]
then
echo 'comment = "'$COMMENT'",' >> $METAFILE
fi
echo "Saved !"
fi
fi
}
if [ -z $1 ]
then
for i in $SPRITES
do
ask_for_meta $i $i false
done
for i in $MODELS
do
ask_for_meta $i ${i%.*}_preview.png false
done
else
if [ -f ${1%.*}_preview.png ]
then
ask_for_meta $1 ${1%.*}_preview.png true
else
ask_for_meta $1 $1 true
fi
fi
rm /tmp/skins_set_meta

2
skins/skins/depends.txt Normal file
View File

@ -0,0 +1,2 @@
inventory_plus
default

135
skins/skins/init.lua Normal file
View File

@ -0,0 +1,135 @@
-- Skins mod for minetest
-- Adds a skin gallery to the inventory, using inventory_plus
-- Released by Zeg9 under WTFPL
-- Have fun !
skins = {}
skins.type = { SPRITE=0, MODEL=1 }
skins.skins = {}
skins.default = function()
return "character_1"
end
skins.get_type = function(texture)
if not texture then return end
if string.sub(texture,0,string.len("character")) == "character" then
return skins.type.MODEL
end
if string.sub(texture,0,string.len("player")) == "player" then
return skins.type.SPRITE
end
end
skins.modpath = minetest.get_modpath("skins")
dofile(skins.modpath.."/skinlist.lua")
dofile(skins.modpath.."/meta.lua")
dofile(skins.modpath.."/players.lua")
skins.update_player_skin = function(player)
name = player:get_player_name()
if skins.get_type(skins.skins[name]) == skins.type.SPRITE then
player:set_properties({
visual = "upright_sprite",
textures = {skins.skins[name]..".png",skins.skins[name].."_back.png"},
visual_size = {x=1, y=2},
})
elseif skins.get_type(skins.skins[name]) == skins.type.MODEL then
player:set_properties({
visual = "mesh",
textures = {skins.skins[name]..".png"},
visual_size = {x=1, y=1},
})
end
skins.save()
end
skins.formspec = {}
skins.formspec.main = function(name)
page = skins.pages[name]
if page == nil then page = 0 end
local formspec = "size[8,7.5]"
.. "button[0,0;2,.5;main;Back]"
if skins.get_type(skins.skins[name]) == skins.type.MODEL then
formspec = formspec
.. "image[0,.75;1,2;"..skins.skins[name].."_preview.png]"
.. "image[1,.75;1,2;"..skins.skins[name].."_preview_back.png]"
.. "label[6,.5;Raw texture:]"
.. "image[6,1;2,1;"..skins.skins[name]..".png]"
else
formspec = formspec
.. "image[0,.75;1,2;"..skins.skins[name]..".png]"
.. "image[1,.75;1,2;"..skins.skins[name].."_back.png]"
end
local meta = skins.meta[skins.skins[name]]
if meta then
if meta.name then
formspec = formspec .. "label[2,.5;Name: "..meta.name.."]"
end
if meta.author then
formspec = formspec .. "label[2,1;Author: "..meta.author.."]"
end
if meta.description then
formspec = formspec .. "label[2,1.5;"..meta.description.."]"
end
if meta.comment then
formspec = formspec .. 'label[2,2;"'..meta.comment..'"]'
end
end
local index = 0
local skip = 0 -- Skip skins, used for pages
for i, skin in ipairs(skins.list) do
if skip < page*16 then skip = skip + 1 else
if index < 16 then
formspec = formspec .. "image_button["..(index%8)..","..((math.floor(index/8))*2+3)..";1,2;"..skin
if skins.get_type(skin) == skins.type.MODEL then
formspec = formspec .. "_preview"
end
formspec = formspec .. ".png;skins_set_"..i..";]"
end
index = index +1
end
end
if page > 0 then
formspec = formspec .. "button[0,7;1,.5;skins_page_"..(page-1)..";<<]"
else
formspec = formspec .. "button[0,7;1,.5;skins_page_"..page..";<<]"
end
formspec = formspec .. "button[.75,7;6.5,.5;skins_page_"..page..";Page "..(page+1).."/"..math.floor(#skins.list/16+1).."]" -- a button is used so text is centered
if index > 16 then
formspec = formspec .. "button[7,7;1,.5;skins_page_"..(page+1)..";>>]"
else
formspec = formspec .. "button[7,7;1,.5;skins_page_"..page..";>>]"
end
return formspec
end
skins.pages = {}
minetest.register_on_joinplayer(function(player)
if not skins.skins[player:get_player_name()] then
skins.skins[player:get_player_name()] = skins.default()
end
skins.update_player_skin(player)
inventory_plus.register_button(player,"skins","Skin")
end)
minetest.register_on_player_receive_fields(function(player,formname,fields)
if fields.skins then
inventory_plus.set_inventory_formspec(player,skins.formspec.main(player:get_player_name()))
end
for field, _ in pairs(fields) do
if string.sub(field,0,string.len("skins_set_")) == "skins_set_" then
skins.skins[player:get_player_name()] = skins.list[tonumber(string.sub(field,string.len("skins_set_")+1))]
skins.update_player_skin(player)
inventory_plus.set_inventory_formspec(player,skins.formspec.main(player:get_player_name()))
end
if string.sub(field,0,string.len("skins_page_")) == "skins_page_" then
skins.pages[player:get_player_name()] = tonumber(string.sub(field,string.len("skins_page_")+1))
inventory_plus.set_inventory_formspec(player,skins.formspec.main(player:get_player_name()))
end
end
end)

15
skins/skins/meta.lua Normal file
View File

@ -0,0 +1,15 @@
skins.meta = {}
for _, i in ipairs(skins.list) do
skins.meta[i] = {}
local f = io.open(skins.modpath.."/meta/"..i..".txt")
local data = nil
if f then
data = minetest.deserialize("return {"..f:read('*all').."}")
f:close()
end
data = data or {}
skins.meta[i].name = data.name or ""
skins.meta[i].author = data.author or ""
skins.meta[i].description = data.description or nil
skins.meta[i].comment = data.comment or nil
end

View File

@ -0,0 +1,4 @@
name = "Sam",
author = "Jordach",
description = "The default skin.",
comment = "Sam Ain't Minecraft",

View File

@ -0,0 +1,2 @@
name = "Assassin",
author = "jmf",

View File

@ -0,0 +1,2 @@
name = "Harry",
author = "jmf",

View File

@ -0,0 +1,2 @@
name = "Bob",
author = "Chinchow",

View File

@ -0,0 +1,2 @@
name = "Jannette",
author = "Chinchow",

View File

@ -0,0 +1,2 @@
name = "Sheriff",
author = "Chinchow",

View File

@ -0,0 +1,2 @@
name = "Sepia Sam",
author = "Hybrid Dog",

View File

@ -0,0 +1,2 @@
name = "Hybrid Sam",
author = "Hybrid Dog",

View File

@ -0,0 +1,2 @@
name = "Original Sam",
author = "Jordach",

View File

@ -0,0 +1,2 @@
name = "Unnamed",
author = "Hybrid Dog",

View File

@ -0,0 +1,3 @@
name = "VanessaE",
author = "Jordach",
comment = "Actually based from an old picture",

View File

@ -0,0 +1,3 @@
name = "Zeg9",
author = "Zeg9",
description = "My own skin.",

View File

@ -0,0 +1,2 @@
name = "Female Sam",
author = "Jordach",

View File

@ -0,0 +1,2 @@
name = "Battlefield 3 Soldier",
author = "Jordach",

View File

@ -0,0 +1,2 @@
name = "Smooth Sam",
author = "Jordach",

View File

@ -0,0 +1,3 @@
name = "Celeron55",
author = "Jordach",
comment = "Based on a picture from the wiki.",

View File

@ -0,0 +1,2 @@
name = "Tuxedo Sam",
author = "Jordach",

View File

@ -0,0 +1,2 @@
name = "Iron Man MK. 7",
author = "Jordach",

View File

@ -0,0 +1,2 @@
name = "Jordach",
author = "Jordach",

View File

@ -0,0 +1,2 @@
name = "Max",
author = "Stuart Jones",

View File

@ -0,0 +1,2 @@
name = "Slenderman",
author = "prof_turbo",

View File

@ -0,0 +1,2 @@
name = "Strange Killer",
author = "prof_turbo",

View File

@ -0,0 +1,2 @@
name = "Alien",
author = "jmf",

View File

@ -0,0 +1,2 @@
name = "jojoa1997",
author = "jojoa1997",

View File

@ -0,0 +1,2 @@
name = "Soldier",
author = "jmf",

View File

@ -0,0 +1,2 @@
name = "John",
author = "jmf",

View File

@ -0,0 +1,2 @@
name = "Ninja",
author = "jmf",

View File

@ -0,0 +1,2 @@
name = "Oerkki",
author = "jmf",

View File

@ -0,0 +1,2 @@
name = "Tux",
author = "jmf",

View File

@ -0,0 +1,2 @@
name = "Black belt",
author = "jmf",

28
skins/skins/players.lua Normal file
View File

@ -0,0 +1,28 @@
skins.file = minetest.get_worldpath() .. "/skins.mt"
skins.load = function()
local input = io.open(skins.file, "r")
local data = nil
if input then
data = input:read('*all')
end
if data and data ~= "" then
lines = string.split(data,"\n")
for _, line in ipairs(lines) do
data = string.split(line, ' ', 2)
skins.skins[data[1]] = data[2]
end
io.close(input)
end
end
skins.load()
skins.save = function()
local output = io.open(skins.file,'w')
for name, skin in pairs(skins.skins) do
if name and skin then
output:write(name .. " " .. skin .. "\n")
end
end
io.close(output)
end

25
skins/skins/skinlist.lua Normal file
View File

@ -0,0 +1,25 @@
skins.list = {}
skins.add = function(skin)
table.insert(skins.list,skin)
end
local id
id = 1
while true do
local f = io.open(minetest.get_modpath("skins").."/textures/player_"..id..".png")
if (not f) then break end
f:close()
skins.add("player_"..id)
id = id +1
end
id = 1
while true do
local f = io.open(minetest.get_modpath("skins").."/textures/character_"..id..".png")
if (not f) then break end
f:close()
skins.add("character_"..id)
id = id +1
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 412 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 578 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 549 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 417 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Some files were not shown because too many files have changed in this diff Show More