-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhexnumbers.lua
More file actions
89 lines (83 loc) · 2.23 KB
/
hexnumbers.lua
File metadata and controls
89 lines (83 loc) · 2.23 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
HexNumbers = {}
local number_table = {
[0] = 'aqaa',
[0.125] = 'aqaawdaddadd',
[0.25] = 'aqaawdd',
[0.375] = 'aqaawdwdd',
[0.5] = 'aqaawd',
[0.625] = 'aqaaqwddwdd',
[0.75] = 'aqaawdwd',
[0.875] = 'aqaaqdwdd',
[1] = 'aqaaw',
[1.5] = 'aqaawdw',
[1.625] = 'aqaawdwqdd', -- Between player sneak and standing height
[2] = 'aqaawa',
[3] = 'aqaaedwd',
[4] = 'aqaawaa',
[5] = 'aqaaq',
[6] = 'aqaaedw',
[7] = 'aqaawaq',
[8] = 'aqaawaqw',
[9] = 'aqaawaaq',
[10] = 'aqaae',
[11] = 'aqaaqaw',
[12] = 'aqaaqwa',
[13] = 'aqaawqaw',
[14] = 'aqaawaaqq',
[15] = 'aqaaedaq',
[16] = 'aqaaqawq',
[17] = 'aqaaqwaq',
[18] = 'aqaawaaqa',
[19] = 'aqaawaaqe',
[20] = 'aqaaee',
[30] = 'aqaaeaqq',
[40] = 'aqaaqqaa',
[50] = 'aqaaeaqa',
[100] = 'aqaaeaqaa',
}
local function to_number(number_as_string)
local numerator, denom = number_as_string:match('([^/]*)/([^/]*)')
if numerator and denom then
local numerator_as_number = to_number(numerator)
local denom_as_number = to_number(denom)
if numerator_as_number and denom_as_number then
return numerator_as_number / denom_as_number
else
return nil
end
end
return tonumber(number_as_string)
end
local function get_angles(number_as_string)
local number = to_number(number_as_string)
if not number then
return nil
end
local is_negative = number < 0
number = math.abs(number)
for key,angles in pairs(number_table) do
local tolerance = 0.00000001
if math.abs(number - key) <= tolerance then
if is_negative then
return angles:gsub('^aqaa', 'dedd', 1)
end
return angles
end
end
return nil
end
function HexNumbers.get_pattern(number_as_string)
local angles = get_angles(number_as_string)
if angles then
local startDir = "SOUTH_EAST"
-- If the number is negative, it should start flipped vertically
if string.sub(angles, 1, 1) == "d" then
startDir = "NORTH_EAST"
end
return {
angles = angles,
startDir = startDir
}
end
return nil
end