Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question and what's the purpose of Empty() #19

Open
karl-police opened this issue Mar 18, 2024 · 1 comment
Open

Question and what's the purpose of Empty() #19

karl-police opened this issue Mar 18, 2024 · 1 comment

Comments

@karl-police
Copy link

karl-police commented Mar 18, 2024

idk, someone that I know told me to look at stuff, then I found this

no clue what this all is but once I saw the name "PseudoInstance", I immediately took a look at it, but already walked away when I saw that it uses all the Libraries that Roblox uses, e.g. Janitor and the entire _Index thing. (I wish I'd know how people even find these things, I feel like they all got this told from a Roblox Staff themselves)

Eitherways.

What's the purpose, of this:

local function Empty() end

Is this part of the magic like these mysterious libraries that just appear in stuff like DataStore Editor Plugin and etc. and NevermoreEngine, like... who advertised these libraries, how did people end up using it, and why is there a reference of node-js in Lua.

@karl-police karl-police changed the title Question Question and what's the purpose of Empty() Mar 18, 2024
@Validark
Copy link
Member

Well, I can tell you how I found out about Janitor. I created it as an alternative to Quenty's "Maid" library. The RoStrap project itself was heavily inspired by NevermoreEngine. Actually it was supposed to be a revision of NevermoreEngine, but things ended up going in a different direction. I found out about NevermoreEngine by searching on GitHub for quality Roblox Lua codebases.

Nowadays, I would encourage you to join the Roblox OSS community: https://discord.gg/ZBaF9xUXcH
You can also find different libraries on the Roblox DevForum: https://devforum.roblox.com/


Empty is used in this part of the file:

Classes/PseudoInstance.lua

Lines 191 to 196 in 75737c7

local Events = ClassData.Events
for i = 1, #Events do
Events[Events[i]] = Empty
Events[i] = nil
end

Other pieces of code want to call a function when an event occurs, so rather than doing:

local callback = Events[event_name]
if callback ~= nil then
    callback()
end

I just guarantee that there is a callable function there so I can do:

Events[event_name]()

When it comes to metamethods, you can read about them here: https://create.roblox.com/docs/luau/metatables

Luau is also open-source, so you could read the source code if desired: https://github.com/luau-lang/luau
Back in the day, I did read the Lua source code to learn how things work, but I also probed at Roblox's implementation with things like:

local Userdata = newproxy(true)

setmetatable(getmetatable(Userdata), {
    __index = function(_, i)
        error("Cannot access " .. i)
    end
})

typeof(Userdata)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants