Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug.getregistry fix inside includes/init.lua #19

Open
Yogpod opened this issue Jan 12, 2024 · 0 comments
Open

debug.getregistry fix inside includes/init.lua #19

Yogpod opened this issue Jan 12, 2024 · 0 comments
Assignees

Comments

@Yogpod
Copy link

Yogpod commented Jan 12, 2024

i'm sure you knew but rubat destroyed debug.getregistry, and appended a temporary fix to includes/init.lua

Here's my version of the fix, and below that is his version.

local _R

OldFindMetaTable = OldFindMetaTable or FindMetaTable
function FindMetaTable(name)
	return name and _R[name] or nil
end

do
	_R = setmetatable({
		[1] = function() end,
		[2] = _G,
		[3] = {},
	}, {
		__index = function(obj, key)
			local tab = key and oldFindMetaTable(key)
			if rawget(obj, key) then
				return rawget(obj, key)
			elseif tab then
				obj[key] = tab
				return tab
			else
				return nil
			end
		end
	})
end

function debug.getregistry()
	return _R
end
-- Temporary hack
local meta = {}
function meta.__index(self, key)
	return FindMetaTable(key)
end

local metas = {}
function meta.__newindex(self, key, value)
	metas[ key ] = value
end

debug.getregistry = function()
	local tbl = {}
	setmetatable(tbl, meta)

	return tbl
end

local oldFindMetaTable = FindMetaTable
FindMetaTable = function( name )
	local f = oldFindMetaTable( name )
	if ( f ) then return f end

	return metas[ name ]
end
@Yogpod Yogpod changed the title debug.getregistry changes debug.getregistry fix inside includes/init.lua Jan 12, 2024
@danielga danielga self-assigned this Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants