Compare commits
5 Commits
fb1e1e39b9
...
bce2e17a43
Author | SHA1 | Date |
---|---|---|
Juraj Vajda | bce2e17a43 | |
Juraj Vajda | 30dc0b6798 | |
Juraj Vajda | 99c3e57f02 | |
Juraj Vajda | ef881cc23d | |
Juraj Vajda | 14123cc34b |
13
README.md
13
README.md
|
@ -79,20 +79,9 @@ http://minetest.net/
|
||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||||
|
|
||||||
Teleport Request
|
Teleport Request
|
||||||
-----------------
|
-----------------
|
||||||
This mod is released under WTFPL.
|
This mod is released under WTFPL.
|
||||||
It adds ability to teleport to other players with their permission by using the /tpr command which requires "interact" privilege and the /tphr command which requires the "interact " privilege.
|
It adds ability to teleport to other players with their permission by using the /tpr command which requires "interact" privilege and the /tphr command which requires the "interact " privilege.
|
||||||
|
|
||||||
|
|
||||||
playeranim
|
|
||||||
-----------
|
|
||||||
Makes the head, and the right arm when you’re mining, face the way you’re facing, similar to Minecraft. Compatible with 3d_armor. Forked from the animplus mod, which was an ugly hack.
|
|
||||||
|
|
||||||
The head only turns up and down relative to the body, except it turns slightly to the right/left when you strafe right/left. When you turn the body turns with the head.
|
|
||||||
|
|
||||||
Works in multiplayer, I tested it on a local server.
|
|
||||||
|
|
||||||
Created by Rui914, this document was written by sloantothebone.
|
|
||||||
|
|
41
init.lua
41
init.lua
|
@ -1,9 +1,11 @@
|
||||||
-- main settings
|
-- main settings
|
||||||
dofile(minetest.get_modpath("enhancements").."/settings.txt")
|
dofile(minetest.get_modpath("enhancements").."/settings.txt")
|
||||||
|
|
||||||
--
|
defaultx = {}
|
||||||
|
|
||||||
|
--
|
||||||
-- tools enhancements
|
-- tools enhancements
|
||||||
--
|
--
|
||||||
if TOOLS_ENHANCE then
|
if TOOLS_ENHANCE then
|
||||||
dofile(minetest.get_modpath("enhancements").."/swords.lua")
|
dofile(minetest.get_modpath("enhancements").."/swords.lua")
|
||||||
dofile(minetest.get_modpath("enhancements").."/axe.lua")
|
dofile(minetest.get_modpath("enhancements").."/axe.lua")
|
||||||
|
@ -13,71 +15,62 @@ if TOOLS_ENHANCE then
|
||||||
print("[Mod][enhancements] TOOLS_ENHANCE enabled")
|
print("[Mod][enhancements] TOOLS_ENHANCE enabled")
|
||||||
end
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
-- clean-up unknown nodes and entities (configuration in that file)
|
-- clean-up unknown nodes and entities (configuration in that file)
|
||||||
--
|
--
|
||||||
if CLEAN_UNKNOWN then
|
if CLEAN_UNKNOWN then
|
||||||
dofile(minetest.get_modpath("enhancements").."/clean_unknown.lua")
|
dofile(minetest.get_modpath("enhancements").."/clean_unknown.lua")
|
||||||
|
|
||||||
print("[Mod][enhancements] CLEAN_UNKNOWN enabled")
|
print("[Mod][enhancements] CLEAN_UNKNOWN enabled")
|
||||||
end
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
-- allow external command from outside of minetest (see readme)
|
-- allow external command from outside of minetest (see readme)
|
||||||
--
|
--
|
||||||
if EXTERNAL_CMD then
|
if EXTERNAL_CMD then
|
||||||
dofile(minetest.get_modpath("enhancements").."/external_cmd.lua")
|
dofile(minetest.get_modpath("enhancements").."/external_cmd.lua")
|
||||||
|
|
||||||
print("[Mod][enhancements] EXTERNAL_CMD enabled")
|
print("[Mod][enhancements] EXTERNAL_CMD enabled")
|
||||||
end
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
-- detect AFK players
|
-- detect AFK players
|
||||||
--
|
--
|
||||||
if PLAYER_AFK then
|
if PLAYER_AFK then
|
||||||
dofile(minetest.get_modpath("enhancements").."/afk.lua")
|
dofile(minetest.get_modpath("enhancements").."/afk.lua")
|
||||||
|
|
||||||
print("[Mod][enhancements] PLAYER_AFK enabled")
|
print("[Mod][enhancements] PLAYER_AFK enabled")
|
||||||
end
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
-- go to and set SPAWN_POINT
|
-- go to and set SPAWN_POINT
|
||||||
--
|
--
|
||||||
if SPAWN_POINT then
|
if SPAWN_POINT then
|
||||||
dofile(minetest.get_modpath("enhancements").."/spawn.lua")
|
dofile(minetest.get_modpath("enhancements").."/spawn.lua")
|
||||||
|
|
||||||
print("[Mod][enhancements] SPAWN_POINT enabled")
|
print("[Mod][enhancements] SPAWN_POINT enabled")
|
||||||
end
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
-- pick dropped items by holding shift (sneak)
|
-- pick dropped items by holding shift (sneak)
|
||||||
--
|
--
|
||||||
if ITEM_DROP then
|
if ITEM_DROP then
|
||||||
dofile(minetest.get_modpath("enhancements").."/item_drop.lua")
|
dofile(minetest.get_modpath("enhancements").."/item_drop.lua")
|
||||||
|
|
||||||
print("[Mod][enhancements] ITEM_DROP enabled")
|
print("[Mod][enhancements] ITEM_DROP enabled")
|
||||||
end
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
-- teleport request to/from another player
|
-- teleport request to/from another player
|
||||||
--
|
--
|
||||||
if TP_REQUEST then
|
if TP_REQUEST then
|
||||||
dofile(minetest.get_modpath("enhancements").."/teleport_request.lua")
|
dofile(minetest.get_modpath("enhancements").."/teleport_request.lua")
|
||||||
|
|
||||||
print("[Mod][enhancements] TP_REQUEST enabled")
|
print("[Mod][enhancements] TP_REQUEST enabled")
|
||||||
end
|
end
|
||||||
|
|
||||||
--
|
|
||||||
-- move player head up/down
|
|
||||||
--
|
|
||||||
if PLAYER_ANIM then
|
|
||||||
dofile(minetest.get_modpath("enhancements").."/playeranim.lua")
|
|
||||||
|
|
||||||
print("[Mod][enhancements] PLAYER_ANIM enabled")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- manage privileges i areas mod - if using areas mod only for admin purposes
|
-- manage privileges i areas mod - if using areas mod only for admin purposes
|
||||||
-- WIP DON'T ENABLE!
|
-- WIP DON'T ENABLE!
|
||||||
if AREAS_ENHANCE and minetest.get_modpath("areas") then
|
if AREAS_ENHANCE and minetest.get_modpath("areas") then
|
||||||
dofile(minetest.get_modpath("enhancements").."/areas.lua")
|
dofile(minetest.get_modpath("enhancements").."/areas.lua")
|
||||||
|
|
||||||
|
|
|
@ -4,27 +4,67 @@ item_drop_settings.radius_magnet = 2.5 --radius of item magnet
|
||||||
item_drop_settings.radius_collect = 0.4 --radius of collection
|
item_drop_settings.radius_collect = 0.4 --radius of collection
|
||||||
item_drop_settings.player_collect_height = 1.5 --added to their pos y value
|
item_drop_settings.player_collect_height = 1.5 --added to their pos y value
|
||||||
local delay = 0
|
local delay = 0
|
||||||
|
local timer = 0
|
||||||
|
|
||||||
|
local sneak = {}
|
||||||
|
|
||||||
|
minetest.register_on_joinplayer(function(player)
|
||||||
|
local player_name = player:get_player_name()
|
||||||
|
sneak[player_name] = false
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_leaveplayer(function(player)
|
||||||
|
local player_name = player:get_player_name()
|
||||||
|
sneak[player_name] = nil
|
||||||
|
end)
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
for _,player in ipairs(minetest.get_connected_players()) do
|
timer = timer + dtime
|
||||||
if player:get_player_control().sneak and (player:get_hp() > 0 or not minetest.settings:get_bool("enable_damage")) then
|
|
||||||
|
-- every 1 second
|
||||||
|
if timer >= 1 then
|
||||||
|
for _, player in ipairs(minetest.get_connected_players()) do
|
||||||
|
local control = player:get_player_control()
|
||||||
|
local player_hp = player:get_hp()
|
||||||
|
local player_name = player:get_player_name()
|
||||||
|
|
||||||
|
if control.sneak and (player_hp > 0 or not minetest.settings:get_bool("enable_damage")) then
|
||||||
|
|
||||||
|
-- [Shift + E + Q] single drop item
|
||||||
|
-- autopickup after delay
|
||||||
|
if control.aux1 then
|
||||||
|
delay = 3
|
||||||
|
end
|
||||||
|
|
||||||
|
if delay > 0 then
|
||||||
|
minetest.after(delay, function()
|
||||||
|
delay = 0
|
||||||
|
end)
|
||||||
|
return
|
||||||
|
else
|
||||||
|
pick_dropped_items(player)
|
||||||
|
end
|
||||||
|
|
||||||
-- [Shift + E + Q] single drop item
|
|
||||||
-- autopickup after delay
|
|
||||||
if player:get_player_control().aux1 then
|
|
||||||
delay = 2
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if delay > 0 then
|
-- hide nametag when sneaking
|
||||||
minetest.after(delay, function()
|
if control.sneak ~= sneak[player_name] then
|
||||||
delay = 0
|
if control.sneak and player_hp > 0 then
|
||||||
end)
|
local nametag_tbl = player:get_nametag_attributes()
|
||||||
return
|
nametag_tbl.color.a = 0
|
||||||
else
|
player:set_nametag_attributes(nametag_tbl)
|
||||||
pick_dropped_items(player)
|
player:set_properties{makes_footstep_sound = false}
|
||||||
|
else
|
||||||
|
local nametag_tbl = player:get_nametag_attributes()
|
||||||
|
nametag_tbl.color.a = 255
|
||||||
|
player:set_nametag_attributes(nametag_tbl)
|
||||||
|
player:set_properties{makes_footstep_sound = true}
|
||||||
|
end
|
||||||
|
sneak[player_name] = control.sneak
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
timer = 0
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -49,16 +89,16 @@ function pick_dropped_items(player)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--magnet
|
--magnet
|
||||||
for _,object in ipairs(minetest.get_objects_inside_radius({x=pos.x,y=pos.y + item_drop_settings.player_collect_height,z=pos.z}, item_drop_settings.radius_magnet)) do
|
for _,object in ipairs(minetest.get_objects_inside_radius({x=pos.x,y=pos.y + item_drop_settings.player_collect_height,z=pos.z}, item_drop_settings.radius_magnet)) do
|
||||||
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
|
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
|
||||||
|
|
||||||
object:get_luaentity().collect = true
|
object:get_luaentity().collect = true
|
||||||
|
|
||||||
if object:get_luaentity().collect then
|
if object:get_luaentity().collect then
|
||||||
if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
|
if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
|
||||||
|
|
||||||
local pos1 = pos
|
local pos1 = pos
|
||||||
pos1.y = pos1.y+0.2
|
pos1.y = pos1.y+0.2
|
||||||
local pos2 = object:getpos()
|
local pos2 = object:getpos()
|
||||||
|
@ -68,12 +108,12 @@ function pick_dropped_items(player)
|
||||||
vec.y = pos2.y + vec.y
|
vec.y = pos2.y + vec.y
|
||||||
vec.z = pos2.z + vec.z
|
vec.z = pos2.z + vec.z
|
||||||
object:moveto(vec)
|
object:moveto(vec)
|
||||||
|
|
||||||
object:get_luaentity().physical_state = false
|
object:get_luaentity().physical_state = false
|
||||||
object:get_luaentity().object:set_properties({
|
object:get_luaentity().object:set_properties({
|
||||||
physical = false
|
physical = false
|
||||||
})
|
})
|
||||||
|
|
||||||
object:setacceleration({x=0, y=0, z=0})
|
object:setacceleration({x=0, y=0, z=0})
|
||||||
object:setvelocity({x=0, y=0, z=0})
|
object:setvelocity({x=0, y=0, z=0})
|
||||||
|
|
||||||
|
@ -107,7 +147,7 @@ function pick_dropped_items(player)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end, {player, object})
|
end, {player, object})
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
262
playeranim.lua
262
playeranim.lua
|
@ -1,262 +0,0 @@
|
||||||
local model = minetest.get_modpath("3d_armor") and "armor" or "normal"
|
|
||||||
|
|
||||||
-- Localize functions to avoid table lookups (better performance)
|
|
||||||
local vector_new = vector.new
|
|
||||||
local vector_add = vector.add
|
|
||||||
local vector_equals = vector.equals
|
|
||||||
local math_sin = math.sin
|
|
||||||
local math_deg = math.deg
|
|
||||||
local get_animation = default.player_get_animation
|
|
||||||
local get_connected_players = minetest.get_connected_players
|
|
||||||
|
|
||||||
-- Animation alias
|
|
||||||
local STAND = 1
|
|
||||||
local WALK = 2
|
|
||||||
local MINE = 3
|
|
||||||
local WALK_MINE = 4
|
|
||||||
local SIT = 5
|
|
||||||
local LAY = 6
|
|
||||||
local SNEAK = 7
|
|
||||||
local RESET_BODY = 8
|
|
||||||
|
|
||||||
-- Bone alias
|
|
||||||
local BODY = "Body"
|
|
||||||
local HEAD = "Head"
|
|
||||||
local CAPE = "Cape"
|
|
||||||
local LARM = "Arm_Left"
|
|
||||||
local RARM = "Arm_Right"
|
|
||||||
local LLEG = "Leg_Left"
|
|
||||||
local RLEG = "Leg_Right"
|
|
||||||
|
|
||||||
local bone_position = {
|
|
||||||
normal = {
|
|
||||||
[BODY] = vector_new(0, -3.5, 0),
|
|
||||||
[HEAD] = vector_new(0, 6, 0),
|
|
||||||
[CAPE] = vector_new(0, 6.5, 1.5),
|
|
||||||
[LARM] = vector_new(-3.9, 6.5, 0),
|
|
||||||
[RARM] = vector_new(3.9, 6.5, 0),
|
|
||||||
[LLEG] = vector_new(-1, 0, 0),
|
|
||||||
[RLEG] = vector_new(1, 0, 0)
|
|
||||||
},
|
|
||||||
armor = {
|
|
||||||
[BODY] = vector_new(0, -3.5, 0),
|
|
||||||
[HEAD] = vector_new(0, 6.75, 0),
|
|
||||||
[CAPE] = vector_new(0, 6.75, 1.5),
|
|
||||||
[LARM] = vector_new(2, 6.5, 0),
|
|
||||||
[RARM] = vector_new(-2, 6.5, 0),
|
|
||||||
[LLEG] = vector_new(1, 0, 0),
|
|
||||||
[RLEG] = vector_new(-1, 0, 0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
local bone_rotation = {
|
|
||||||
normal = {
|
|
||||||
[BODY] = vector_new(0, 0, 0),
|
|
||||||
[HEAD] = vector_new(0, 0, 0),
|
|
||||||
[CAPE] = vector_new(0, 0, 180),
|
|
||||||
[LARM] = vector_new(180, 0, 0),
|
|
||||||
[RARM] = vector_new(180, 0, 0),
|
|
||||||
[LLEG] = vector_new(0, 0, 0),
|
|
||||||
[RLEG] = vector_new(0, 0, 0)
|
|
||||||
},
|
|
||||||
armor = {
|
|
||||||
[BODY] = vector_new(0, 0, 0),
|
|
||||||
[HEAD] = vector_new(0, 0, 0),
|
|
||||||
[CAPE] = vector_new(180, 0, 180),
|
|
||||||
[LARM] = vector_new(180, 0, 9),
|
|
||||||
[RARM] = vector_new(180, 0, -9),
|
|
||||||
[LLEG] = vector_new(0, 0, 0),
|
|
||||||
[RLEG] = vector_new(0, 0, 0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
local function rotate(player, bone, x, y, z)
|
|
||||||
local rotation = vector_add(vector_new(x or 0, y or 0, z or 0), bone_rotation[model][bone])
|
|
||||||
player:set_bone_position(bone, bone_position[model][bone], rotation)
|
|
||||||
end
|
|
||||||
|
|
||||||
local step = 0
|
|
||||||
local animation_speed = {}
|
|
||||||
local look_pitch = {}
|
|
||||||
|
|
||||||
local animations = {
|
|
||||||
[STAND] = function(player)
|
|
||||||
rotate(player, BODY)
|
|
||||||
rotate(player, CAPE)
|
|
||||||
rotate(player, LARM)
|
|
||||||
rotate(player, RARM)
|
|
||||||
rotate(player, LLEG)
|
|
||||||
rotate(player, RLEG)
|
|
||||||
end,
|
|
||||||
[WALK] = function(player)
|
|
||||||
local name = player:get_player_name()
|
|
||||||
local swing = math_sin(step * 4 * animation_speed[name])
|
|
||||||
rotate(player, CAPE, swing * 30 + 35)
|
|
||||||
rotate(player, LARM, swing * -40)
|
|
||||||
rotate(player, RARM, swing * 40)
|
|
||||||
rotate(player, LLEG, swing * 40)
|
|
||||||
rotate(player, RLEG, swing * -40)
|
|
||||||
end,
|
|
||||||
[MINE] = function(player)
|
|
||||||
local name = player:get_player_name()
|
|
||||||
local pitch = look_pitch[name]
|
|
||||||
local swing = math_sin(step * 4 * animation_speed[name])
|
|
||||||
local hand_swing = math_sin(step * 8 * animation_speed[name])
|
|
||||||
rotate(player, CAPE, swing * 5 + 10)
|
|
||||||
rotate(player, LARM)
|
|
||||||
rotate(player, RARM, hand_swing * 20 + 80 + pitch)
|
|
||||||
rotate(player, LLEG)
|
|
||||||
rotate(player, RLEG)
|
|
||||||
end,
|
|
||||||
[WALK_MINE] = function(player)
|
|
||||||
local name = player:get_player_name()
|
|
||||||
local pitch = look_pitch[name]
|
|
||||||
local swing = math_sin(step * 4 * animation_speed[name])
|
|
||||||
local hand_swing = math_sin(step * 8 * animation_speed[name])
|
|
||||||
rotate(player, CAPE, swing * 30 + 35)
|
|
||||||
rotate(player, LARM, swing * -40)
|
|
||||||
rotate(player, RARM, hand_swing * 20 + 80 + pitch)
|
|
||||||
rotate(player, LLEG, swing * 40)
|
|
||||||
rotate(player, RLEG, swing * -40)
|
|
||||||
end,
|
|
||||||
[SIT] = function(player)
|
|
||||||
local body_pos = vector_new(bone_position[model][BODY])
|
|
||||||
body_pos.y = body_pos.y - 6
|
|
||||||
player:set_bone_position(BODY, body_pos, vector_new(0, 0, 0))
|
|
||||||
rotate(player, LARM)
|
|
||||||
rotate(player, RARM)
|
|
||||||
rotate(player, LLEG, 90)
|
|
||||||
rotate(player, RLEG, 90)
|
|
||||||
end,
|
|
||||||
[LAY] = function(player)
|
|
||||||
player:set_bone_position(BODY, vector_new(0, -9, 0), vector_new(270, 0, 0))
|
|
||||||
rotate(player, HEAD)
|
|
||||||
end,
|
|
||||||
[SNEAK] = function(player)
|
|
||||||
rotate(player, BODY, 5)
|
|
||||||
end,
|
|
||||||
[RESET_BODY] = function(player)
|
|
||||||
rotate(player, BODY)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
|
|
||||||
local function update_look_pitch(player)
|
|
||||||
local name = player:get_player_name()
|
|
||||||
local pitch = math_deg(player:get_look_pitch())
|
|
||||||
|
|
||||||
if look_pitch[name] ~= pitch then
|
|
||||||
look_pitch[name] = pitch
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function set_animation_speed(player, bool_sneak)
|
|
||||||
local name = player:get_player_name()
|
|
||||||
local speed = bool_sneak and 0.75 or 2
|
|
||||||
|
|
||||||
if animation_speed[name] ~= speed then
|
|
||||||
animation_speed[name] = speed
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local current_animation = {}
|
|
||||||
|
|
||||||
local function set_animation(player, anim)
|
|
||||||
local name = player:get_player_name()
|
|
||||||
|
|
||||||
if anim == LAY or anim == SNEAK or anim == RESET_BODY then
|
|
||||||
if current_animation[name][1] ~= anim then
|
|
||||||
current_animation[name][1] = anim
|
|
||||||
animations[anim](player)
|
|
||||||
end
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if anim == WALK or anim == MINE or anim == WALK_MINE then
|
|
||||||
current_animation[name][2] = anim
|
|
||||||
animations[anim](player)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if current_animation[name][2] ~= anim then
|
|
||||||
current_animation[name][2] = anim
|
|
||||||
animations[anim](player)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local current_head = {}
|
|
||||||
|
|
||||||
local function head_rotate(player, controls)
|
|
||||||
local name = player:get_player_name()
|
|
||||||
|
|
||||||
local pitch = look_pitch[name]
|
|
||||||
local look = vector_new(pitch, 0, 0)
|
|
||||||
if controls.left ~= controls.right then
|
|
||||||
look.y = controls.right and 10 or -10
|
|
||||||
end
|
|
||||||
|
|
||||||
local old_pitch, old_look = current_head[name][1], current_head[name][2]
|
|
||||||
if old_pitch ~= pitch or (not old_look or not vector_equals(old_look, look)) then
|
|
||||||
current_head[name] = {pitch, look}
|
|
||||||
rotate(player, HEAD, look.x, look.y, look.z)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function set_sneak_animation(player, bool_sneak)
|
|
||||||
set_animation(player, bool_sneak and SNEAK or RESET_BODY)
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
|
||||||
local name = player:get_player_name()
|
|
||||||
current_head[name] = {}
|
|
||||||
current_animation[name] = {}
|
|
||||||
end)
|
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player)
|
|
||||||
local name = player:get_player_name()
|
|
||||||
animation_speed[name] = nil
|
|
||||||
look_pitch[name] = nil
|
|
||||||
current_head[name] = nil
|
|
||||||
current_animation[name] = nil
|
|
||||||
end)
|
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
|
||||||
step = step + dtime
|
|
||||||
if step >= 3600 then
|
|
||||||
step = 1
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, player in ipairs(get_connected_players()) do
|
|
||||||
local animation = get_animation(player).animation
|
|
||||||
|
|
||||||
if animation == "lay" then -- No head rotate
|
|
||||||
set_animation(player, STAND) -- Reset
|
|
||||||
set_animation(player, LAY)
|
|
||||||
else
|
|
||||||
local controls = player:get_player_control()
|
|
||||||
local bool_sneak = controls.sneak
|
|
||||||
|
|
||||||
update_look_pitch(player)
|
|
||||||
|
|
||||||
if animation == "walk" then
|
|
||||||
set_animation_speed(player, bool_sneak)
|
|
||||||
set_animation(player, WALK)
|
|
||||||
set_sneak_animation(player, bool_sneak)
|
|
||||||
elseif animation == "mine" then
|
|
||||||
set_animation_speed(player, bool_sneak)
|
|
||||||
set_animation(player, MINE)
|
|
||||||
set_sneak_animation(player, bool_sneak)
|
|
||||||
elseif animation == "walk_mine" then
|
|
||||||
set_animation_speed(player, bool_sneak)
|
|
||||||
set_animation(player, WALK_MINE)
|
|
||||||
set_sneak_animation(player, bool_sneak)
|
|
||||||
elseif animation == "sit" then
|
|
||||||
set_animation(player, SIT)
|
|
||||||
else
|
|
||||||
set_animation(player, STAND)
|
|
||||||
set_sneak_animation(player, bool_sneak)
|
|
||||||
end
|
|
||||||
|
|
||||||
head_rotate(player, controls)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
|
@ -13,7 +13,10 @@ minetest.register_chatcommand("spawn", {
|
||||||
return false, "Player not found"
|
return false, "Player not found"
|
||||||
end
|
end
|
||||||
if spawn_spawnpos then
|
if spawn_spawnpos then
|
||||||
player:setpos(spawn_spawnpos)
|
if vector.distance(player:get_pos(), spawn_spawnpos) < 48 then
|
||||||
|
return false, "You are already near the spawn, teleporting aborted."
|
||||||
|
end
|
||||||
|
player:set_pos(spawn_spawnpos)
|
||||||
return true, "Teleporting to spawn..."
|
return true, "Teleporting to spawn..."
|
||||||
else
|
else
|
||||||
return false, "The spawn point is not set!"
|
return false, "The spawn point is not set!"
|
||||||
|
@ -24,13 +27,13 @@ minetest.register_chatcommand("spawn", {
|
||||||
minetest.register_chatcommand("setspawn", {
|
minetest.register_chatcommand("setspawn", {
|
||||||
params = "",
|
params = "",
|
||||||
description = "Sets the spawn point to your current position",
|
description = "Sets the spawn point to your current position",
|
||||||
privs = { server=true },
|
privs = {server = true},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = minetest.get_player_by_name(name)
|
||||||
if not player then
|
if not player then
|
||||||
return false, "Player not found"
|
return false, "Player not found"
|
||||||
end
|
end
|
||||||
local pos = player:getpos()
|
local pos = player:get_pos()
|
||||||
local x = pos.x
|
local x = pos.x
|
||||||
local y = pos.y
|
local y = pos.y
|
||||||
local z = pos.z
|
local z = pos.z
|
||||||
|
|
Loading…
Reference in New Issue