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

Are the RbxLibraries modules, and is LoadLibrary like require?

This should be a pretty simple question to those who know, but i ask this because i can return their individual environments with getfenv. So, is LoadLibrary like saying require?

Comparison:

Module:

local t = {}

a = 1
b = 2

t.test = function() end

return t

Script:

-- This script is inside the module script

local env = getfenv(require(script.Parent).test)
table.foreach(env,print)

-- Output --

-- a 1
-- b 2
-- script ModuleScript

And the same effect happens with LoadLibrary:

table.foreach(getfenv(LoadLibrary'RbxUtility'.Help),print)

-- Output --

-- Encode function
-- Decode function
-- Null function

So, that's pretty much it. It just seems to me that LoadLibrary is like another way of saying require, except it's parameter is limited to the string value of all it's library names.

3 comments

0

By that logic you could say that libraries and modules are remotely the same thing. It's just that in RBX Lua, we make modules, and the libraries are already there for us.

0

So they're just built-in modules?

0

I guess so, but I'm not an expert on how RBX Lua is structured. BlueTaslem, where are you?

1 answer

✓ Accepted answer

Long ago in a ROBLOX without require, there was LoadLibrary.

This was a global function that allowed us to import a few whitelisted libraries that ROBLOX provided. Almost all of their functions have by now been fully replaced with official implementations.

The end.

4 comments

1

NICE STORY O:

2

i cried a little :')

1

toon give me a tissue

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