Various fixes: ... (#7)
Some checks failed
luacheck / build (push) Has been cancelled

* `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`.
This commit is contained in:
1F616EMO~nya 2024-04-29 00:44:05 +08:00 committed by GitHub
parent 7bdc2fa907
commit 2482e08065
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 12 deletions

16
api.lua
View File

@ -1,5 +1,5 @@
local S = emote.S 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 local vector_rotate_xz = emote.util.vector_rotate_xz
emote.emotes = {} emote.emotes = {}
@ -13,16 +13,16 @@ function emote.register_emote(name, def)
emote.emotes[name] = def emote.emotes[name] = def
minetest.register_chatcommand(name, { 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) func = function(playername)
local player = minetest.get_player_by_name(playername) local player = minetest.get_player_by_name(playername)
if emote.start(player, name) then if emote.start(player, name) then
if not emote.settings.announce_in_chat then if not emote.settings.announce_in_chat then
return true, S(("you %s"):format(name)) return true, S("You @1", name)
end end
else else
if not emote.settings.announce_in_chat then 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 end
end, end,
@ -105,13 +105,13 @@ function emote.attach_to_node(player, pos, locked)
local rotation = look_horizontal + emotedef.look_horizontal_offset local rotation = look_horizontal + emotedef.look_horizontal_offset
local new_pos = vector.add(pos, offset) local new_pos = vector.add(pos, offset)
emote.set_animation(player, emotedef.emotestring) emote.start(player, emotedef.emotestring)
if locked then if locked then
local object = minetest.add_entity(new_pos, "emote:attacher") local object = minetest.add_entity(new_pos, "emote:attacher")
if object then if object then
object:get_luaentity():init(player) 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)) 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 end
else else
emote.set_animation(player, emotedef.emotestring) player:set_pos(new_pos)
player:setpos(new_pos)
player:set_eye_offset(emotedef.eye_offset, {x = 0, y = 0, z = 0}) player:set_eye_offset(emotedef.eye_offset, {x = 0, y = 0, z = 0})
end end

View File

@ -34,21 +34,18 @@ emote.register_emote("sit", {
anim_name = "sit", anim_name = "sit",
speed = 30, speed = 30,
description = S("sits"), description = S("sits"),
eye_offset = vector.new(0, -5, 0)
}) })
emote.register_emote("lay", { emote.register_emote("lay", {
anim_name = "lay", anim_name = "lay",
speed = 30, speed = 30,
description = S("lies down"), description = S("lies down"),
eye_offset = vector.new(0, -10, -5)
}) })
emote.register_emote("sleep", { -- alias for lay emote.register_emote("sleep", { -- alias for lay
anim_name = "lay", anim_name = "lay",
speed = 30, speed = 30,
description = S("falls asleep"), description = S("falls asleep"),
eye_offset = vector.new(0, -10, -5)
}) })
model.animations.wave = {x = 192, y = 196, override_local = true} model.animations.wave = {x = 192, y = 196, override_local = true}