Skip to content

Instantly share code, notes, and snippets.

@raingloom
Last active August 18, 2016 17:47
Show Gist options
  • Save raingloom/f1b06b5d10a068d8abe49ff04be3e42c to your computer and use it in GitHub Desktop.
Save raingloom/f1b06b5d10a068d8abe49ff04be3e42c to your computer and use it in GitHub Desktop.
Mobdebug metamethod tests
local evilmt = { "somevalue" }
---[[
function evilmt:__pairs()
return pairs{"Wrong table :P"}--the output is not what I expected but it is also not correct
--return next,self--for normal output
end--]]
setmetatable( evilmt, evilmt )
while true do
print( evilmt )
end
local evilmt = { "somevalue" }
---[[
function evilmt:__tostring()
error"NO OUTPUT FOR YOU! HAH!"--clears whole stack window and only shows error message
end--]]
setmetatable( evilmt, evilmt )
while true do
print( evilmt )
end
local evilmt = { "somevalue" }
---[[
function evilmt:__tostring()
error( self )--use the fact that `error` can return any value against the debugger
end--]]
setmetatable( evilmt, evilmt )
while true do
print'running'--this line is never executed but there is no error message either
--it executes without problems when ran directly
--but crashes in the debugger
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment