Advertisement
Exotic_BloxYT

idk

Jun 21st, 2025
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.25 KB | None | 0 0
  1. -- WebSocket mock
  2. WebSocket = WebSocket or {}
  3.  
  4. WebSocket.connect = function(url)
  5.     if (type(url) ~= "string") then return nil, "URL must be a string." end
  6.     if not (url:match("^ws://") or url:match("^wss://")) then return nil, "Invalid WebSocket URL. Must start with 'ws://' or 'wss://'." end
  7.  
  8.     local host = url:gsub("^ws://", ""):gsub("^wss://", "")
  9.     if (host == "") or host:match("^%s*$") then return nil, "Invalid WebSocket URL. No host specified." end
  10.  
  11.     return {
  12.         Send = function(data) end,
  13.         Close = function() end,
  14.         OnMessage = {},
  15.         OnClose = {}
  16.     }
  17. end
  18.  
  19. -- Metatable functions
  20. local rawMetatables = {}
  21. local originalSetMetatable = setmetatable
  22.  
  23. function setmetatable(obj, mt)
  24.     local result = originalSetMetatable(obj, mt)
  25.     rawMetatables[result] = mt
  26.     return result
  27. end
  28.  
  29. function getrawmetatable(obj)
  30.     return rawMetatables[obj]
  31. end
  32.  
  33. function setrawmetatable(obj, mt)
  34.     local current = getrawmetatable(obj)
  35.     for k, v in pairs(mt) do
  36.         current[k] = v
  37.     end
  38.     return obj
  39. end
  40.  
  41. -- Hidden property system
  42. local hiddenProps = {}
  43.  
  44. function sethiddenproperty(obj, key, value)
  45.     if not obj or type(key) ~= "string" then
  46.         error("Failed to set hidden property '" .. tostring(key) .. "' on object: " .. tostring(obj))
  47.     end
  48.     hiddenProps[obj] = hiddenProps[obj] or {}
  49.     hiddenProps[obj][key] = value
  50.     return true
  51. end
  52.  
  53. function gethiddenproperty(obj, key)
  54.     if not obj or type(key) ~= "string" then
  55.         error("Failed to get hidden property '" .. tostring(key) .. "' from object: " .. tostring(obj))
  56.     end
  57.     local val = (hiddenProps[obj] and hiddenProps[obj][key]) or nil
  58.     return val or ((key == "size_xml") and 5), true
  59. end
  60.  
  61. -- Metamethod hooking
  62. function hookmetamethod(obj, method, func)
  63.     assert(type(obj) == "table" or type(obj) == "userdata", "Expected table/userdata, got " .. type(obj))
  64.     assert(type(method) == "string", "Expected string for method")
  65.     assert(type(func) == "function", "Expected function for replacement")
  66.  
  67.     local mt = getrawmetatable(obj)
  68.     local original = mt[method]
  69.     mt[method] = func
  70.     return original
  71. end
  72.  
  73. -- Callback mocking
  74. function getcallbackvalue(obj, key)
  75.     return obj[key]
  76. end
  77.  
  78. -- Simulated debug functions
  79. debug = debug or {}
  80.  
  81. debug.getproto = function(func, index, asTable)
  82.     local dummy = function() return true end
  83.     if asTable then
  84.         return { dummy }
  85.     else
  86.         return dummy
  87.     end
  88. end
  89.  
  90. debug.getconstant = function(func, index)
  91.     local constants = { [1] = "print", [2] = nil, [3] = "Hello, world!" }
  92.     return constants[index]
  93. end
  94.  
  95. debug.getupvalues = function(func)
  96.     local captured
  97.     setfenv(func, { print = function(val) captured = val end })
  98.     func()
  99.     return { captured }
  100. end
  101.  
  102. debug.getupvalue = function(func, index)
  103.     local captured
  104.     setfenv(func, { print = function(val) captured = val end })
  105.     func()
  106.     return captured
  107. end
  108.  
  109. -- Table functions
  110. table.clone = function(t)
  111.     local copy = {}
  112.     for k, v in pairs(t) do
  113.         copy[k] = v
  114.     end
  115.     return copy
  116. end
  117.  
  118. table.freeze = function(tbl, deep) end
  119. function setreadonly() end
  120. function isreadonly(t)
  121.     assert(type(t) == "table", "Expected table")
  122.     return true
  123. end
  124.  
  125. -- Additional Functions
  126. function getnamecallmethod()
  127.     return debug.getinfo(2, "n").name or "__namecall"
  128. end
  129.  
  130. function hookfunction(original, replacement)
  131.     assert(type(original) == "function", "Expected function for original")
  132.     assert(type(replacement) == "function", "Expected function for replacement")
  133.     -- In real environments, hooking logic would go here.
  134.     return original
  135. end
  136.  
  137. debug.setupvalue = function(func, index, value)
  138.     local i = 1
  139.     while true do
  140.         local name = debug.getupvalue(func, i)
  141.         if not name then break end
  142.         if i == index then
  143.             debug.setupvalue(func, i, value)
  144.             return name
  145.         end
  146.         i = i + 1
  147.     end
  148.     return nil
  149. end
  150.  
  151. debug.setstack = function(level, value)
  152.     error("Setting the call stack is not supported in standard Lua", 2)
  153. end
  154.  
  155. debug.setconstant = function(func, index, value)
  156.     error("Setting constants is not supported in standard Lua", 2)
  157. end
  158.  
  159. -- End of Script
  160.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement