-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhell.lua
More file actions
127 lines (99 loc) · 2.73 KB
/
hell.lua
File metadata and controls
127 lines (99 loc) · 2.73 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
--[[
Metatable hell and more useful things
"what the f*ck did you just bring upon this cursed land"
made with regrets by Ale32bit
https://github.com/Ale32bit-CC/hell-superset
MIT LICENSE: https://github.com/Ale32bit-CC/hell-superset/blob/master/LICENSE
--]]
assert(debug, "Debug not found")
assert(debug.getmetatable, "debug.getmetatable not found")
assert(debug.setmetatable, "debug.setmetatable not found")
local StringMT = debug.getmetatable("")
local NumberMT = debug.getmetatable(0) or {}
local FunctionMT = debug.getmetatable(function() end) or {}
local BooleanMT = debug.getmetatable(true) or {}
local NilMT = debug.getmetatable(nil) or {} --wtf
local stringlib = StringMT.__index
local function getAddress(str)
return loadstring("return 0x"..tostring(str):match("%w+$"))()
end
stringlib.tonumber = function(n)
return tonumber(n)
end
StringMT.__add = function(a, b)
return tostring(a)..tostring(b)
end
StringMT.__sub = function(a, b)
return (string.gsub(a,b,""))
end
StringMT.__unm = function(a)
return string.reverse(a)
end
StringMT.__index = function(str, ix)
if stringlib[ix] then return stringlib[ix] end
if type(ix) == "number" then
if ix > #str then return nil end
return string.sub(str, ix, ix)
end
return nil
end
NumberMT.__index = {
tostring = function(n)
return tostring(n)
end,
isNan = function(n)
return n ~= n
end,
isInf = function(n)
if n < 0 then n = -n end
return math.huge == n
end
}
FunctionMT.globalPrototypes = {
dump = string.dump,
tostring = tostring,
address = function(f)
return (string.match(tostring(f),"%w+$"))
end,
}
FunctionMT.prototypes = {}
FunctionMT.__index = function(self, k)
if not FunctionMT.prototypes[getAddress(self)] then FunctionMT.prototypes[getAddress(self)] = {} end
return FunctionMT.prototypes[getAddress(self)][k] or FunctionMT.globalPrototypes[k] or nil
end
FunctionMT.__newindex = function(self, k, v)
if not FunctionMT.prototypes[getAddress(self)] then FunctionMT.prototypes[getAddress(self)] = {} end
FunctionMT.prototypes[getAddress(self)][k] = v
end
FunctionMT.__concat = function(a, b)
return function(...)
local x = {a(...)}
local y = {b(...)}
return x, y
end
end
BooleanMT.__add = function(a, b)
return a or b
end
BooleanMT.__mul = function(a, b)
return a and b
end
BooleanMT.__unm = function(a)
return not a
end
BooleanMT.__mod = function(a, b)
return a ~= b
end
NilMT.prototype = {} -- im sorry jon
NilMT.__index = function(self, k)
return NilMT.prototype[k]
end
NilMT.__newindex = function(self, k, v)
NilMT.prototype[k] = v
end
debug.setmetatable("", StringMT)
debug.setmetatable(0, NumberMT)
debug.setmetatable(function() end, FunctionMT)
debug.setmetatable(true, BooleanMT)
debug.setmetatable(nil, NilMT)
--just kill me already