Version update: 0.3.0

This commit is contained in:
stujones11 2013-06-22 19:31:57 +01:00
parent 4a86ba8260
commit efea71a63e
54 changed files with 1687 additions and 810 deletions

157
3d_armor/armor.lua Normal file
View File

@ -0,0 +1,157 @@
local time = 0
local update_time = tonumber(minetest.setting_get("3d_armor_update_time"))
if not update_time then
update_time = 1
minetest.setting_set("3d_armor_update_time", tostring(update_time))
end
armor = {
player_hp = {},
}
armor.set_player_armor = function(self, player)
if not player then
return
end
local name = player:get_player_name()
local player_inv = player:get_inventory()
local armor_texture = uniskins.default_texture
local armor_level = 0
local textures = {}
for _,v in ipairs({"head", "torso", "legs", "feet"}) do
local stack = player_inv:get_stack("armor_"..v, 1)
local level = stack:get_definition().groups["armor_"..v]
if level then
local item = stack:get_name()
table.insert(textures, item:gsub("%:", "_")..".png")
armor_level = armor_level + level
end
end
if table.getn(textures) > 0 then
armor_texture = table.concat(textures, "^")
end
local armor_groups = {fleshy=100}
if armor_level > 0 then
armor_groups.level = math.floor(armor_level / 20)
armor_groups.fleshy = 100 - armor_level
end
player:set_armor_groups(armor_groups)
uniskins.armor[name] = armor_texture
uniskins:update_player_visuals(player)
end
armor.update_armor = 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 armor_inv = minetest.get_inventory({type="detached", name=name.."_armor"})
if not armor_inv then
return
end
local heal_max = 0
for _,v in ipairs({"head", "torso", "legs", "feet"}) do
local stack = armor_inv:get_stack("armor_"..v, 1)
if stack:get_count() > 0 then
local use = stack:get_definition().groups["armor_use"] or 0
local heal = stack:get_definition().groups["armor_heal"] or 0
local item = stack:get_name()
stack:add_wear(use)
armor_inv:set_stack("armor_"..v, 1, stack)
player_inv:set_stack("armor_"..v, 1, stack)
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_armor(player)
end
heal_max = heal_max + heal
end
end
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.armor then
inventory_plus.set_inventory_formspec(player, "size[8,8.5]"
.."button[0,0;2,0.5;main;Back]"
.."list[current_player;main;0,4.5;8,4;]"
.."list[detached:"..name.."_armor;armor_head;3,0;1,1;]"
.."list[detached:"..name.."_armor;armor_torso;3,1;1,1;]"
.."list[detached:"..name.."_armor;armor_legs;3,2;1,1;]"
.."list[detached:"..name.."_armor;armor_feet;3,3;1,1;]")
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,"armor", "Armor")
local player_inv = player:get_inventory()
local name = player:get_player_name()
local armor_inv = minetest.create_detached_inventory(name.."_armor",{
on_put = function(inv, listname, index, stack, player)
player:get_inventory():set_stack(listname, index, stack)
armor:set_player_armor(player)
end,
on_take = function(inv, listname, index, stack, player)
player:get_inventory():set_stack(listname, index, nil)
armor:set_player_armor(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({"head", "torso", "legs", "feet"}) do
local list = "armor_"..v
player_inv:set_size(list, 1)
armor_inv:set_size(list, 1)
armor_inv:set_stack(list, 1, player_inv:get_stack(list, 1))
end
armor.player_hp[name] = 0
minetest.after(0, function(player)
armor:set_player_armor(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
armor:update_armor(player)
end
time = 0
end
end)

View File

@ -1,91 +0,0 @@
armor_api = {
player_hp = {},
}
armor_api.get_armor_textures = function(self, player)
if not player then
return
end
local name = player:get_player_name()
local textures = {}
local player_inv = player:get_inventory()
for _,v in ipairs({"head", "torso", "legs"}) do
local stack = player_inv:get_stack("armor_"..v, 1)
if stack:get_definition().groups["armor_"..v] then
local item = stack:get_name()
textures[v] = item:gsub("%:", "_")..".png"
end
end
local stack = player_inv:get_stack("armor_shield", 1)
if stack:get_definition().groups["armor_shield"] then
local item = stack:get_name()
textures["shield"] = minetest.registered_items[item].inventory_image
end
return textures
end
armor_api.set_player_armor = function(self, player)
if not player then
return
end
local name = player:get_player_name()
local player_inv = player:get_inventory()
local armor_level = 0
for _,v in ipairs({"head", "torso", "legs", "shield"}) do
local stack = player_inv:get_stack("armor_"..v, 1)
local armor = stack:get_definition().groups["armor_"..v] or 0
armor_level = armor_level + armor
end
local armor_groups = {fleshy=100}
if armor_level > 0 then
armor_groups.level = math.floor(armor_level / 20)
armor_groups.fleshy = 100 - armor_level
end
player:set_armor_groups(armor_groups)
uniskins:update_player_visuals(player)
end
armor_api.update_armor = function(self, player)
if not player then
return
end
local name = player:get_player_name()
local hp = player:get_hp()
if hp == nil or 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 armor_inv = minetest.get_inventory({type="detached", name=name.."_outfit"})
if armor_inv == nil then
return
end
local heal_max = 0
for _,v in ipairs({"head", "torso", "legs", "shield"}) do
local stack = armor_inv:get_stack("armor_"..v, 1)
if stack:get_count() > 0 then
local use = stack:get_definition().groups["armor_use"] or 0
local heal = stack:get_definition().groups["armor_heal"] or 0
local item = stack:get_name()
stack:add_wear(use)
armor_inv:set_stack("armor_"..v, 1, stack)
player_inv:set_stack("armor_"..v, 1, stack)
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_armor(player)
end
heal_max = heal_max + heal
end
end
if heal_max > math.random(100) then
player:set_hp(self.player_hp[name])
return
end
end
self.player_hp[name] = hp
end

View File

@ -43,32 +43,16 @@ Leggings:
[3d_armor:leggings_steel] X = [default:steel_ingot]
[3d_armor:leggings_bronze] X = [default:bronze_ingot]
Shields:
Boots:
+---+---+---+
| X | X | X |
| X | | X |
+---+---+---+
| X | X | X |
+---+---+---+
| | X | |
| X | | X |
+---+---+---+
[3d_armor:shield_wood] X = [default:wood]
[3d_armor:shield_steel] X = [default:steel_ingot]
[3d_armor:shield_bronze] X = [default:bronze_ingot
[3d_armor:boots_wood] X = [default:wood]
[3d_armor:boots_steel] X = [default:steel_ingot]
[3d_armor:boots_bronze] X = [default:bronze_ingot
Enhanced Wooden Shield:
SI = [default:steel_ingot]
WS = [3d_armor:shield_wood]
+----+
| SI |
+----+
| WS |
+----+
| SI |
+----+
[3d_armor:shield_enhanced_wood]

View File

@ -1,108 +1,124 @@
dofile(minetest.get_modpath(minetest.get_current_modname()).."/armor_api.lua")
local time = 0
local update_time = tonumber(minetest.setting_get("3d_armor_update_time"))
if not update_time then
update_time = 1
minetest.setting_set("3d_armor_update_time", tostring(update_time))
end
dofile(minetest.get_modpath(minetest.get_current_modname()).."/armor.lua")
-- Regisiter Head Armor
minetest.register_tool("3d_armor:helmet_wood", {
description = "Wood Helmet",
inventory_image = "3d_armor_inv_helmet_wood.png",
groups = {armor_head=5, armor_heal=0, armor_use=1000},
groups = {armor_head=5, armor_heal=0, armor_use=2000},
wear = 0,
})
minetest.register_tool("3d_armor:helmet_steel", {
description = "Steel Helmet",
inventory_image = "3d_armor_inv_helmet_steel.png",
groups = {armor_head=10, armor_heal=5, armor_use=250},
groups = {armor_head=10, armor_heal=0, armor_use=500},
wear = 0,
})
minetest.register_tool("3d_armor:helmet_bronze", {
description = "Bronze Helmet",
inventory_image = "3d_armor_inv_helmet_bronze.png",
groups = {armor_head=15, armor_heal=10, armor_use=100},
groups = {armor_head=10, armor_heal=6, armor_use=250},
wear = 0,
})
minetest.register_tool("3d_armor:helmet_diamond", {
description = "Diamond Helmet",
inventory_image = "3d_armor_inv_helmet_diamond.png",
groups = {armor_head=15, armor_heal=12, armor_use=100},
wear = 0,
})
-- Regisiter Torso Armor
minetest.register_tool("3d_armor:chestplate_wood", {
description = "Wood Chestplate",
inventory_image = "3d_armor_inv_chestplate_wood.png",
groups = {armor_torso=10, armor_heal=0, armor_use=1000},
groups = {armor_torso=10, armor_heal=0, armor_use=2000},
wear = 0,
})
minetest.register_tool("3d_armor:chestplate_steel", {
description = "Steel Chestplate",
inventory_image = "3d_armor_inv_chestplate_steel.png",
groups = {armor_torso=15, armor_heal=5, armor_use=250},
groups = {armor_torso=15, armor_heal=0, armor_use=500},
wear = 0,
})
minetest.register_tool("3d_armor:chestplate_bronze", {
description = "Bronze Chestplate",
inventory_image = "3d_armor_inv_chestplate_bronze.png",
groups = {armor_torso=25, armor_heal=10, armor_use=100},
groups = {armor_torso=15, armor_heal=6, armor_use=250},
wear = 0,
})
minetest.register_tool("3d_armor:chestplate_diamond", {
description = "Diamond Chestplate",
inventory_image = "3d_armor_inv_chestplate_diamond.png",
groups = {armor_torso=20, armor_heal=12, armor_use=100},
wear = 0,
})
-- Regisiter Leg Armor
minetest.register_tool("3d_armor:leggings_wood", {
description = "Wood Leggings",
inventory_image = "3d_armor_inv_leggings_wood.png",
groups = {armor_legs=5, armor_heal=0, armor_use=1000},
groups = {armor_legs=5, armor_heal=0, armor_use=2000},
wear = 0,
})
minetest.register_tool("3d_armor:leggings_steel", {
description = "Steel Leggings",
inventory_image = "3d_armor_inv_leggings_steel.png",
groups = {armor_legs=10, armor_heal=5, armor_use=250},
groups = {armor_legs=15, armor_heal=0, armor_use=500},
wear = 0,
})
minetest.register_tool("3d_armor:leggings_bronze", {
description = "Bronze Leggings",
inventory_image = "3d_armor_inv_leggings_bronze.png",
groups = {armor_legs=15, armor_heal=10, armor_use=100},
groups = {armor_legs=15, armor_heal=6, armor_use=250},
wear = 0,
})
-- Regisiter Shields
minetest.register_tool("3d_armor:shield_wood", {
description = "Wooden Shield",
inventory_image = "3d_armor_inv_shield_wood.png",
groups = {armor_shield=10, armor_heal=0, armor_use=1000},
minetest.register_tool("3d_armor:leggings_diamond", {
description = "Diamond Leggings",
inventory_image = "3d_armor_inv_leggings_diamond.png",
groups = {armor_legs=20, armor_heal=12, armor_use=100},
wear = 0,
})
minetest.register_tool("3d_armor:shield_enhanced_wood", {
description = "Enhanced Wooden Shield",
inventory_image = "3d_armor_inv_shield_enhanced_wood.png",
groups = {armor_shield=15, armor_heal=5, armor_use=500},
-- Regisiter Boots
minetest.register_tool("3d_armor:boots_wood", {
description = "Wood Boots",
inventory_image = "3d_armor_inv_boots_wood.png",
groups = {armor_feet=5, armor_heal=0, armor_use=2000},
wear = 0,
})
minetest.register_tool("3d_armor:shield_steel", {
description = "Steel Shield",
inventory_image = "3d_armor_inv_shield_steel.png",
groups = {armor_shield=20, armor_heal=5, armor_use=250},
minetest.register_tool("3d_armor:boots_steel", {
description = "Steel Boots",
inventory_image = "3d_armor_inv_boots_steel.png",
groups = {armor_feet=10, armor_heal=0, armor_use=500},
wear = 0,
})
minetest.register_tool("3d_armor:shield_bronze", {
description = "Bronze Shield",
inventory_image = "3d_armor_inv_shield_bronze.png",
groups = {armor_shield=25, armor_heal=10, armor_use=100},
minetest.register_tool("3d_armor:boots_bronze", {
description = "Bronze Boots",
inventory_image = "3d_armor_inv_boots_bronze.png",
groups = {armor_feet=10, armor_heal=6, armor_use=250},
wear = 0,
})
minetest.register_tool("3d_armor:boots_diamond", {
description = "Diamond Boots",
inventory_image = "3d_armor_inv_boots_diamond.png",
groups = {armor_feet=15, armor_heal=12, armor_use=100},
wear = 0,
})
@ -112,6 +128,7 @@ local craft_ingreds = {
wood = "default:wood",
steel = "default:steel_ingot",
bronze = "default:bronze_ingot",
diamond = "default:diamond",
}
for k, v in pairs(craft_ingreds) do
@ -140,92 +157,12 @@ for k, v in pairs(craft_ingreds) do
},
})
minetest.register_craft({
output = "3d_armor:shield_"..k,
output = "3d_armor:boots_"..k,
recipe = {
{v, v, v},
{v, v, v},
{"", v, ""},
{v, "", v},
{v, "", v},
},
})
end
minetest.register_craft({
output = "3d_armor:shield_enhanced_wood",
recipe = {
{"default:steel_ingot"},
{"3d_armor:shield_wood"},
{"default:steel_ingot"},
},
})
-- Register Callbacks
minetest.register_on_player_receive_fields(function(player, formname, fields)
local name = player:get_player_name()
if fields.outfit then
inventory_plus.set_inventory_formspec(player, "size[8,7.5]"
.."button[0,0;2,0.5;main;Back]"
.."list[current_player;main;0,3.5;8,4;]"
.."list[detached:"..name.."_outfit;armor_head;3,0;1,1;]"
.."list[detached:"..name.."_outfit;armor_torso;3,1;1,1;]"
.."list[detached:"..name.."_outfit;armor_legs;3,2;1,1;]"
.."list[detached:"..name.."_outfit;armor_shield;4,1;1,1;]")
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)
armor_api:set_player_armor(player)
end, player)
end
end
end)
minetest.register_on_joinplayer(function(player)
inventory_plus.register_button(player,"outfit", "Outfit")
local player_inv = player:get_inventory()
local name = player:get_player_name()
local armor_inv = minetest.create_detached_inventory(name.."_outfit",{
on_put = function(inv, listname, index, stack, player)
player:get_inventory():set_stack(listname, index, stack)
armor_api:set_player_armor(player)
end,
on_take = function(inv, listname, index, stack, player)
player:get_inventory():set_stack(listname, index, nil)
armor_api:set_player_armor(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({"head", "torso", "legs", "shield"}) do
local armor = "armor_"..v
player_inv:set_size(armor, 1)
armor_inv:set_size(armor, 1)
armor_inv:set_stack(armor, 1, player_inv:get_stack(armor, 1))
end
armor_api.player_hp[name] = 0
minetest.after(0, function(player)
armor_api:set_player_armor(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
armor_api:update_armor(player)
end
time = 0
end
end)

Binary file not shown.

After

Width:  |  Height:  |  Size: 632 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 629 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 609 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 565 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 933 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 878 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 858 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 863 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 B

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 240 B

After

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 251 B

After

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 241 B

After

Width:  |  Height:  |  Size: 237 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 723 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 747 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 697 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 667 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 885 B

After

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 622 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 774 B

After

Width:  |  Height:  |  Size: 578 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 737 B

After

Width:  |  Height:  |  Size: 577 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 723 B

View File

@ -1,6 +0,0 @@
[mod] Moreores Armor [more_armor]
========================================
depends: default, 3d_armor
Adds Bronze and Mithril armor sets, upgrades moreores weapons.

View File

@ -1,46 +0,0 @@
more_armor -- Crafting Guide
----------------------------
M = Mithril Ingot [moreores:mithril_ingot]
Mithril Helmet: [more_armor:helmet_mithril]
+---+---+---+
| M | M | M |
+---+---+---+
| M | | M |
+---+---+---+
| | | |
+---+---+---+
Mithril Chestplate: [more_armor:chestplate_mithril]
+---+---+---+
| M | | M |
+---+---+---+
| M | M | M |
+---+---+---+
| M | M | M |
+---+---+---+
Mithril Leggings: [more_armor:leggings_mithril]
+---+---+---+
| M | M | M |
+---+---+---+
| M | | M |
+---+---+---+
| M | | M |
+---+---+---+
Mithril Shield: [more_armor:shield_mithril]
+---+---+---+
| M | M | M |
+---+---+---+
| M | M | M |
+---+---+---+
| | M | |
+---+---+---+

View File

@ -1,2 +0,0 @@
default
3d_armor

View File

@ -1,89 +0,0 @@
-- Override moreores weapons (make them more powerful)
minetest.register_tool(":moreores:sword_mithril", {
description = "Mithril Sword",
inventory_image = "moreores_tool_mithrilsword.png",
tool_capabilities = {
full_punch_interval = 0.8,
max_drop_level=1,
groupcaps={
fleshy={times={[0]=0.65, [1]=0.50, [2]=0.40, [3]=0.30}, uses=50, maxlevel=3},
snappy={times={[2]=0.80, [3]=0.40}, uses=100, maxlevel=1},
choppy={times={[3]=0.90}, uses=50, maxlevel=0}
}
}
})
-- Regisiter Head Armor
minetest.register_tool("more_armor:helmet_mithril", {
description = "Mithril Helmet",
inventory_image = "more_armor_inv_helmet_mithril.png",
groups = {armor_head=15, armor_heal=15, armor_use=50},
wear = 0,
})
minetest.register_craft({
output = "more_armor:helmet_mithril",
recipe = {
{"moreores:mithril_ingot", "moreores:mithril_ingot", "moreores:mithril_ingot"},
{"moreores:mithril_ingot", "", "moreores:mithril_ingot"},
{"", "", ""},
},
})
-- Regisiter Torso Armor
minetest.register_tool("more_armor:chestplate_mithril", {
description = "Mithril Chestplate",
inventory_image = "more_armor_inv_chestplate_mithril.png",
groups = {armor_torso=25, armor_heal=15, armor_use=50},
wear = 0,
})
minetest.register_craft({
output = "more_armor:chestplate_mithril",
recipe = {
{"moreores:mithril_ingot", "", "moreores:mithril_ingot"},
{"moreores:mithril_ingot", "moreores:mithril_ingot", "moreores:mithril_ingot"},
{"moreores:mithril_ingot", "moreores:mithril_ingot", "moreores:mithril_ingot"},
},
})
-- Regisiter Leg Armor
minetest.register_tool("more_armor:leggings_mithril", {
description = "Mithril Leggings",
inventory_image = "more_armor_inv_leggings_mithril.png",
groups = {armor_legs=20, armor_heal=15, armor_use=50},
wear = 0,
})
minetest.register_craft({
output = "more_armor:leggings_mithril",
recipe = {
{"moreores:mithril_ingot", "moreores:mithril_ingot", "moreores:mithril_ingot"},
{"moreores:mithril_ingot", "", "moreores:mithril_ingot"},
{"moreores:mithril_ingot", "", "moreores:mithril_ingot"},
},
})
-- Regisiter Shields
minetest.register_tool("more_armor:shield_mithril", {
description = "Mithril Shield",
inventory_image = "more_armor_inv_shield_mithril.png",
groups = {armor_shield=25, armor_heal=15, armor_use=50},
wear = 0,
})
minetest.register_craft({
output = "more_armor:shield_mithril",
recipe = {
{"moreores:mithril_ingot", "moreores:mithril_ingot", "moreores:mithril_ingot"},
{"moreores:mithril_ingot", "moreores:mithril_ingot", "moreores:mithril_ingot"},
{"", "moreores:mithril_ingot", ""},
},
})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 647 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 777 B

View File

@ -1,70 +1,51 @@
uniskins = {
skins = {},
default_character_skin = "character.png",
skin = {},
armor = {},
wielditem = {},
default_skin = "character.png",
default_texture = nil
}
uniskins.get_player_skin = function(self, name)
if minetest.get_modpath("skins") then
local skin = skins.skins[name]
if skin then
if skins.get_type(skin) == skins.type.MODEL then
return skin..".png"
end
end
end
if self.skins[name] then
return self.skins[name]
end
return self.default_character_skin
end
uniskins.update_player_visuals = function(self, player)
if not player then
return
end
local name = player:get_player_name()
local texture = self:get_player_skin(name)
local has_wieldview = minetest.get_modpath("wieldview")
if has_wieldview then
texture = "wieldview_character_bg.png^[combine:64x64:0,32="..texture
local wielded_item_texture = wieldview:get_wielded_item_texture(player)
if wielded_item_texture then
texture = texture.."^[combine:64x64:0,0="..wielded_item_texture
end
local texture = "uniskins_trans.png"
if self.wielditem[name] then
texture = texture.."^[combine:64x64:0,0="..self.wielditem[name]
end
if minetest.get_modpath("3d_armor") then
local textures = armor_api:get_armor_textures(player)
for _,v in ipairs({"head", "torso", "legs"}) do
if textures[v] then
texture = texture.."^"
if has_wieldview then
texture = texture.."[combine:64x64:0,32="
end
texture = texture..textures[v]
end
end
if has_wieldview and textures["shield"] then
texture = texture.."^[combine:64x64:16,0="..textures["shield"]
end
if self.skin[name] then
texture = texture.."^[combine:64x64:0,32="..self.skin[name]
end
if self.armor[name] then
texture = texture.."^[combine:64x64:0,0="..self.armor[name]
end
player:set_properties({
visual = "mesh",
mesh = "uniskins_character.x",
textures = {texture},
visual_size = {x=1, y=1},
})
end
minetest.register_on_joinplayer(function(player)
if not minetest.get_modpath("player_textures") then
return
end
local name = player:get_player_name()
local filename = minetest.get_modpath("player_textures").."/textures/player_"..name
local f = io.open(filename..".png")
if f then
f:close()
uniskins.skins[name] = "player_"..player:get_player_name()..".png"
uniskins.skin[name] = uniskins.default_skin
if minetest.get_modpath("player_textures") then
local filename = minetest.get_modpath("player_textures").."/textures/player_"..name
local f = io.open(filename..".png")
if f then
f:close()
uniskins.skin[name] = "player_"..name..".png"
end
end
if minetest.get_modpath("skins") then
local skin = skins.skins[name]
if skin and skins.get_type(skin) == skins.type.MODEL then
uniskins.skin[name] = skin..".png"
end
end
end)

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 167 B

After

Width:  |  Height:  |  Size: 167 B

View File

@ -6,29 +6,21 @@ if not update_time then
end
wieldview = {
wielded_items = {},
wielded_item = {},
}
wieldview.get_wielded_item_texture = function(self, player)
if not player then
return nil
end
local stack = player:get_wielded_item()
local item = stack:get_name()
if not item then
return nil
end
if not minetest.registered_items[item] then
return nil
end
local texture = minetest.registered_items[item].inventory_image
if texture == "" then
if not minetest.registered_items[item].tiles then
return nil
wieldview.get_item_texture = function(self, item)
if item ~= "" then
if minetest.registered_items[item] then
if minetest.registered_items[item].inventory_image ~= "" then
return minetest.registered_items[item].inventory_image
end
if minetest.registered_items[item].tiles then
return minetest.registered_items[item].tiles[1]
end
end
texture = minetest.registered_items[item].tiles[1]
end
return texture
return uniskins.default_texture
end
wieldview.update_wielded_item = function(self, player)
@ -41,25 +33,21 @@ wieldview.update_wielded_item = function(self, player)
if not item then
return
end
if self.wielded_items[name] then
if self.wielded_items[name] == item then
if self.wielded_item[name] then
if self.wielded_item[name] == item then
return
end
uniskins.wielditem[name] = self:get_item_texture(item)
uniskins:update_player_visuals(player)
end
self.wielded_items[name] = item
self.wielded_item[name] = item
end
minetest.register_on_joinplayer(function(player)
local texture = uniskins:get_player_skin(name)
player:set_properties({
visual = "mesh",
mesh = "wieldview_character.x",
textures = {texture},
visual_size = {x=1, y=1},
})
local name = player:get_player_name()
wieldview.wielded_item[name] = ""
minetest.after(0, function(player)
uniskins:update_player_visuals(player)
wieldview:update_wielded_item(player)
end, player)
end)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB