From 2482e080653fda458bea7dd6148931c00886d16e Mon Sep 17 00:00:00 2001 From: 1F616EMO~nya Date: Mon, 29 Apr 2024 00:44:05 +0800 Subject: [PATCH] Various fixes: ... (#7) * `eye_offset` is redundant since Minetest Game PR#2745 * Translations are now using `@1` syntax instead of `%s` + `string.format`. * Replaced some deprecated calls. * Fixed reference to `emote.util.facedir_to_look_horizontal`. --- api.lua | 16 +++++++--------- init.lua | 3 --- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/api.lua b/api.lua index 57643a6..6134578 100644 --- a/api.lua +++ b/api.lua @@ -1,5 +1,5 @@ local S = emote.S -local facedir_to_look_horizontal = emote.facedir_to_look_horizontal +local facedir_to_look_horizontal = emote.util.facedir_to_look_horizontal local vector_rotate_xz = emote.util.vector_rotate_xz emote.emotes = {} @@ -13,16 +13,16 @@ function emote.register_emote(name, def) emote.emotes[name] = def minetest.register_chatcommand(name, { - description = S(("Makes your character perform the %s emote"):format(name)), + description = S("Makes your character perform the @1 emote", name), func = function(playername) local player = minetest.get_player_by_name(playername) if emote.start(player, name) then if not emote.settings.announce_in_chat then - return true, S(("you %s"):format(name)) + return true, S("You @1", name) end else if not emote.settings.announce_in_chat then - return false, S(("you fail to %s"):format(name)) + return false, S("You failed to @1", name) end end end, @@ -105,13 +105,13 @@ function emote.attach_to_node(player, pos, locked) local rotation = look_horizontal + emotedef.look_horizontal_offset local new_pos = vector.add(pos, offset) - emote.set_animation(player, emotedef.emotestring) + emote.start(player, emotedef.emotestring) if locked then local object = minetest.add_entity(new_pos, "emote:attacher") if object then object:get_luaentity():init(player) - object:setyaw(rotation) + object:set_yaw(rotation) player:set_attach(object, "", emotedef.eye_offset, minetest.facedir_to_dir(node.param2)) @@ -119,9 +119,7 @@ function emote.attach_to_node(player, pos, locked) end else - emote.set_animation(player, emotedef.emotestring) - - player:setpos(new_pos) + player:set_pos(new_pos) player:set_eye_offset(emotedef.eye_offset, {x = 0, y = 0, z = 0}) end diff --git a/init.lua b/init.lua index 4a798dc..05edbd6 100644 --- a/init.lua +++ b/init.lua @@ -34,21 +34,18 @@ emote.register_emote("sit", { anim_name = "sit", speed = 30, description = S("sits"), - eye_offset = vector.new(0, -5, 0) }) emote.register_emote("lay", { anim_name = "lay", speed = 30, description = S("lies down"), - eye_offset = vector.new(0, -10, -5) }) emote.register_emote("sleep", { -- alias for lay anim_name = "lay", speed = 30, description = S("falls asleep"), - eye_offset = vector.new(0, -10, -5) }) model.animations.wave = {x = 192, y = 196, override_local = true}