I am trying to add a method to an existing userdata like this, this however game me an error.
local userData = luajava.newInstance("Objects.Block") --creates a userdata from a Java class
userData.newMethod = function()
-- Do stuff
end
I found this example on a site but it doesn't work either
local userData = luajava.newInstance("Objects.Block")
local mt = getmetatable(userData)
mt.__index.newMethod = function()
-- Do stuff
end
is there a working way to add a method/function to an existing userdata from Lua