Add autoregistration.

master
None 2015-02-02 23:03:43 +03:00
parent 9687d5b960
commit 175743c714
1 changed files with 37 additions and 6 deletions

View File

@ -5,7 +5,7 @@ clothing.update_skin = function(player)
-- Function gets the player's "wear" inventory list.
-- It's created by mod "inventory"
local weared = player:get_inventory():get_list("wear")
local skin = default.player_get_animation(player).textures[1]
local skin = player:get_player_name() .. ".png"
for _,itemstack in ipairs(weared) do
if not itemstack:is_empty() then
skin = skin .. "^" .. itemstack:get_definition().wear_image
@ -31,24 +31,55 @@ end)
--{{{ Cloth
-- Required values is:
-- "wear_image" (this image is adding on player skin)
-- Names of items (and textures) for autoregistration
clothing.registered = {
"black_coat",
"black_glasses",
"blue_longskirt",
"blue_waistcoat",
"brown_hat",
"brown_hat_wth_badge",
"hazel_scarf",
"jabot",
"leather_boots",
"leather_dirty_coat",
"leather_high_boot",
"leather_long_gloves",
"linen_shirt",
"salmon_long_dress",
"white_apron",
"white_blouse",
"white_bonnet",
"white_greek_dress",
}
for _,name in pairs(clothing.registered) do
minetest.register_craftitem("clothing:" .. name, {
description = name:gsub("_", " "):gsub("^.", string.upper),
inventory_image = "clothing_" ..name.. "_inv.png",
wield_image = "clothing_" ..name.. "_inv.png",
wear_image = "clothing_" ..name.. ".png",
stack_max = 1,
})
end
-- Special case
minetest.register_craftitem("clothing:test1", {
decription = "Test cloth 1",
description = "Test cloth 1",
inventory_image = "clothing_test.png",
wield_image = "clothing_test.png",
wear_image = "clothing_test.png",
stack_max = 1,
})
minetest.register_craftitem("clothing:test2", {
decription = "Test cloth 2",
description = "Test cloth 2",
inventory_image = "clothing_test2.png",
wield_image = "clothing_test2.png",
wear_image = "clothing_test2.png",
stack_max = 1,
})
minetest.register_craftitem("clothing:test3", {
decription = "Test cloth 3",
description = "Test cloth 3",
inventory_image = "clothing_test3.png",
wield_image = "clothing_test3.png",
wear_image = "clothing_test3.png",