nil checks and 53 support check
This commit is contained in:
parent
3b3e83b0d3
commit
725d4ac0c4
10
api.lua
10
api.lua
@ -27,16 +27,18 @@ function beds.register_bed(name, def)
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
stack_max = 1,
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 1,
|
||||
fall_damage_add_percent = -40, bouncy = 85},
|
||||
groups = {
|
||||
choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 1,
|
||||
fall_damage_add_percent = -40, bouncy = 85
|
||||
},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = def.selectionbox,
|
||||
fixed = def.selectionbox
|
||||
},
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = def.collisionbox,
|
||||
fixed = def.collisionbox
|
||||
},
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
|
@ -1,5 +1,6 @@
|
||||
local S = beds.get_translator
|
||||
local is_50 = minetest.get_modpath("player_api")
|
||||
local is_53 = minetest.has_feature("object_step_has_moveresult")
|
||||
local is_pova = minetest.get_modpath("pova")
|
||||
local pi = math.pi
|
||||
local is_sp = minetest.is_singleplayer()
|
||||
@ -132,7 +133,7 @@ local function lay_down(player, pos, bed_pos, state, skip)
|
||||
end
|
||||
|
||||
-- Check if player is moving
|
||||
if vector.length(player:get_velocity()) > 0.001 then
|
||||
if is_53 and vector.length(player:get_velocity()) > 0.001 then
|
||||
|
||||
minetest.chat_send_player(name,
|
||||
S("You have to stop moving before going to bed!"))
|
||||
@ -320,6 +321,8 @@ if enable_respawn then
|
||||
-- respawn player at bed if enabled and valid position is found
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
|
||||
if not player then return end
|
||||
|
||||
local name = player:get_player_name()
|
||||
local pos = beds.spawn[name]
|
||||
|
||||
@ -333,6 +336,8 @@ end
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
|
||||
if not player then return end
|
||||
|
||||
local name = player:get_player_name()
|
||||
|
||||
lay_down(player, nil, nil, false, true)
|
||||
|
Loading…
x
Reference in New Issue
Block a user