Add files via upload
parent
406b350a72
commit
e572f4cff6
|
@ -1,50 +1,57 @@
|
|||
function ma_pops_furniture.sit(pos, node, clicker)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local param2 = node.param2
|
||||
local name = clicker:get_player_name()
|
||||
local function top_face(pointed_thing)
|
||||
if not pointed_thing then return end
|
||||
return pointed_thing.above.y > pointed_thing.under.y
|
||||
end
|
||||
|
||||
if name == meta:get_string("is_sit") then
|
||||
print 'player should be standing.'
|
||||
meta:set_string("is_sit", "")
|
||||
pos.y = pos.y-0.5
|
||||
function ma_pops_furniture.sit(pos, node, clicker, pointed_thing)
|
||||
if not top_face(pointed_thing) then return end
|
||||
local player_name = clicker:get_player_name()
|
||||
local objs = minetest.get_objects_inside_radius(pos, 0.1)
|
||||
local vel = clicker:get_player_velocity()
|
||||
local ctrl = clicker:get_player_control()
|
||||
|
||||
for _, obj in pairs(objs) do
|
||||
if obj:is_player() and obj:get_player_name() ~= player_name then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if default.player_attached[player_name] then
|
||||
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_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_attached[player_name] = false
|
||||
default.player_set_animation(clicker, "stand", 30)
|
||||
else
|
||||
meta:set_string("is_sit", clicker:get_player_name())
|
||||
print 'player should be sitting.'
|
||||
clicker:set_eye_offset({x=0,y=-7,z=2}, {x=0,y=0,z=0})
|
||||
|
||||
elseif not default.player_attached[player_name] and node.param2 <= 3 and
|
||||
not ctrl.sneak and vector.equals(vel, {x=0,y=0,z=0}) then
|
||||
|
||||
clicker:set_eye_offset({x=0, y=-7, z=2}, {x=0, y=0, z=0})
|
||||
clicker:set_physics_override(0, 0, 0)
|
||||
clicker:setpos(pos)
|
||||
default.player_attached[name] = true
|
||||
default.player_attached[player_name] = true
|
||||
default.player_set_animation(clicker, "sit", 30)
|
||||
if param2 == 0 then
|
||||
clicker:set_look_yaw(3.15)
|
||||
elseif param2 == 1 then
|
||||
clicker:set_look_yaw(7.9)
|
||||
elseif param2 == 2 then
|
||||
clicker:set_look_yaw(6.28)
|
||||
elseif param2 == 3 then
|
||||
clicker:set_look_yaw(4.75)
|
||||
else return end
|
||||
|
||||
if node.param2 == 0 then clicker:set_look_yaw(3.15)
|
||||
elseif node.param2 == 1 then clicker:set_look_yaw(7.9)
|
||||
elseif node.param2 == 2 then clicker:set_look_yaw(6.28)
|
||||
elseif node.param2 == 3 then clicker:set_look_yaw(4.75) end
|
||||
end
|
||||
end
|
||||
|
||||
function ma_pops_furniture.dig_chair(pos, node, meta, digger)
|
||||
local sitting = meta.fields.is_sit or nil
|
||||
|
||||
if sitting and sitting ~= "" then
|
||||
local player = minetest.get_player_by_name(sitting)
|
||||
pos.y = pos.y-0.5
|
||||
player:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0})
|
||||
player:set_physics_override(1, 1, 1)
|
||||
default.player_attached[sitting] = false
|
||||
default.player_set_animation(player, "stand", 30)
|
||||
function ma_pops_furniture.sit_dig(pos, digger)
|
||||
for _, player in pairs(minetest.get_objects_inside_radius(pos, 0.1)) do
|
||||
if player:is_player() and
|
||||
default.player_attached[player:get_player_name()] then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
|
||||
ma_pops_furniture.window_operate = function( pos, old_node_state_name, new_node_state_name )
|
||||
|
||||
local offsets = {-1,1,-2,2,-3,3};
|
||||
|
|
27
nodes.lua
27
nodes.lua
|
@ -744,9 +744,12 @@ minetest.register_node('ma_pops_furniture:chair_'..material, {
|
|||
paramtype = 'light',
|
||||
paramtype2 = 'facedir',
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
ma_pops_furniture.sit(pos, node, clicker)
|
||||
end,
|
||||
can_dig = ma_pops_furniture.sit_dig,
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
pos.y = pos.y + 0 -- Sitting position
|
||||
ma_pops_furniture.sit(pos, node, clicker, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
|
@ -1899,9 +1902,12 @@ minetest.register_node("ma_pops_furniture:chair2_"..color, {
|
|||
paramtype2 = "facedir",
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, furniture = 1, fall_damage_add_percent=-80, bouncy=80},
|
||||
sounds = {wood = {name="furn_bouncy", gain=0.8}},
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
ma_pops_furniture.sit(pos, node, clicker)
|
||||
end,
|
||||
can_dig = ma_pops_furniture.sit_dig,
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
pos.y = pos.y + 0 -- Sitting position
|
||||
ma_pops_furniture.sit(pos, node, clicker, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
|
@ -3646,9 +3652,12 @@ minetest.register_node("ma_pops_furniture:stool_"..color, {
|
|||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 2, furniture = 1},
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
ma_pops_furniture.sit(pos, node, clicker)
|
||||
end,
|
||||
can_dig = ma_pops_furniture.sit_dig,
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
pos.y = pos.y + 0 -- Sitting position
|
||||
ma_pops_furniture.sit(pos, node, clicker, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
|
|
45
sofa.lua
45
sofa.lua
|
@ -47,9 +47,12 @@ minetest.register_node('ma_pops_furniture:sofa_'..color, {
|
|||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
sounds = {wood = {name="furn_bouncy", gain=0.8}},
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
ma_pops_furniture.sit(pos, node, clicker)
|
||||
end,
|
||||
can_dig = ma_pops_furniture.sit_dig,
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
pos.y = pos.y + 0 -- Sitting position
|
||||
ma_pops_furniture.sit(pos, node, clicker, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
selection_box = {
|
||||
type = 'fixed',
|
||||
fixed = {
|
||||
|
@ -160,9 +163,12 @@ minetest.register_node('ma_pops_furniture:sofa_l_'..color, {
|
|||
drop = 'ma_pops_furniture:sofa_'..color,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
ma_pops_furniture.sit(pos, node, clicker)
|
||||
end,
|
||||
can_dig = ma_pops_furniture.sit_dig,
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
pos.y = pos.y + 0 -- Sitting position
|
||||
ma_pops_furniture.sit(pos, node, clicker, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
sounds = {
|
||||
wood = {name="furn_bouncy", gain=0.8}
|
||||
},
|
||||
|
@ -274,9 +280,12 @@ minetest.register_node('ma_pops_furniture:sofa_m_'..color, {
|
|||
drop = 'ma_pops_furniture:sofa_'..color,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
ma_pops_furniture.sit(pos, node, clicker)
|
||||
end,
|
||||
can_dig = ma_pops_furniture.sit_dig,
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
pos.y = pos.y + 0 -- Sitting position
|
||||
ma_pops_furniture.sit(pos, node, clicker, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
sounds = {wood = {name="furn_bouncy", gain=0.8}},
|
||||
selection_box = {
|
||||
type = 'fixed',
|
||||
|
@ -383,9 +392,12 @@ minetest.register_node('ma_pops_furniture:sofa_r_'..color, {
|
|||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
sounds = {wood = {name="furn_bouncy", gain=0.8}},
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
ma_pops_furniture.sit(pos, node, clicker)
|
||||
end,
|
||||
can_dig = ma_pops_furniture.sit_dig,
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
pos.y = pos.y + 0 -- Sitting position
|
||||
ma_pops_furniture.sit(pos, node, clicker, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
selection_box = {
|
||||
type = 'fixed',
|
||||
fixed = {
|
||||
|
@ -493,9 +505,12 @@ minetest.register_node('ma_pops_furniture:sofa_c_'..color, {
|
|||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
sounds = {wood = {name="furn_bouncy", gain=0.8}},
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
ma_pops_furniture.sit(pos, node, clicker)
|
||||
end,
|
||||
can_dig = ma_pops_furniture.sit_dig,
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
pos.y = pos.y + 0 -- Sitting position
|
||||
ma_pops_furniture.sit(pos, node, clicker, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
selection_box = {
|
||||
type = 'fixed',
|
||||
fixed = {
|
||||
|
|
Loading…
Reference in New Issue