From 175743c714ad81a7ed48ce83759db590c80c6bc0 Mon Sep 17 00:00:00 2001 From: None Date: Mon, 2 Feb 2015 23:03:43 +0300 Subject: [PATCH] Add autoregistration. --- clothing/init.lua | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/clothing/init.lua b/clothing/init.lua index ae05088..e4fbd96 100644 --- a/clothing/init.lua +++ b/clothing/init.lua @@ -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",