Skip to content
On this page

Red

The root of the library.

Functions

Server Server Only Since 1.0.0

Retrieves a server namespace.

lua
(
	Name: string, -- The name of the server namespace.
	EventNames: { string }? -- The names of the events that should be pre-defined.
) -> Server

It should be noted that namespaces are global, you can call this function with the same name multiple times and you will have no issues. If you don't define your events when you create the namespace, any listeners on the client will yield until the server defines the event, which would be when it is first fired.

Simply put, define events that you fire to the client.

lua
local Net = Red.Server("Namespace", { "Event" })

Net:Fire("Event")

WARNING

If called on the client, this function will error.

Client Client Only Since 1.0.0

Retrieves a client namespace.

lua
(
	Name: string -- The name of the client namespace.
) -> Client

Just like with the server, client namespaces are global. You can call this function as many times as you like. Unlike the server, however, you cannot define events on the client.

lua
local Net = Red.Client("Namespace")

Net:On("Event", function()
	print("Hello, World!")
end)

WARNING

If called on the server, this function will error.

Spawn Since 1.0.0

Spawns a new thread with thread reuse.

lua
<T...>(
	fn: (T...) -> (), -- The function to spawn.
	...: T... -- The arguments to pass to the function.
) -> ()

This function uses thread reuse and task.spawn to spawn threads efficiently.

lua
Red.Spawn(print, "Hello, World!")

Properties

Promise Since 1.0.0

A reference to the Red Promise implementation. This implementation differs from the main library used, it provides autocomplete, it uses PascalCase and has better performance.

lua
Red.Promise.new(function(Resolve, Reject)
	Resolve("Hello, World")
end):Then(print)

Signal Since 1.0.0

A reference to the Red Signal implementation. This implementation is almost identical to other implementations, it just uses the Red Promise implementation, and is also typesafe.

lua
local Signal = Red.Signal.new()

Signal:Connect(print)
Signal:Fire("Hello, World")

Clock Since 1.0.0

A reference to the Clock object. This object is used to run a callback at consistent intervals.

lua
local Clock = Red.Clock.new(1, function()
	print("Hello, World!")
end)