player_api: minor update
This commit is contained in:
parent
294bd09695
commit
1c9023b176
@ -8,7 +8,7 @@ Also sets the default model, texture, and player flags.
|
||||
Authors of source code
|
||||
----------------------
|
||||
Originally by celeron55, Perttu Ahola <celeron55@gmail.com> (LGPLv3.0+)
|
||||
Various Minetest developers and contributors (LGPLv3.0+),
|
||||
Various Minetest developers and contributors (LGPLv3.0+)
|
||||
stujones11, Stuart Jones (LGPLv3.0+, with the permission of the author)
|
||||
MultiCraft Development Team (LGPLv3.0+)
|
||||
|
||||
|
@ -157,14 +157,8 @@ minetest.register_playerstep(function(_, playernames)
|
||||
local model = model_name and models[model_name]
|
||||
if model and not player_attached[name] then
|
||||
local controls = player:get_player_control()
|
||||
local walking = false
|
||||
local animation_speed_mod = model.animation_speed or 30
|
||||
|
||||
-- Determine if the player is walking
|
||||
if controls.up or controls.down or controls.left or controls.right then
|
||||
walking = true
|
||||
end
|
||||
|
||||
-- Determine if the player is sneaking, and reduce animation speed if so
|
||||
if controls.sneak then
|
||||
animation_speed_mod = animation_speed_mod / 2
|
||||
@ -173,7 +167,8 @@ minetest.register_playerstep(function(_, playernames)
|
||||
-- Apply animations based on what the player is doing
|
||||
if player:get_hp() == 0 then
|
||||
player_set_animation(player, "lay")
|
||||
elseif walking then
|
||||
-- Determine if the player is walking
|
||||
elseif controls.up or controls.down or controls.left or controls.right then
|
||||
if player_sneak[name] ~= controls.sneak then
|
||||
player_anim[name] = nil
|
||||
player_sneak[name] = controls.sneak
|
||||
|
@ -119,7 +119,7 @@ end
|
||||
|
||||
-- Items for the new player
|
||||
if not creative_mode_cache and minetest.is_singleplayer() then
|
||||
minetest.register_on_newplayer(function (player)
|
||||
minetest.register_on_newplayer(function(player)
|
||||
player:get_inventory():add_item("main", "default:sword_steel")
|
||||
player:get_inventory():add_item("main", "default:torch 8")
|
||||
player:get_inventory():add_item("main", "default:wood 32")
|
||||
@ -142,6 +142,11 @@ minetest.register_on_dieplayer(function(player)
|
||||
inv:set_list("main", {})
|
||||
|
||||
-- Display death coordinates
|
||||
minetest.chat_send_player(player:get_player_name(), Sl("Your last coordinates:") .. " "
|
||||
.. minetest.pos_to_string(pos, 1))
|
||||
local name = player:get_player_name()
|
||||
local pos_string = minetest.pos_to_string(pos, 1)
|
||||
|
||||
minetest.chat_send_player(name, Sl("Your last coordinates:") .. " "
|
||||
.. pos_string)
|
||||
|
||||
minetest.log("action", name .. " died at " .. pos_string)
|
||||
end)
|
||||
|
Loading…
x
Reference in New Issue
Block a user