Add support for playerphysics mod
This commit is contained in:
parent
4082115ae3
commit
9b5ce5f5a1
@ -1,3 +1,5 @@
|
|||||||
|
local mod_playerphysics = minetest.get_modpath("playerphysics") ~= nil
|
||||||
|
|
||||||
local function top_face(pointed_thing)
|
local function top_face(pointed_thing)
|
||||||
if not pointed_thing then return end
|
if not pointed_thing then return end
|
||||||
return pointed_thing.above.y > pointed_thing.under.y
|
return pointed_thing.above.y > pointed_thing.under.y
|
||||||
@ -20,7 +22,12 @@ function xdecor.sit(pos, node, clicker, pointed_thing)
|
|||||||
pos.y = pos.y - 0.5
|
pos.y = pos.y - 0.5
|
||||||
clicker:set_pos(pos)
|
clicker:set_pos(pos)
|
||||||
clicker:set_eye_offset(vector.new(), vector.new())
|
clicker:set_eye_offset(vector.new(), vector.new())
|
||||||
clicker:set_physics_override({speed = 1, jump = 1, gravity = 1})
|
if mod_playerphysics then
|
||||||
|
playerphysics.remove_physics_factor(clicker, "speed", "xdecor:sit_speed")
|
||||||
|
playerphysics.remove_physics_factor(clicker, "jump", "xdecor:sit_jump")
|
||||||
|
else
|
||||||
|
clicker:set_physics_override({speed = 1, jump = 1})
|
||||||
|
end
|
||||||
default.player_attached[player_name] = false
|
default.player_attached[player_name] = false
|
||||||
default.player_set_animation(clicker, "stand", 30)
|
default.player_set_animation(clicker, "stand", 30)
|
||||||
|
|
||||||
@ -28,7 +35,12 @@ function xdecor.sit(pos, node, clicker, pointed_thing)
|
|||||||
not ctrl.sneak and vector.equals(vel, vector.new()) then
|
not ctrl.sneak and vector.equals(vel, vector.new()) then
|
||||||
|
|
||||||
clicker:set_eye_offset({x = 0, y = -7, z = 2}, vector.new())
|
clicker:set_eye_offset({x = 0, y = -7, z = 2}, vector.new())
|
||||||
clicker:set_physics_override({speed = 0, jump = 0, gravity = 1})
|
if mod_playerphysics then
|
||||||
|
playerphysics.add_physics_factor(clicker, "speed", "xdecor:sit_speed", 0)
|
||||||
|
playerphysics.add_physics_factor(clicker, "jump", "xdecor:sit_jump", 0)
|
||||||
|
else
|
||||||
|
clicker:set_physics_override({speed = 0, jump = 0})
|
||||||
|
end
|
||||||
clicker:set_pos(pos)
|
clicker:set_pos(pos)
|
||||||
default.player_attached[player_name] = true
|
default.player_attached[player_name] = true
|
||||||
default.player_set_animation(clicker, "sit", 30)
|
default.player_set_animation(clicker, "sit", 30)
|
||||||
|
2
mod.conf
2
mod.conf
@ -1,5 +1,5 @@
|
|||||||
name = xdecor
|
name = xdecor
|
||||||
description = A decoration mod meant to be simple and well-featured (libre version).
|
description = A decoration mod meant to be simple and well-featured (libre version).
|
||||||
depends = default, bucket, doors, farming, stairs, xpanes
|
depends = default, bucket, doors, farming, stairs, xpanes
|
||||||
optional_depends = fire, oresplus, moreblocks, mesecons
|
optional_depends = playerphysics, fire, oresplus, moreblocks, mesecons
|
||||||
min_minetest_version = 5.1.0
|
min_minetest_version = 5.1.0
|
||||||
|
Loading…
Reference in New Issue
Block a user