Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is there a way to access built-in methods source?

Let's say I want to know exactly what the function FindPartOnRay() does, or :FindFirstChild() or whatever, is there a place where I can get exactly the source?

for FFC() it says it in the wiki, but not for the others .-.

2 answers

✓ Accepted answer

Short answer: No.


Long answer: Sort of, but no.

Lua functions are compiled into byte-code when the script first executes. That means the original source is lost. We can see how Lua compiled a particular function using string.dump. Note that you can't usually print it because it will include NULL characters.

function hello()
	local s = "hello"
	for i = 1, #s do
		print(s:sub(1, i))
	end
end

print(string.dump(hello))

If you do a little work to hide the bad characters, you'll get this:

LuaQ   =Workspace.Script   

  A@ ? Á@ `@?E ?Á@ B @ ? \A _ þ ?   hello  ð? print  sub 
                s    (for index)    (for limit)    (for step)    i   

It begins with Lua, then the version number -- Q is ASCII character 51(hex), meaning this is Lua 5.1 code.

Then it gives the location of the script, Workspace.Script. (If you compile with your laptop's Lua it would look like @C:\Users\Blu\Desktop\blah.lua)

There's a bunch of characters strewn throughout that the output doesn't differentiate, but are of course important to Lua.

So, you can sort of get a picture of what happened in hello based on this dump.


Problem: Lua is an embedded language. It's designed to interface with another, lower level language. In ROBLOX's case, this is C++.

Most "built in functions" are implemented in C or C++. This includes the table, string, etc libraries, as well as all of the ROBLOX functions, methods, etc.

If you try to string.dump them, you'll just get the error

unable to dump given function

2 comments

0

Ah well that's sad. ROBLOX should make them somehow available, could allow developers to make enhanced Methods, idk.

0

They won't help -- they're written in C++, and you can't write C++.

in roblox studio, go to the view tab and click on "Object Browser" it shows what everything does in roblox

1 comment

0

He's asking for the source code used to create the methods.

This discussion is preserved as it was. New answers, comments, and votes are closed.