emote-cd2025/init.lua

86 lines
2.0 KiB
Lua
Raw Normal View History

2022-06-08 15:35:23 -07:00
local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname)
local S = minetest.get_translator(modname)
2016-12-15 16:41:24 -08:00
2022-06-08 15:35:23 -07:00
emote = {
modname = modname,
modpath = modpath,
2016-12-15 16:41:24 -08:00
2022-06-08 15:35:23 -07:00
S = S,
2022-06-08 15:35:23 -07:00
log = function(level, messagefmt, ...)
return minetest.log(level, ("[%s] %s"):format(modname, messagefmt:format(...)))
end,
2022-06-08 15:35:23 -07:00
dofile = function(...)
return dofile(table.concat({modpath, ...}, DIR_DELIM) .. ".lua")
end,
}
2022-06-08 15:35:23 -07:00
emote.dofile("settings")
emote.dofile("util")
emote.dofile("api")
emote.dofile("entity")
2016-12-15 16:41:24 -08:00
2022-06-08 15:35:23 -07:00
local model = player_api.registered_models["character.b3d"]
2016-12-15 16:41:24 -08:00
2022-06-08 15:35:23 -07:00
emote.register_emote("stand", {
anim_name = "stand",
speed = 30,
description = S("stands up")
})
2022-06-08 15:35:23 -07:00
emote.register_emote("sit", {
anim_name = "sit",
speed = 30,
2022-11-06 02:21:17 -08:00
description = S("sits"),
2022-06-08 15:35:23 -07:00
})
2022-06-08 15:35:23 -07:00
emote.register_emote("lay", {
anim_name = "lay",
speed = 30,
2022-11-06 02:21:17 -08:00
description = S("lies down"),
2022-06-08 15:35:23 -07:00
})
2022-06-08 15:35:23 -07:00
emote.register_emote("sleep", { -- alias for lay
anim_name = "lay",
speed = 30,
2022-11-06 02:21:17 -08:00
description = S("falls asleep"),
2022-06-08 15:35:23 -07:00
})
2022-06-08 15:35:23 -07:00
model.animations.wave = {x = 192, y = 196, override_local = true}
emote.register_emote("wave", {
anim_name = "wave",
speed = 15,
stop_after = 4,
description = S("waves")
})
2022-06-08 15:35:23 -07:00
model.animations.point = {x = 196, y = 196, override_local = true}
emote.register_emote("point", {
anim_name = "point",
speed = 30,
description = S("points")
})
2022-06-08 15:35:23 -07:00
model.animations.freeze = {x = 205, y = 205, override_local = true}
emote.register_emote("freeze", {
anim_name = "freeze",
speed = 30,
description = S("freezes")
})
--[[
-- testing tool - punch any node to test attachment code
2022-06-08 15:35:23 -07:00
]]--
minetest.register_tool("emote:sleep", {
description = "use me on a bed bottom",
2022-06-08 15:35:23 -07:00
groups = {not_in_creative_inventory = 1},
on_use = function(itemstack, user, pointed_thing)
-- the delay here is weird, but the client receives a mouse-up event
-- after the punch and switches back to "stand" animation, undoing
-- the animation change we're doing.
minetest.after(0.5, emote.attach_to_node, user, pointed_thing.under)
end
})