fixed some issues with sunbeds
This commit is contained in:
parent
b6521c992e
commit
a656298d7c
109
sdraia.lua
109
sdraia.lua
@ -12,59 +12,7 @@
|
|||||||
for i in ipairs(sdraia_list) do
|
for i in ipairs(sdraia_list) do
|
||||||
local sdraiadesc = sdraia_list[i][1]
|
local sdraiadesc = sdraia_list[i][1]
|
||||||
local colour = sdraia_list[i][2]
|
local colour = sdraia_list[i][2]
|
||||||
|
local sleep_in_sdraia = function( pos, node, clicker, itemstack, pointed_thing )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("summer:sdraia_"..colour.."", {
|
|
||||||
description = sdraiadesc.."",
|
|
||||||
drawtype = "mesh",
|
|
||||||
mesh = "sdraia.obj",
|
|
||||||
tiles = {"sdraia_"..colour..".png",
|
|
||||||
},
|
|
||||||
inventory_image = "sdraia_"..colour.."_inv.png",
|
|
||||||
|
|
||||||
wield_image = "sdraia_"..colour..".png" ,
|
|
||||||
paramtype = "light",
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
sunlight_propagates = true,
|
|
||||||
walkable = false,
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = { 0.4, 0.1,1.0, -0.4,-0.49, -1.0 },
|
|
||||||
},
|
|
||||||
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3,not_in_creative_inventory=0},
|
|
||||||
--sounds = default.node_sound_wood_defaults(),
|
|
||||||
drop = "summer:sdraia_"..colour.."",
|
|
||||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
|
||||||
return minetest.sleep_in_sdraia( pos, node, clicker, itemstack, pointed_thing );
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
minetest.allow_sit = function( player )
|
|
||||||
-- no check possible
|
|
||||||
if( not( player.get_player_velocity )) then
|
|
||||||
return true;
|
|
||||||
end
|
|
||||||
local velo = player:get_player_velocity();
|
|
||||||
if( not( velo )) then
|
|
||||||
return false;
|
|
||||||
end
|
|
||||||
local max_velo = 0.0010;
|
|
||||||
if( math.abs(velo.x) < max_velo
|
|
||||||
and math.abs(velo.y) < max_velo
|
|
||||||
and math.abs(velo.z) < max_velo ) then
|
|
||||||
return true;
|
|
||||||
end
|
|
||||||
return false;
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
minetest.sleep_in_sdraia = function( pos, node, clicker, itemstack, pointed_thing )
|
|
||||||
if( not( clicker ) or not( node ) or not( node.name ) or not( pos ) or not( minetest.allow_sit( clicker))) then
|
if( not( clicker ) or not( node ) or not( node.name ) or not( pos ) or not( minetest.allow_sit( clicker))) then
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
@ -172,6 +120,7 @@ minetest.sleep_in_sdraia = function( pos, node, clicker, itemstack, pointed_thin
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.chat_send_player( pname, 'Состояние ' .. new_animation);
|
||||||
if( default.player_attached[pname] and animation.animation=="sit") then
|
if( default.player_attached[pname] and animation.animation=="sit") then
|
||||||
-- just changing the animation...
|
-- just changing the animation...
|
||||||
if( allow_sleep==true ) then
|
if( allow_sleep==true ) then
|
||||||
@ -192,10 +141,10 @@ minetest.sleep_in_sdraia = function( pos, node, clicker, itemstack, pointed_thin
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
clicker:set_eye_offset({x=0,y=-7,z=2}, {x=0,y=0,z=0})
|
clicker:set_eye_offset({x=0,y=3,z=2}, {x=0,y=10,z=0})
|
||||||
clicker:setpos( p );
|
clicker:setpos( p );
|
||||||
default.player_set_animation(clicker, new_animation, 30)
|
default.player_set_animation(clicker, new_animation, 30)
|
||||||
clicker:set_physics_override(0, 0, 0)
|
clicker:set_physics_override()
|
||||||
default.player_attached[pname] = true
|
default.player_attached[pname] = true
|
||||||
|
|
||||||
|
|
||||||
@ -203,4 +152,54 @@ end
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
minetest.register_node("summer:sdraia_"..colour.."", {
|
||||||
|
description = sdraiadesc.."",
|
||||||
|
drawtype = "mesh",
|
||||||
|
mesh = "sdraia.obj",
|
||||||
|
tiles = {"sdraia_"..colour..".png",
|
||||||
|
},
|
||||||
|
inventory_image = "sdraia_"..colour.."_inv.png",
|
||||||
|
|
||||||
|
wield_image = "sdraia_"..colour..".png" ,
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
selection_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = { 0.4, 0.1,1.0, -0.4,-0.49, -1.0 },
|
||||||
|
},
|
||||||
|
collision_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{0.4, 0.1,1.0, -0.4,-0.49, -1.0},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
is_ground_content = false,
|
||||||
|
groups = {cracky=3,oddly_breakable_by_hand=3,not_in_creative_inventory=0},
|
||||||
|
--sounds = default.node_sound_wood_defaults(),
|
||||||
|
drop = "summer:sdraia_"..colour.."",
|
||||||
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
|
return sleep_in_sdraia( pos, node, clicker, itemstack, pointed_thing );
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
minetest.allow_sit = function( player )
|
||||||
|
-- no check possible
|
||||||
|
if( not( player.get_player_velocity )) then
|
||||||
|
return true;
|
||||||
|
end
|
||||||
|
local velo = player:get_player_velocity();
|
||||||
|
if( not( velo )) then
|
||||||
|
return false;
|
||||||
|
end
|
||||||
|
local max_velo = 0.0010;
|
||||||
|
if( math.abs(velo.x) < max_velo
|
||||||
|
and math.abs(velo.y) < max_velo
|
||||||
|
and math.abs(velo.z) < max_velo ) then
|
||||||
|
return true;
|
||||||
|
end
|
||||||
|
return false;
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user