forked from nalc/homedecor_modpack
Allow sit on some furnitures
This commit is contained in:
parent
307d969f4c
commit
c6790ad21e
@ -34,6 +34,40 @@ for _, i in ipairs(table_colors) do
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function sit(pos, node, clicker)
|
||||||
|
local name = clicker:get_player_name()
|
||||||
|
local meta = minetest:get_meta(pos)
|
||||||
|
local param2 = node.param2
|
||||||
|
if not clicker or not clicker:is_player()
|
||||||
|
or clicker:get_player_control().up == true or clicker:get_player_control().down == true
|
||||||
|
or clicker:get_player_control().left == true or clicker:get_player_control().right == true
|
||||||
|
or clicker:get_player_control().jump == true then -- make sure that the player is immobile.
|
||||||
|
return end
|
||||||
|
if clicker:get_player_name() == meta:get_string("player") then
|
||||||
|
meta:set_string("player", "")
|
||||||
|
pos.y = pos.y-0.5
|
||||||
|
clicker:setpos(pos)
|
||||||
|
clicker:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0})
|
||||||
|
clicker:set_physics_override(1, 1, 1)
|
||||||
|
default.player_attached[name] = false
|
||||||
|
default.player_set_animation(clicker, "stand", 30)
|
||||||
|
else
|
||||||
|
meta:set_string("player", clicker:get_player_name())
|
||||||
|
clicker:set_eye_offset({x=0,y=-7,z=2}, {x=0,y=0,z=0})
|
||||||
|
clicker:set_physics_override(0, 0, 0)
|
||||||
|
default.player_attached[name] = true
|
||||||
|
if param2 == 1 then
|
||||||
|
clicker:set_look_yaw(7.9)
|
||||||
|
elseif param2 == 3 then
|
||||||
|
clicker:set_look_yaw(4.75)
|
||||||
|
elseif param2 == 0 then
|
||||||
|
clicker:set_look_yaw(3.15)
|
||||||
|
else
|
||||||
|
clicker:set_look_yaw(6.28)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local chaircolors = {
|
local chaircolors = {
|
||||||
{ "", "plain" },
|
{ "", "plain" },
|
||||||
{ "black", "Black" },
|
{ "black", "Black" },
|
||||||
@ -81,6 +115,12 @@ for i in ipairs(chaircolors) do
|
|||||||
fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3},
|
fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3},
|
||||||
},
|
},
|
||||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
||||||
|
on_rightclick = function(pos, node, clicker) -- don't move these functions inside sit()
|
||||||
|
sit(pos, node, clicker, pos)
|
||||||
|
pos.y = pos.y-0 -- player's sit position.
|
||||||
|
clicker:setpos(pos)
|
||||||
|
default.player_set_animation(clicker, "sit", 30)
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
if color ~= "" then
|
if color ~= "" then
|
||||||
@ -110,6 +150,13 @@ for i in ipairs(chaircolors) do
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
||||||
|
on_rightclick = function(pos, node, clicker) -- don't move these functions inside sit()
|
||||||
|
sit(pos, node, clicker, pos)
|
||||||
|
pos.y = pos.y-0.1 -- player's sit position.
|
||||||
|
clicker:setpos(pos)
|
||||||
|
default.player_set_animation(clicker, "sit", 30)
|
||||||
|
clicker:set_hp(20)
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
@ -355,6 +402,12 @@ homedecor.register("simple_bench", {
|
|||||||
{ 0.3, -0.5, 0.1, 0.4, -0.15, 0.3},
|
{ 0.3, -0.5, 0.1, 0.4, -0.15, 0.3},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
on_rightclick = function(pos, node, clicker) -- don't move these functions inside sit()
|
||||||
|
sit(pos, node, clicker, pos)
|
||||||
|
pos.y = pos.y-0 -- player's sit position.
|
||||||
|
clicker:setpos(pos)
|
||||||
|
default.player_set_animation(clicker, "sit", 30)
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
homedecor.register("bench_large_1_left", {
|
homedecor.register("bench_large_1_left", {
|
||||||
@ -386,6 +439,12 @@ homedecor.register("bench_large_1_left", {
|
|||||||
fixed = { -0.5, -0.5, -0.09375, 1.5, 0.5, 0.5 }
|
fixed = { -0.5, -0.5, -0.09375, 1.5, 0.5, 0.5 }
|
||||||
},
|
},
|
||||||
expand = { right="homedecor:bench_large_1_right" },
|
expand = { right="homedecor:bench_large_1_right" },
|
||||||
|
on_rightclick = function(pos, node, clicker) -- don't move these functions inside sit()
|
||||||
|
sit(pos, node, clicker, pos)
|
||||||
|
pos.y = pos.y-0 -- player's sit position.
|
||||||
|
clicker:setpos(pos)
|
||||||
|
default.player_set_animation(clicker, "sit", 30)
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
homedecor.register("bench_large_1_right", {
|
homedecor.register("bench_large_1_right", {
|
||||||
@ -452,6 +511,12 @@ homedecor.register("bench_large_2_left", {
|
|||||||
fixed = { -0.5, -0.5, -0.15625, 1.5, 0.5, 0.5 }
|
fixed = { -0.5, -0.5, -0.15625, 1.5, 0.5, 0.5 }
|
||||||
},
|
},
|
||||||
expand = { right="homedecor:bench_large_2_right" },
|
expand = { right="homedecor:bench_large_2_right" },
|
||||||
|
on_rightclick = function(pos, node, clicker) -- don't move these functions inside sit()
|
||||||
|
sit(pos, node, clicker, pos)
|
||||||
|
pos.y = pos.y-0 -- player's sit position.
|
||||||
|
clicker:setpos(pos)
|
||||||
|
default.player_set_animation(clicker, "sit", 30)
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
homedecor.register("bench_large_2_right", {
|
homedecor.register("bench_large_2_right", {
|
||||||
|
Loading…
Reference in New Issue
Block a user