add function to check if a value is a valid position

This commit is contained in:
sapier 2013-02-10 16:21:31 +00:00
parent ed17af18f8
commit bbf9d5a5f7

View File

@ -633,6 +633,41 @@ function mobf_pos_is_same(pos1,pos2)
return true
end
-------------------------------------------------------------------------------
-- name: mobf_is_pos(value)
--
--! @brief check if a given value is a position
--
--! @param value to check
--
--! @return true/false
-------------------------------------------------------------------------------
function mobf_is_pos(value)
if value == nil or
type(value) ~= "table" then
return false
end
if value.x == nil or
tonumber(value.x) == nil then
return false
end
if value.y == nil or
tonumber(value.y) == nil then
return false
end
if value.z == nil or
tonumber(value.z) == nil then
return false
end
return true
end
-------------------------------------------------------------------------------
-- name: mobf_assert_backtrace(value)
--
@ -647,4 +682,6 @@ function mobf_assert_backtrace(value)
end
end
--!@}