Last active
December 8, 2015 19:42
-
-
Save zorggn/ca59b135c596a780c219 to your computer and use it in GitHub Desktop.
Lua hax #84721365: Calling plain tostring in custom tostring metamethod to get table address.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local t = {} | |
local toString = function(t) | |
local original = getmetatable(t) | |
local modified = {}; for k,v in pairs(original) do modified[k] = v end; modified.__tostring = nil | |
setmetatable(t, modified) | |
local address = tostring(t):sub(8) | |
setmetatable(t, original) | |
return string.format("Identifying table:\n%s\nYep, it's a table.", address) | |
end | |
setmetatable(t,{__tostring = toString}) | |
print(t) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment