-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
38 lines (32 loc) · 991 Bytes
/
init.lua
File metadata and controls
38 lines (32 loc) · 991 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
local function sit_on_stair(pos, node, player)
-- Get opposite horizontal rotation
local rotation = emote.util.facedir_to_look_horizontal((node.param2 + 2) % 4)
player:set_look_horizontal(rotation)
-- Teleport player to adjusted position
local sit_pos = {
x = pos.x,
y = pos.y,
z = pos.z
}
player:set_pos(sit_pos)
-- Trigger sit emote
minetest.after(0.25, function()
emote.start(player, "sit")
minetest.after(0.1, function()
player:set_eye_offset({x = 0, y = 6, z = 0}, {x = 0, y = 0, z = 0})
end)
end)
end
-- Override all stair-like nodes
minetest.register_on_mods_loaded(function()
for name, def in pairs(minetest.registered_nodes) do
if def.description and def.description:lower():find("stair") then
minetest.override_item(name, {
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
sit_on_stair(pos, node, clicker)
return itemstack
end
})
end
end
end)