Move sit function

This commit is contained in:
kilbith 2015-05-11 20:21:27 +02:00
parent f59e0448c7
commit 3f16e7dbc0
3 changed files with 36 additions and 49 deletions

View File

@ -84,12 +84,10 @@ for i in ipairs(chaircolors) do
collision_box = kc_cbox, collision_box = kc_cbox,
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
--[[
on_rightclick = function(pos, node, clicker) on_rightclick = function(pos, node, clicker)
pos.y = pos.y-0 -- player's sit position. pos.y = pos.y+0 -- where do I put my ass ?
homedecor.sit_exec(pos, node, clicker) homedecor.sit(pos, node, clicker)
end, end
--]]
}) })
if color ~= "" then if color ~= "" then
@ -187,50 +185,6 @@ homedecor.register("office_chair_"..c, {
end end
-- Sitting functions disabled for now because of buggyness.
--[[
function homedecor.sit(pos, node, clicker)
local name = clicker:get_player_name()
local meta = minetest:get_meta(pos)
local param2 = node.param2
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
function homedecor.sit_exec(pos, node, clicker) -- don't move these functions inside sit()
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
homedecor.sit(pos, node, clicker)
clicker:setpos(pos)
default.player_set_animation(clicker, "sit", 30)
end
--]]
-- Aliases for 3dforniture mod. -- Aliases for 3dforniture mod.
minetest.register_alias("3dforniture:table", "homedecor:table") minetest.register_alias("3dforniture:table", "homedecor:table")

View File

@ -0,0 +1,32 @@
function homedecor.sit(pos, node, clicker)
do return end -- delete it when the engine is stabler for the player's physics
local meta = minetest.get_meta(pos)
local param2 = node.param2
local name = clicker:get_player_name()
if name == meta:get_string("is_sit") then
meta:set_string("is_sit", "")
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("is_sit", 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)
clicker:setpos(pos)
default.player_attached[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
end
end

View File

@ -122,6 +122,7 @@ dofile(homedecor.modpath.."/handlers/furnaces.lua")
dofile(homedecor.modpath.."/handlers/registration.lua") dofile(homedecor.modpath.."/handlers/registration.lua")
-- some nodes have particle spawners -- some nodes have particle spawners
dofile(homedecor.modpath.."/handlers/water_particles.lua") dofile(homedecor.modpath.."/handlers/water_particles.lua")
dofile(homedecor.modpath.."/handlers/sit.lua")
-- load various other components -- load various other components
dofile(homedecor.modpath.."/misc-nodes.lua") -- the catch-all for all misc nodes dofile(homedecor.modpath.."/misc-nodes.lua") -- the catch-all for all misc nodes