Skip to content

Commit

Permalink
Optionally use default value for physics override
Browse files Browse the repository at this point in the history
  • Loading branch information
AntumDeluge committed Jul 21, 2021
1 parent a72ba91 commit a2a10e8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ end
-- Public Methods --
--------------------

local default_transforms = {
sitting = { yaw = 7.9, pos = { x = 0, y = 0.1, z = 0 }, off = -7 },
laying = { yaw = 7.9, pos = { x = 0.5, y = 0.1, z = 0 }, off = -13 },
}

beds.sit_down = function ( name, pos )
if player_states[ name ] or default.player_attached[ name ] then return end

Expand All @@ -226,7 +231,8 @@ beds.sit_down = function ( name, pos )
if not transforms or not transforms.sitting then return end -- quick sanity check for properties

-- prevent the player from sitting on air
apply_physics_override( pos, player, transforms.sitting[ node.param2 ] )
apply_physics_override( pos, player, transforms.sitting[ node.param2 ]
or default_transforms.sitting )

default.player_set_animation( player, "sit", 30 )
default.player_attached[ name ] = true
Expand All @@ -244,7 +250,8 @@ beds.lay_down = function ( name, pos )
if not transforms or not transforms.laying then return end -- quick sanity check for properties

-- prevent the player from sitting on air
apply_physics_override( pos, player, transforms.laying[ node.param2 ] )
apply_physics_override( pos, player, transforms.laying[ node.param2 ]
or default_transforms.laying )

default.player_set_animation( player, "lay", 0 )
default.player_attached[ name ] = true
Expand Down

0 comments on commit a2a10e8

Please sign in to comment.