Libraries+, a library extension module

I got a chance to check some of it out.

WaitForChildOfClass = function(instance, class_name, timeout) -- Wait for a child of class
	if type(timeout) == "number" then
		wait(timeout)
		return instance:FindFirstChildOfClass(class_name)
	end
	while not instance:FindFirstChildOfClass(class_name) do
		instance.ChildAdded:Wait()
	end
	return instance:FindFirstChildOfClass(class_name)
end

This isn’t the intended functionality of ‘WaitForChild’. If given a Timeout, this will simply stall the entire time duration (ignoring any instances created in the intermission) and then spit-out an already existing Instance that fits the criteria. Check out this post on how you may actually implement this correctly. (Of course, substituting the now deprecated RbxUtility signal for a BindableEvent.)

1 Like

Update

_M no longer forces library injection.

Now how it should be used is

local import = require(_M)

And you can import the specific libraries you want, e.g.

import("table")

will import the table extensions.

It can be called with multiple arguments, so

import("table", "math", "string") 

Gives that python feeling.

That will import the extensions for table, math and string.

using has been changed to import. All of this is now documented in the OP!

@EpicMetatableMoment the module now contains submodules and it should be easier now!

@AskWisp The function has been implemented correctly now!

2 Likes

Good Work!

This looks much cleaner!

image

Other things you could change:

  • Type Checking
  • Update Math Functions
  • Update Color3 Functions
  • Update Incapaz Specials

Type Checking:

Add type checking with the new lua demo? (Of course if you do this please create a separate version of the module as the type checking is not enabled on the server / client)

Update Math Functions

I still see no math.cosecant and math.cotangent, also a math.nroot would be nice; easily implementable via (replace the 3 with n):

On the note of Brendan’s post, you should update the math.cbrt to use his (in my opinion) cleaner method of doing this.

Update Color3 Functions

This is assuming people use Color3.fromRGB rather than Color3.new (in which case Color3.new is being used by the function internally, perhaps change this to ValueError: new RGB component is over 1) or alternatively just use clamp and not spit an error?.

Update Incapaz Specials

Perhaps use a quick variable for _M.printf?

_M.printf = function(s, ...) -- C's printf
    print(s:format(...))

    return #s:format(...)
end

The extra s:format(...) is not needed and could be removed with a simple variable declaration.

Overall, very cool!

image

2 Likes

incapaz_specials formatting was fixed.

I will be making a separate project that doesn’t do any library injection that uses the “classic” way of requiring in the future which will use typed Lua once it is ready. It’s been really unstable rn and so many bugs. Like I can’t even use ipairs(table.pack(...)) without it complaining I need to call it as a method with the : and that the types mismatch.

let me be honest here bro i don’t know anything about math. A friend was using Lua for his math homework or something and he asked if there was a way to use secant. And I asked “what is the formula” and he said it was 1/cos(n) so I made a function that easily did that.

But I did add that root function. Should I remove cbrt since root is added?

2 Likes

No, you don’t need to remove the cbrt function.

Also, cosecant, secant, and cotangent are just the reciprocal of their respective counterparts.

cosecant (csc) = 1 / sin(x)
secant (sec) = 1 / cos(x)
cotangent (cot) = 1 / tan(x)

Yes, type checking currently is pretty botched. That is why I suggested a separate module / project for it because it is annoying to work with for one, and two it is not enabled ingame.

1 Like

Hey! I wanted to share something that I’ve been working on for some time. I forked Libraries+ (before the update you just released, and it is up-to-date). If you are interested, I can share what I added.

1 Like

Here is the link to the Libraries+ fork. I added some functions to it. I did move some functions around (such as pathtostring is now in Rbx_Instance, etc.)

I added Roblox-created libraries, such as Symbol, and cryo.

I changed the main module to be a table with a __call metamethod. I added a function called GetLibraries which gets the Libraries without importing (there’s also the __index metamethod doing its own stuff with retrieving libraries)

It’s probably not much, but here it is:
https://www.roblox.com/library/4557280035/LibPlus-Fork

4 Likes