track/common.lua

by hugeblank
697 days ago
COPY
1
local api = {}
2

3
local function xzbounds(num)
4
    return num > -10001 and num < 10001
5
end
6

7
local function ybounds(num)
8
    return num > -65 and num < 321
9
end
10

11
api.checkBounds = function(x, y, z)
12
    x, y, z = tonumber(x), tonumber(y), tonumber(z)
13
    if not x then
14
        return false, "Value x is not a number."
15
    elseif not y then
16
        return false, "Value y is not a number."
17
    elseif not z then
18
        return false, "Value z is not a number."
19
    elseif not xzbounds(x) then
20
        return false, "Value x = "..x.." is out of bounds."
21
    elseif not ybounds(y) then
22
        return false, "Value y = "..y.." is out of bounds."
23
    elseif not xzbounds(z) then
24
        return false, "Value z = "..z.." is out of bounds."
25
    end
26
    return true, x, y, z
27
end
28

29
return api