First Upload

Player_Customization.

such clothing - many undone - so wow.

We need all base colors supported. Please take two minutes to /fork/ the
code. I'll accept patches every morning.

to 4aiman: maybe I can push cape code.
master
Austin Williamson 2014-03-13 21:02:13 -06:00
commit ec09f6bfe0
24 changed files with 505 additions and 0 deletions

22
.gitattributes vendored Normal file
View File

@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

215
.gitignore vendored Normal file
View File

@ -0,0 +1,215 @@
#################
## Eclipse
#################
*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
#################
## Visual Studio
#################
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.Publish.xml
*.pubxml
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
#############
## Windows detritus
#############
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac crap
.DS_Store
#############
## Python
#############
*.py[co]
# Packages
*.egg
*.egg-info
dist/
build/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
#Translations
*.mo
#Mr Developer
.mr.developer.cfg

9
clothing/README.txt Normal file
View File

@ -0,0 +1,9 @@
[mod] Clothing [clothing]
=====================================
depends: default, inventory_plus, unified_skins
Adds clothing to the game. Craft basic items out of wool- on the "loom"- dye, and wear!

180
clothing/clothing.lua Normal file
View File

@ -0,0 +1,180 @@
local time = 0
local update_time = tonumber(minetest.setting_get("3d_clothing_update_time"))
if not update_time then
update_time = 1
minetest.setting_set("3d_clothing_update_time", tostring(update_time))
end
clothing = {
player_hp = {},
elements = {"head", "torso", "legs", "feet"},
formspec = "size[8,8.5]button[0,0;2,0.5;main;Back]"
.."list[current_player;main;0,4.5;8,4;]"
.."list[detached:player_name_clothing;clothing_head;3,0;1,1;]"
.."list[detached:player_name_clothing;clothing_torso;3,1;1,1;]"
.."list[detached:player_name_clothing;clothing_legs;3,2;1,1;]"
.."list[detached:player_name_clothing;clothing_feet;3,3;1,1;]",
}
clothing.def = {
state = 0,
count = 0
}
clothing.set_player_clothing = function(self, player)
if not player then
return
end
local name = player:get_player_name()
local player_inv = player:get_inventory()
local clothing_texture = uniskins.default_texture
local clothing_level = 0
local state = 0
local items = 0
local textures = {}
for _,v in ipairs(self.elements) do
local stack = player_inv:get_stack("clothing_"..v, 1)
local level = stack:get_definition().groups["clothing_"..v]
if level then
local item = stack:get_name()
table.insert(textures, item:gsub("%:", "_")..".png")
clothing_level = clothing_level + level
state = state + stack:get_wear()
items = items+1
end
end
if table.getn(textures) > 0 then
clothing_texture = table.concat(textures, "^")
end
local clothing_groups = {fleshy=100}
if clothing_level > 0 then
clothing_groups.level = math.floor(clothing_level / 20)
clothing_groups.fleshy = 100 - clothing_level
end
-- player:set_clothing_groups(clothing_groups)
uniskins.clothing[name] = clothing_texture
uniskins:update_player_visuals(player)
clothing.def[name].state = state
clothing.def[name].count = items
end
clothing.update_clothing = function(self, player)
if not player then
return
end
local name = player:get_player_name()
local hp = player:get_hp() or 0
if hp == 0 or hp == self.player_hp[name] then
return
end
if self.player_hp[name] > hp then
local player_inv = player:get_inventory()
local clothing_inv = minetest.get_inventory({type="detached", name=name.."_clothing"})
if not clothing_inv then
return
end
local heal_max = 0
local state = 0
local items = 0
for _,v in ipairs(self.elements) do
local stack = clothing_inv:get_stack("clothing_"..v, 1)
if stack:get_count() > 0 then
local use = stack:get_definition().groups["clothing_use"] or 0
local heal = stack:get_definition().groups["clothing_heal"] or 0
local item = stack:get_name()
stack:add_wear(use)
clothing_inv:set_stack("clothing_"..v, 1, stack)
player_inv:set_stack("clothing_"..v, 1, stack)
state = state + stack:get_wear()
items = items+1
if stack:get_count() == 0 then
local desc = minetest.registered_items[item].description
if desc then
minetest.chat_send_player(name, "Your "..desc.." got destroyed!")
end
self:set_player_clothing(player)
end
heal_max = heal_max + heal
end
end
clothing.def[name].state = state
clothing.def[name].count = items
if heal_max > math.random(100) then
player:set_hp(self.player_hp[name])
return
end
end
self.player_hp[name] = hp
end
-- Register Callbacks
minetest.register_on_player_receive_fields(function(player, formname, fields)
local name = player:get_player_name()
if fields.clothing then
local formspec = clothing.formspec:gsub("player_name", name)
inventory_plus.set_inventory_formspec(player, formspec)
return
end
for field, _ in pairs(fields) do
if string.sub(field,0,string.len("skins_set_")) == "skins_set_" then
minetest.after(0, function(player)
uniskins.skin[name] = skins.skins[name]..".png"
uniskins:update_player_visuals(player)
end, player)
end
end
end)
minetest.register_on_joinplayer(function(player)
inventory_plus.register_button(player,"clothing", "clothing")
local player_inv = player:get_inventory()
local name = player:get_player_name()
local clothing_inv = minetest.create_detached_inventory(name.."_clothing",{
on_put = function(inv, listname, index, stack, player)
player:get_inventory():set_stack(listname, index, stack)
clothing:set_player_clothing(player)
end,
on_take = function(inv, listname, index, stack, player)
player:get_inventory():set_stack(listname, index, nil)
clothing:set_player_clothing(player)
end,
allow_put = function(inv, listname, index, stack, player)
if inv:is_empty(listname) then
return 1
end
return 0
end,
allow_take = function(inv, listname, index, stack, player)
return stack:get_count()
end,
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
return 0
end,
})
for _,v in ipairs(clothing.elements) do
local list = "clothing_"..v
player_inv:set_size(list, 1)
clothing_inv:set_size(list, 1)
clothing_inv:set_stack(list, 1, player_inv:get_stack(list, 1))
end
clothing.player_hp[name] = 0
clothing.def[name] = {
state = 0,
count = 0
}
minetest.after(0, function(player)
clothing:set_player_clothing(player)
end, player)
end)
minetest.register_globalstep(function(dtime)
time = time + dtime
if time > update_time then
for _,player in ipairs(minetest.get_connected_players()) do
clothing:update_clothing(player)
end
time = 0
end
end)

3
clothing/depends.txt Normal file
View File

@ -0,0 +1,3 @@
default
inventory_plus
unified_skins

76
clothing/init.lua Normal file
View File

@ -0,0 +1,76 @@
-- Crafting
local craft_ingreds = {
red = "wool:red",
blue = "wool:blue",
yellow = "wool:yellow",
}
for k, v in pairs(craft_ingreds) do
minetest.register_craft({
output = "clothing:shirt_"..k,
recipe = {
{v, "", v},
{v, v, v},
{v, v, v},
},
})
minetest.register_craft({
output = "clothing:pants_"..k,
recipe = {
{v, v, v},
{v, "", v},
{v, "", v},
},
})
minetest.register_tool("clothing:shirt_"..k, {
description = k.." shirt",
inventory_image = "clothing_inv_shirt_"..k.."_overlay.png^clothing_shirt_inv_white.png",
texture = "clothing_shirt_"..k.."_overlay.png^clothing_shirt_white.png",
groups = {armor_torso=1, armor_heal=5, armor_use=2000},
wear = 0,
})
minetest.register_tool("clothing:pants_"..k, {
description = k.." pants",
inventory_image = "clothing_inv_pants_"..k.."_overlay.png^clothing_pants_inv_white.png",
texture = "clothing_pants_"..k.."_overlay.png^clothing_pants_white.png",
groups = {armor_legs=1, armor_heal=5, armor_use=2000},
wear = 0,
})
end
-- Register White Stuff
minetest.register_tool("clothing:shirt_white", {
description = "White shirt",
inventory_image = "clothing_inv_shirt_white.png",
texture = "clothing_shirt_white.png",
groups = {armor_torso=1, armor_heal=5, armor_use=2000},
wear = 0,
})
minetest.register_tool("clothing:pants_white", {
description = "White pants",
inventory_image = "clothing_inv_pants_white.png",
texture = "clothing_pants_white.png",
groups = {armor_legs=1, armor_heal=5, armor_use=2000},
wear = 0,
})
minetest.register_craft({
output = "clothing:shirt_white",
recipe = {
{"wool:white", "", "wool:white"},
{"wool:white", "wool:white", "wool:white"},
{"wool:white", "wool:white", "wool:white"},
},
})
minetest.register_craft({
output = "clothing:pants_white",
recipe = {
{"wool:white", "wool:white", "wool:white"},
{"wool:white", "", "wool:white"},
{"wool:white", "", "wool:white"},
},
})

BIN
clothing/textures/cape.xcf Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B