-
Notifications
You must be signed in to change notification settings - Fork 3
/
globals.lua
50 lines (45 loc) · 955 Bytes
/
globals.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---@enum Difficulty
Difficulty = {
Beginner = 0,
Easy = 1,
Medium = 2,
Hard = 3
}
---@enum Directions
Directions = {
Up = 0,
Down = 1,
Left = 2,
Right = 3
}
---@enum GameStatus
GameStatus = {
Error = -5,
FailedToStart = -4,
MissingHackKit = -3,
TakingDamage = -2,
Failure = -1,
PlayerQuit = 0,
Success = 1
}
---@enum PortPositionType
PortPositionType = {
Start = 0,
Finish = 1
}
---Clamp a value to a min and max value
---@param value number
---@param min number
---@param max number
---@return number
function math.clamp(value, min, max)
return value < min and min or value > max and max or value
end
---Round a number to the specified decimal point
---@param number number
---@param decimalPoint number
---@return number
function math.round(number, decimalPoint)
local multiplier = 10 ^ (decimalPoint or 0)
return math.floor(number * multiplier + 0.5) / multiplier
end