forked from rudzik8/mcl_decor
Add ability to sit on the chairs from ts_furniture mod
also, delete these comments from register.lua about nodeboxes for Gravel Path. currently the sitting feature works a bit weird, i'll try to fix it (BUT SITTING WORKS FINALLY YAAAYYY)
This commit is contained in:
parent
106ed35005
commit
b2e1eea202
61
api.lua
61
api.lua
|
@ -1,5 +1,55 @@
|
||||||
-- mcl_decor/api.lua
|
-- mcl_decor/api.lua
|
||||||
|
|
||||||
|
-- originally from the ts_furniture mod (which is from cozy) by Thomas--S // https://github.com/minetest-mods/ts_furniture/
|
||||||
|
mcl_decor.sit = function(pos, _, player)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
if not mcl_player.player_attached[name] then
|
||||||
|
if vector.length(player:get_player_velocity()) > 0 then
|
||||||
|
minetest.chat_send_player(player:get_player_name(), 'You can only sit down when you are not moving.')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
player:move_to(pos)
|
||||||
|
player:set_eye_offset({x = 0, y = -7, z = 2}, {x = 0, y = 0, z = 0})
|
||||||
|
player:set_physics_override(0, 0, 0)
|
||||||
|
mcl_player.player_attached[name] = true
|
||||||
|
minetest.after(0.1, function()
|
||||||
|
if player then
|
||||||
|
mcl_player.player_set_animation(player, "sit" , 30)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
mcl_decor.stand(player, name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
mcl_decor.up = function(_, _, player)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
if mcl_player.player_attached[name] then
|
||||||
|
mcl_decor.stand(player, name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
mcl_decor.stand = function(player, name)
|
||||||
|
player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
||||||
|
player:set_physics_override(1, 1, 1)
|
||||||
|
mcl_player.player_attached[name] = false
|
||||||
|
mcl_player.player_set_animation(player, "stand", 30)
|
||||||
|
end
|
||||||
|
if not minetest.get_modpath("mcl_cozy") then
|
||||||
|
minetest.register_globalstep(function(dtime)
|
||||||
|
local players = minetest.get_connected_players()
|
||||||
|
for i = 1, #players do
|
||||||
|
local player = players[i]
|
||||||
|
local name = player:get_player_name()
|
||||||
|
local ctrl = player:get_player_control()
|
||||||
|
if mcl_player.player_attached[name] and not player:get_attach() and
|
||||||
|
(ctrl.up or ctrl.down or ctrl.left or ctrl.right or ctrl.jump or ctrl.sneak) then
|
||||||
|
mcl_decor.up(nil, nil, player)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function mcl_decor:register_chair(name, def)
|
function mcl_decor:register_chair(name, def)
|
||||||
minetest.register_node(name, {
|
minetest.register_node(name, {
|
||||||
description = def.description,
|
description = def.description,
|
||||||
|
@ -35,16 +85,7 @@ function mcl_decor:register_chair(name, def)
|
||||||
_mcl_hardness = def._mcl_hardness,
|
_mcl_hardness = def._mcl_hardness,
|
||||||
_mcl_blast_resistance = def._mcl_blast_resistance,
|
_mcl_blast_resistance = def._mcl_blast_resistance,
|
||||||
sounds = def.sounds,
|
sounds = def.sounds,
|
||||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
on_rightclick = mcl_decor.sit
|
||||||
if not clicker:is_player() then
|
|
||||||
return itemstack
|
|
||||||
end
|
|
||||||
mcl_player.player_set_animation(clicker, "sit_mount", 30)
|
|
||||||
pos.y = pos.y-0.5
|
|
||||||
clicker:setpos(pos)
|
|
||||||
clicker:set_hp(20)
|
|
||||||
return itemstack
|
|
||||||
end
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
14
register.lua
14
register.lua
|
@ -44,13 +44,13 @@ minetest.register_node("mcl_decor:gravel_path", {
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{-0.4375, -0.5, -0.4375, -0.125, -0.4375, -0.125}, -- NodeBox1
|
{-0.4375, -0.5, -0.4375, -0.125, -0.4375, -0.125},
|
||||||
{-0.125, -0.5, -0.0625, 0.0625, -0.4375, 0.125}, -- NodeBox2
|
{-0.125, -0.5, -0.0625, 0.0625, -0.4375, 0.125},
|
||||||
{-0.3125, -0.5, 0.1875, -0.0625, -0.4375, 0.4375}, -- NodeBox3
|
{-0.3125, -0.5, 0.1875, -0.0625, -0.4375, 0.4375},
|
||||||
{0.0625, -0.5, -0.375, 0.25, -0.4375, -0.1875}, -- NodeBox4
|
{0.0625, -0.5, -0.375, 0.25, -0.4375, -0.1875},
|
||||||
{0.125, -0.5, 0.125, 0.375, -0.4375, 0.375}, -- NodeBox5
|
{0.125, -0.5, 0.125, 0.375, -0.4375, 0.375},
|
||||||
{0.25, -0.5, -0.125, 0.375, -0.4375, 0}, -- NodeBox6
|
{0.25, -0.5, -0.125, 0.375, -0.4375, 0},
|
||||||
{-0.4375, -0.5, 0, -0.3125, -0.4375, 0.125}, -- NodeBox7
|
{-0.4375, -0.5, 0, -0.3125, -0.4375, 0.125},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
selection_box = {
|
selection_box = {
|
||||||
|
|
Loading…
Reference in New Issue