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

Are the RbxLibraries modules, and is LoadLibrary like require?

Asked by
LuaQuest 450 Moderation Voter
9 years ago

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.

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. funyun 958 — 9y
0
So they're just built-in modules? LuaQuest 450 — 9y
0
I guess so, but I'm not an expert on how RBX Lua is structured. BlueTaslem, where are you? funyun 958 — 9y

1 answer

Log in to vote
5
Answered by
Unclear 1776 Moderation Voter
9 years ago

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.

Ad

Answer this question