From 18d42f2285512b62bf81ca180538e0511bad448b Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Thu, 2 Mar 2017 20:41:45 +0000 Subject: [PATCH] limit mob names to 64 chars, update mount lib to new 0.4.15 functions --- api.lua | 7 ++++++- mount.lua | 14 ++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/api.lua b/api.lua index d8e3624..4403b76 100644 --- a/api.lua +++ b/api.lua @@ -1,5 +1,5 @@ --- Mobs Api (24th February 2017) +-- Mobs Api (2nd March 2017) mobs = {} mobs.mod = "redo" @@ -3383,6 +3383,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) return end + -- limit name entered to 64 characters long + if string.len(fields.name) > 64 then + fields.name = string.sub(fields.name, 1, 64) + end + -- update nametag mob_obj[name].nametag = fields.name diff --git a/mount.lua b/mount.lua index 0b08613..84874ef 100644 --- a/mount.lua +++ b/mount.lua @@ -141,7 +141,8 @@ function mobs.attach(entity, player) default.player_set_animation(player, "sit" , 30) end) - player:set_look_yaw(entity.object:getyaw() - rot_view) + --player:set_look_yaw(entity.object:getyaw() - rot_view) + player:set_look_horizontal(entity.object:getyaw() - rot_view) end @@ -196,10 +197,8 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime) entity.v = entity.v - entity.accel / 10 end - --entity.object:setyaw(entity.driver:get_look_yaw() - rot_steer) --- entity.object:setyaw(entity.driver:get_look_horizontal())-- - rot_steer) - -- fix mob rotation +-- entity.object:setyaw(entity.driver:get_look_yaw() - entity.rotate) entity.object:setyaw(entity.driver:get_look_horizontal() - entity.rotate) if can_fly then @@ -376,7 +375,8 @@ function mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim) local ctrl = entity.driver:get_player_control() local velo = entity.object:getvelocity() local dir = entity.driver:get_look_dir() - local yaw = entity.driver:get_look_yaw() +-- local yaw = entity.driver:get_look_yaw() + local yaw = entity.driver:get_look_horizontal() + 1.57 -- offset fix between old and new commands local rot_steer, rot_view = math.pi / 2, 0 if entity.player_rotation.y == 90 then @@ -415,8 +415,10 @@ function mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim) local ent = obj:get_luaentity() if ent then ent.switch = 1 -- for mob specific arrows + ent.owner_id = tostring(entity.object) -- so arrows dont hurt entity you are riding local vec = {x = dir.x * 6, y = dir.y * 6, z = dir.z * 6} - local yaw = entity.driver:get_look_yaw() +-- local yaw = entity.driver:get_look_yaw() + local yaw = entity.driver:get_look_horizontal() obj:setyaw(yaw + math.pi / 2) obj:setvelocity(vec) else