RbxLibrary: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>JulienDethurens
Syntax highlighting.
>JulienDethurens
No edit summary
Line 9: Line 9:
To find out what methods are in the library, you can first check for documentation on the wiki, or search the forums. If they both come up with nothing, you'll probably need to do lots of experimenting. Here's some base code to use:
To find out what methods are in the library, you can first check for documentation on the wiki, or search the forums. If they both come up with nothing, you'll probably need to do lots of experimenting. Here's some base code to use:
<code lua>
<code lua>
LoadLibrary("RbxGui")
assert(LoadLibrary('RbxGui'))
</code>
</code>
That loads the contents of [[RbxGui]], a library. However, we need to store it in a [[variable]].
That loads the contents of [[RbxGui]], a library. However, we need to store it in a [[variable]].
<code lua>
<code lua>
local RbxGui = LoadLibrary("RbxGui")
local RbxGui = assert(LoadLibrary("RbxGui"))
</code>
</code>
Now, to see the contents, we can use a simple loop, with the handy GetApi method:
Now, to see the contents, we can use a simple loop, with the handy GetApi method:
<code lua>
<code lua>
for key, val in pairs(RbxGui:GetApi()) do
for _, val in pairs(RbxGui:GetApi()) do
     print(key .. " = " .. val)
     print(val)
end
end
</code>
</code>
That will print pretty much everything in the table out for us, so we know at least what there is in there.
That will print everything in the table out for us, so we know at least what there is in there.
 
Then, we can find how to use the functions that are in the library using the Help function. All the libraries have an Help function that lets us know how to use the functions it contains. Let's try with the CreateSlider function:
 
<code lua>
local RbxGui = assert(LoadLibrary('RbxGui'))
print(RbxGui.Help("CreateSlider"))
</code>
 
This will print some informations about how to use the function in the output.


== What libraries currently exist? ==
== What libraries currently exist? ==
*[[RbxGui]]
*[[RbxGui]]
<!--*[[RbxGear]] (This library is under development and currently only contains properties that seem to've been used to test libraries.)-->
*[[RbxUtility]]
*[[RbxUtility]]
*[[RbxStatus]]
*[[RbxStatus]]
*[[RbxGear]]
*[[RbxGear]]

Revision as of 03:43, 19 January 2012

Stub icon Stub
This article is a stub. If you think you know more about this than we do, please help us by contacting a writer.
Thank you!


What is a library?

In Roblox, the term library doesn't mean "an educational, academical place to gain informational knowledge." Rather, libraries in Roblox are simply extensions of the API, which include developer-created Lua code which can be included in any script with ease.

How do I use a library?

To find out what methods are in the library, you can first check for documentation on the wiki, or search the forums. If they both come up with nothing, you'll probably need to do lots of experimenting. Here's some base code to use: assert(LoadLibrary('RbxGui')) That loads the contents of RbxGui, a library. However, we need to store it in a variable. local RbxGui = assert(LoadLibrary("RbxGui")) Now, to see the contents, we can use a simple loop, with the handy GetApi method: for _, val in pairs(RbxGui:GetApi()) do

   print(val)

end That will print everything in the table out for us, so we know at least what there is in there.

Then, we can find how to use the functions that are in the library using the Help function. All the libraries have an Help function that lets us know how to use the functions it contains. Let's try with the CreateSlider function:

local RbxGui = assert(LoadLibrary('RbxGui')) print(RbxGui.Help("CreateSlider"))

This will print some informations about how to use the function in the output.

What libraries currently exist?