player_skin: Appearance, the initial version

This commit is contained in:
MoNTE48 2020-01-21 19:59:35 +01:00
parent 6004f23be9
commit 659902d86b
5 changed files with 89 additions and 47 deletions

View File

@ -80,6 +80,21 @@ function player_api.set_animation(player, anim_name, speed)
player:set_animation(anim, speed or model.animation_speed, animation_blend)
end
function player_api.character(player)
local character = "player_api:character"
if player:get_attribute("gender") == "female" then
character = character .. "_female"
end
local skin = player:get_attribute("skin")
if skin then
character = character .. "_" .. skin
end
return character
end
minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name()
player_model[name] = nil

View File

@ -0,0 +1 @@
3d_armor?

View File

@ -19,60 +19,64 @@ player_api.register_model("character.b3d", {
eye_height = 1.47
})
-- Hand definition
local hand = {
wield_scale = {x = 1, y = 1, z = 0.7},
paramtype = "light",
drawtype = "mesh",
mesh = "hand.b3d",
inventory_image = "blank.png",
drop = "",
node_placement_prediction = ""
}
if creative_mode_cache then
local digtime = 128
local caps = {times = {digtime, digtime, digtime}, uses = 0, maxlevel = 192}
minetest.register_node("player_api:hand", {
tiles = {"character.png"},
wield_scale = {x = 1, y = 1, z = 0.7},
paramtype = "light",
drawtype = "mesh",
mesh = "hand.b3d",
inventory_image = "blank.png",
drop = "",
node_placement_prediction = "",
range = 10,
tool_capabilities = {
full_punch_interval = 0.5,
max_drop_level = 3,
groupcaps = {
crumbly = caps,
cracky = caps,
snappy = caps,
choppy = caps,
oddly_breakable_by_hand = caps
},
damage_groups = {fleshy = 5}
}
})
hand.range = 10
hand.tool_capabilities = {
full_punch_interval = 0.5,
max_drop_level = 3,
groupcaps = {
crumbly = caps,
cracky = caps,
snappy = caps,
choppy = caps,
oddly_breakable_by_hand = caps
},
damage_groups = {fleshy = 5}
}
else
minetest.register_node("player_api:hand", {
tiles = {"character.png"},
wield_scale = {x = 1, y = 1, z = 0.7},
paramtype = "light",
drawtype = "mesh",
mesh = "hand.b3d",
inventory_image = "blank.png",
drop = "",
node_placement_prediction = "",
tool_capabilities = {
full_punch_interval = 0.5,
max_drop_level = 0,
groupcaps = {
crumbly = {times = {[1]=5.0, [2]=3.0, [3]=0.7}, uses = 0, maxlevel = 1},
snappy = {times = {[1]=0.5, [2]=0.5, [3]=0.5}, uses = 0, maxlevel = 1},
choppy = {times = {[1]=6.0, [2]=4.0, [3]=3.0}, uses = 0, maxlevel = 1},
cracky = {times = {[1]=7.0, [2]=5.0, [3]=4.0}, uses = 0, maxlevel = 1},
oddly_breakable_by_hand = {times = {[1]=3.5, [2]=2.0, [3]=0.7}, uses = 0}
},
damage_groups = {fleshy = 1}
}
})
hand.tool_capabilities = {
full_punch_interval = 0.5,
max_drop_level = 0,
groupcaps = {
crumbly = {times = {[1]=5.0, [2]=3.0, [3]=0.7}, uses = 0, maxlevel = 1},
snappy = {times = {[1]=0.5, [2]=0.5, [3]=0.5}, uses = 0, maxlevel = 1},
choppy = {times = {[1]=6.0, [2]=4.0, [3]=3.0}, uses = 0, maxlevel = 1},
cracky = {times = {[1]=7.0, [2]=5.0, [3]=4.0}, uses = 0, maxlevel = 1},
oddly_breakable_by_hand = {times = {[1]=3.5, [2]=2.0, [3]=0.7}, uses = 0}
},
damage_groups = {fleshy = 1}
}
end
local hand_male, hand_female = table.copy(hand), table.copy(hand)
hand_male.tiles = {"character.png"}
hand_female.tiles = {"character_female.png"}
minetest.register_node("player_api:hand", hand_male)
minetest.register_node("player_api:hand_female", hand_female)
-- Update appearance when the player joins
minetest.register_on_joinplayer(function(player)
player_api.player_attached[player:get_player_name()] = false
local name = player:get_player_name()
local gender = player:get_attribute("gender")
player_api.player_attached[name] = false
player_api.set_model(player, "character.b3d")
player:set_local_animation(
{x = 0, y = 0}, -- y = 79
@ -85,7 +89,22 @@ minetest.register_on_joinplayer(function(player)
player:hud_set_hotbar_image("gui_hotbar.png")
player:hud_set_hotbar_selected_image("gui_hotbar_selected.png")
player:get_inventory():set_stack("hand", 1, "player_api:hand")
if gender == "female" then
-- ToDo: do not call 3d_armor here
if minetest.get_modpath("3d_armor") then
minetest.after(0, function()
armor.textures[name].skin = "character" .. (gender == "female" and "_female" or "") .. ".png"
armor:set_player_armor(player)
end)
else
player_api.set_textures(player, {
"character" .. (gender == "female" and "_female" or "") .. ".png", "blank.png", "blank.png", "blank.png"
})
end
player:get_inventory():set_stack("hand", 1, "player_api:hand_female")
else
player:get_inventory():set_stack("hand", 1, "player_api:hand")
end
end)
minetest.register_node("player_api:character", {
@ -95,6 +114,13 @@ minetest.register_node("player_api:character", {
groups = {not_in_creative_inventory = 1}
})
minetest.register_node("player_api:character_female", {
drawtype = "mesh",
mesh = "character_preview.b3d",
tiles = {"character_female.png"},
groups = {not_in_creative_inventory = 1}
})
-- Temporary solution to the problem of loading yaw 'nul' on iOS
if PLATFORM == "iOS" then
minetest.register_on_joinplayer(function(player)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 999 B

After

Width:  |  Height:  |  Size: 998 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 998 B