Skip to content

Instantly share code, notes, and snippets.

@xordspar0
Created February 9, 2020 02:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xordspar0/9f7b87fcb297a6a5e537838750182cad to your computer and use it in GitHub Desktop.
Save xordspar0/9f7b87fcb297a6a5e537838750182cad to your computer and use it in GitHub Desktop.
Minimal test case for weird love.event behavior
function love.handlers.myEvent(t)
print("In my event handler:")
print(getmetatable(t))
print(t.upper)
end
super = {
upper = "hello world"
}
function love.load()
local t = setmetatable({}, {__index = super})
print("My table's metatable:", getmetatable(t))
love.event.push("myEvent", t)
end
-- It prints this:
-- My table's metatable: table: 0x40af88f8
-- In my event handler:
-- nil
-- nil
@xordspar0
Copy link
Author

xordspar0 commented Feb 9, 2020

[20:42] <+slime> love.event.push copies the data you give it to memory in C++, it can't copy functions or metatable information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment