Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by
KoreanBBQ 301 Moderation Voter
8 years ago

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

Log in to vote
3
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
8 years ago

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

0
Ah well that's sad. ROBLOX should make them somehow available, could allow developers to make enhanced Methods, idk. KoreanBBQ 301 — 8y
0
They won't help -- they're written in C++, and you can't write C++. BlueTaslem 18071 — 8y
Ad
Log in to vote
-3
Answered by 8 years ago

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

0
He's asking for the source code used to create the methods. funyun 958 — 8y

Answer this question