Categories > Coding > Lua >
How do you hook metatables with the WRD API?
Posted
There are getrawmetatable() and setrawmetatable() methods in the API, along with setreadonly(). None of these methods appear to work or just cause my client to crash. Is there a specific way to use them? The way they are used in the Synapse documentation does not appear to work with WRD API.
Replied
Just incase someone says "theres no newcclosure" they're stupid
it's a wrapper, all the functions are cclosures.
Anyway this is how:
local mt = getrawmetatable(game)
local backup = mt.__index
setreadonly(mt, false)
mt.__index = newcclosure(function(...) --newcclosure isnt needed here but it would be needed for any other execution method
--do whatever here
return backup(...)
end)
setreadonly(mt, true) --not needed but I like to do it
Cancel
Post
My Discord is xwyvern
https://i.imgur.com/mH521VR.png
Replied
Ran your origional, the block failed with an error:
attempt to call global 'newcclosure' (a nil value)
Removing the newcclosure, it would fail to run the code block upon indexing game (i put a print statement, and then a WRDApi console log)
WRD API simply does not support newcclosure, and as I stated in the question, the usage from Synapse X is inconsistent with WRD API.
Cancel
Post
Replied
@snekerator well deeppain said all funcs on wrappers are cclosures so you could be doing this:
if newcclosure == nil then
getgenv().newcclosure = function(func)
func()
end
end
I am not sure if it works and I might be totally wrong, but maybe it will work?
(add the code b4 ur script)
Cancel
Post
My new discord is Wabz#1337 with ID 777154062789509130
My Discord is xwyvern
https://i.imgur.com/mH521VR.png
My new discord is Wabz#1337 with ID 777154062789509130
Replied
Molly rocks in my green tea
So uh what we talking bout?
Cancel
Post
COME BACK THISNAMENOTGONE
Replied
What you guys think of funny monkey gif?
Cancel
Post
no
Error: The signature must be between 3-200 characters
Users viewing this thread:
( Members: 0, Guests: 1, Total: 1 )
Cancel
Post