2022-04-28 15:46:06 +02:00
|
|
|
local S = minetest.get_translator(minetest.get_current_modname())
|
2022-05-02 05:31:58 +02:00
|
|
|
local mcl_cozy_print_actions = minetest.settings:get_bool("mcl_cozy_print_actions") ~= false
|
2022-04-28 15:46:06 +02:00
|
|
|
|
2022-05-11 14:31:18 +02:00
|
|
|
-- functions
|
|
|
|
local function print_action_sit(name)
|
|
|
|
if mcl_cozy_print_actions then
|
|
|
|
minetest.chat_send_all("* "..name..S(" sits"))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
local function print_action_lay(name)
|
|
|
|
if mcl_cozy_print_actions then
|
|
|
|
minetest.chat_send_all("* "..name..S(" lies"))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
local function print_action_stand(name)
|
|
|
|
if mcl_cozy_print_actions then
|
|
|
|
minetest.chat_send_all("* "..name..S(" stands up"))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- to support both Mineclonia and MineClone 2/5
|
|
|
|
local function actionbar_show_status(player)
|
|
|
|
if minetest.get_modpath("mcl_title") then
|
|
|
|
mcl_title.set(player, "actionbar", {text=S("Move to stand up"), color="white", stay=60})
|
|
|
|
elseif minetest.get_modpath("mcl_tmp_message") then
|
|
|
|
mcl_tmp_message.message(player, S("Move to stand up"))
|
|
|
|
else
|
|
|
|
minetest.log("warning", "Didn't found any mod to set titles in actionbar (mcl_title or mcl_tmp_message)!")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-02-24 01:24:56 +01:00
|
|
|
minetest.register_globalstep(function(dtime)
|
|
|
|
local players = minetest.get_connected_players()
|
|
|
|
for i=1, #players do
|
|
|
|
local name = players[i]:get_player_name()
|
|
|
|
if mcl_player.player_attached[name] and not players[i]:get_attach() and
|
|
|
|
(players[i]:get_player_control().up == true or
|
|
|
|
players[i]:get_player_control().down == true or
|
|
|
|
players[i]:get_player_control().left == true or
|
|
|
|
players[i]:get_player_control().right == true or
|
|
|
|
players[i]:get_player_control().jump == true) then
|
|
|
|
players[i]:set_eye_offset({x=0, y=0, z=0}, {x=0, y=0, z=0})
|
|
|
|
players[i]:set_physics_override(1, 1, 1)
|
|
|
|
mcl_player.player_attached[name] = false
|
|
|
|
mcl_player.player_set_animation(players[i], "stand", 30)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
minetest.register_chatcommand("sit", {
|
2022-04-28 15:46:06 +02:00
|
|
|
description = S("Sit down"),
|
2022-02-24 01:24:56 +01:00
|
|
|
func = function(name)
|
|
|
|
local player = minetest.get_player_by_name(name)
|
|
|
|
if mcl_player.player_attached[name] then
|
|
|
|
player:set_eye_offset({x=0, y=0, z=0}, {x=0, y=0, z=0})
|
|
|
|
player:set_physics_override(1, 1, 1)
|
|
|
|
mcl_player.player_attached[name] = false
|
|
|
|
mcl_player.player_set_animation(player, "stand", 30)
|
2022-05-11 14:31:18 +02:00
|
|
|
print_action_stand(name)
|
2022-02-24 01:24:56 +01:00
|
|
|
else
|
|
|
|
player:set_eye_offset({x=0, y=-7, z=2}, {x=0, y=0, z=0})
|
|
|
|
player:set_physics_override(0, 0, 0)
|
|
|
|
mcl_player.player_attached[name] = true
|
|
|
|
mcl_player.player_set_animation(player, "sit", 30)
|
2022-05-11 14:31:18 +02:00
|
|
|
print_action_sit(name)
|
|
|
|
actionbar_show_status(player)
|
2022-02-24 01:24:56 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_chatcommand("lay", {
|
2022-04-28 15:46:06 +02:00
|
|
|
description = S("Lay down"),
|
2022-02-24 01:24:56 +01:00
|
|
|
func = function(name)
|
|
|
|
local player = minetest.get_player_by_name(name)
|
|
|
|
if mcl_player.player_attached[name] then
|
|
|
|
player:set_eye_offset({x=0, y=0, z=0}, {x=0, y=0, z=0})
|
|
|
|
player:set_physics_override(1, 1, 1)
|
|
|
|
mcl_player.player_attached[name] = false
|
|
|
|
mcl_player.player_set_animation(player, "stand", 30)
|
2022-05-11 14:31:18 +02:00
|
|
|
print_action_stand(name)
|
2022-02-24 01:24:56 +01:00
|
|
|
else
|
|
|
|
player:set_eye_offset({x=0, y=-13, z=0}, {x=0, y=0, z=0})
|
|
|
|
player:set_physics_override(0, 0, 0)
|
|
|
|
mcl_player.player_attached[name] = true
|
|
|
|
mcl_player.player_set_animation(player, "lay", 0)
|
2022-05-11 14:31:18 +02:00
|
|
|
print_action_lay(name)
|
|
|
|
actionbar_show_status(player)
|
2022-02-24 01:24:56 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|