Some functions i spent time on, that will be added to Extended API
Returns the script that called the function. This may not always work, look at the code inside getcallingscript.lua
to know its limitations.
Example:
local userdata = newproxy(true)
getmetatable(userdata).__index = function(self, key)
if key == "KeyThatPrints" then
print(tostring(getcallingscript()) .. " has the key that prints.")
end
end
local access = userdata.KeyThatPrints --> Output: "(script name) has the key that prints."
Returns the name of the invoked __namecall
method. If no method name is found, it will return "__namecall"
.
Example:
local userdata = newproxy(true)
getmetatable(userdata).__namecall = function(self, ...)
print("__namecall method: " .. tostring(getnamecallmethod()))
end
userdata:HelloWorld() --> Output: "__namecall method: HelloWorld"
Returns true
if the caller is the original, otherwise returns false
Example:
local userdata = newproxy(true)
getmetatable(userdata).__index = function(self, key)
print("is the original caller? " .. tostring(checkcaller()))
end
local nothing = userdata.key --> Output: "is the original caller? true"
Hooks a metamethod in a metatable.
Example:
local old
old = hookmetamethod(game, "__index", function(self, key)
if key == "NotAllowed" then
return -- Return nothing.
end
return old(self, key)
end)
print(game.NotAllowed) -- Output: "nil"
Please note that it should not be implemented as the following example:
local hookmetamethod = function(first, metamethod, func)
local mt = getrawmetatable(first)
setreadonly(mt, false)
local old = mt[metamethod]
mt[metamethod] = func
return old
end
It should be implemented with actual hooking, since the game can access the original __index
(before changes, after it is changed you can't anymore) with this method:
local __Index
xpcall(function()
return game[{}]
end, function()
__Index = debug.info(2, "f")
end)
-- Now they can do whatever they want with the function
local _workspace = __Index(game, "Workspace")
-- Also with
local __newIndex
xpcall(function()
game[{}] = {}
end, function()
__newIndex = debug.info(2, "f")
end)
-- Now they can do this:
__newIndex(workspace.Baseplate, "Parent", nil)
5. gethiddenproperty
Gets a hidden property from an instance, and returns if the property was hidden or not.
Parameters:
- Instance
- Property
gethiddenproperty(instance, property)
Example:
local Motor6D = Instance.new("Motor6D")
print(gethiddenproperty(Motor6D, "ReplicateCurrentOffset6D")) -- Outputs "0, 0, 0 true"
Function used for getting a Fast Flag's (FFlag) value.
Parameters:
- FFlag (String)
Example:
print(getfflag("FFlagDisablePostFx")) -- Outputs "false" by default
Function used for setting a Fast Flag's (FFlag) value.
Parameters:
- FFlag (String)
- Value
Example:
setfflag("FFlagDisablePostFx", true)