### Install Dependencies Source: https://github.com/1axen/blink/blob/main/docs/README.md Run this command to install project dependencies before starting local development. ```bash pnpm i ``` -------------------------------- ### Start Development Server Source: https://github.com/1axen/blink/blob/main/docs/README.md Run this command to start the local development server. Visit localhost:3000 to view the documentation. ```bash pnpm dev ``` -------------------------------- ### Install Blink with pesde Source: https://github.com/1axen/blink/blob/main/docs/pages/getting-started/1-installation.mdx Install Blink using pesde, a package manager. Ensure you run both commands. ```bash pesde add --dev 1axen/blink pesde install ``` -------------------------------- ### Example Map Usage Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Defines a map where keys are f64 and values are strings. ```blink map UserIdToUsername = { [f64]: string } ``` -------------------------------- ### Install Blink with Rokit Source: https://github.com/1axen/blink/blob/main/docs/pages/getting-started/1-installation.mdx Use this command to add Blink to your project via Rokit. ```bash rokit add 1Axen/blink ``` -------------------------------- ### Struct Merging Example Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Demonstrates merging two structs, foo and bar, into a new struct foo_bar. ```blink struct foo { foo: u8 } struct bar { bar: string } struct foo_bar { ..foo, ..bar } ``` -------------------------------- ### Listen to Events in Luau Source: https://github.com/1axen/blink/blob/main/docs/pages/language/5-events.mdx Shows how to register listeners for events in Luau. Includes examples for both simple events and events with type packs, as well as how to capture the disconnect function for cleanup. ```lua blink.MyEvent.On(function(Value) -- ... end) blink.MyTypePackEvent.On(function(Foo, Bar, FooBar) -- ... end) ``` ```lua blink.MyEvent.On(function(Player, Value) -- ... end) blink.MyTypePackEvent.On(function(Player, Foo, Bar, FooBar) -- ... end) ``` ```lua local Disconnect = blink.MyEvent.On(...) Disconnect() ``` -------------------------------- ### Example Vector Type Definitions Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Demonstrates defining a default vector type, a unit vector with a range, and a vector with u8 encoding. ```blink type Position = vector type UnitVector = vector(0..1) type VectorU8 = vector ``` -------------------------------- ### Example Bounded Array Usage Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Defines a type for an array of f64 numbers, bounded to have between 1 and 50 elements. ```blink type UserIds = f64[1..50] ``` -------------------------------- ### Example String Type Definitions Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Shows how to define custom string types for UUID (exactly 36 characters) and Username (3 to 20 characters). This helps ensure data conforms to expected formats. ```blink type UUID = string(36) type Username = string(3..20) ``` -------------------------------- ### Using Exported Types in Luau Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Example of how to use the exported Blink type 'MyInterface' in a Luau script for serialization and deserialization. ```lua local Serialized = blink.MyInterface.Write(MyInterface) local Deserialized = blink.MyInterface.Read(Serialized) ``` -------------------------------- ### Example Buffer Type Definitions Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Illustrates defining custom buffer types for BinaryBlob (unbounded) and UnreliableEventBuffer (up to 950 bytes). This allows for custom data serialization with size constraints. ```blink type BinaryBlob = buffer type UnreliableEventBuffer = buffer(..950) ``` -------------------------------- ### Example Number Type Definitions Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Illustrates defining custom types for Health (bounded u8) and UserId (f64). Use custom types to improve code readability and enforce constraints. ```blink type Health = u8(0..100) type UserId = f64 ``` -------------------------------- ### Invoke Blink Function with Promise Source: https://github.com/1axen/blink/blob/main/docs/pages/language/6-functions.mdx Invokes 'MyFunction' from the client using the promise yield type. The 'Invoke' method returns a promise object that can be awaited to get the return value. ```lua local Promise = blink.MyFunction.Invoke(5) local Value = Promise:await() ``` -------------------------------- ### Invoke Blink Function with Future Source: https://github.com/1axen/blink/blob/main/docs/pages/language/6-functions.mdx Invokes 'MyFunction' from the client using the future yield type. The 'Invoke' method returns a future object that can be awaited to get the return value. ```lua local Future = blink.MyFunction.Invoke(5) local Value = Future:Await() ``` -------------------------------- ### Importing Blink Files Source: https://github.com/1axen/blink/blob/main/docs/pages/language/3-imports.mdx Demonstrates how to import other Blink files using direct paths and aliasing with the 'as' keyword. Imported files create new scopes. ```blink import "./external" import "./external" as "Common" type ExternType = external.Type type CommonType = Common.Type ``` -------------------------------- ### Basic Option Syntax Source: https://github.com/1axen/blink/blob/main/docs/pages/language/1-options.mdx Illustrates the fundamental syntax for setting options in Blink. ```blink option [OPTION] = [VALUE] ``` -------------------------------- ### Listen to Blink Function on Server Source: https://github.com/1axen/blink/blob/main/docs/pages/language/6-functions.mdx Sets up a listener on the server for 'MyFunction'. The provided callback function receives the player and any data sent by the client, and returns a value to the client. ```lua blink.MyFunction.On(function(Player, Value) return Value * 2 end) ``` -------------------------------- ### Specify Output Paths Source: https://github.com/1axen/blink/blob/main/docs/pages/language/1-options.mdx Defines the output file paths for generated types, server, and client code. Ensure paths are correctly specified. ```blink option TypesOutput = "../Network/Types.luau" option ServerOutput = "../Network/Server.luau" option ClientOutput = "../Network/Client.luau" ``` -------------------------------- ### Compile a Blink Description File Source: https://github.com/1axen/blink/blob/main/docs/pages/getting-started/3-cli.mdx Use this command to compile a Blink description file. The CLI will look for files with .blink or .txt extensions in the current directory. ```sh blink file-name ``` -------------------------------- ### Define String Array Type Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Illustrates the basic syntax for defining an array of strings. ```blink string[] ``` -------------------------------- ### Compile Blink Network Description Source: https://github.com/1axen/blink/blob/main/docs/pages/getting-started/2-introduction.mdx Use this command in your terminal to compile your Blink network description file into Luau code. ```sh blink FILE_NAME ``` -------------------------------- ### Using Imported Scopes in Luau Source: https://github.com/1axen/blink/blob/main/docs/pages/language/3-imports.mdx Shows how to access imported modules and their types within Luau code, leveraging the scopes created by Blink imports. ```lua local Blink = require(PATH_TO_BLINK) Blink.external.Event.FireAll(0) local Number: Blink.Common_Type = 0 ``` -------------------------------- ### Set Casing Option Source: https://github.com/1axen/blink/blob/main/docs/pages/language/1-options.mdx Configures the casing style for generated event and function methods. Use Pascal, Camel, or Snake. ```blink option Casing = Camel ``` -------------------------------- ### Define Generic Map Template and Usage Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Defines a generic map template and then instantiates it for string keys and f64 values. ```blink map Map = {[K]: V} map StringToNumber = Map ``` -------------------------------- ### Enable TypeScript Definitions Source: https://github.com/1axen/blink/blob/main/docs/pages/language/1-options.mdx Enables the generation of TypeScript definition files (.d.ts) alongside Luau files. These files are placed in the same directory as the output files. ```blink option Typescript = true ``` -------------------------------- ### Define a Scope and its Members Source: https://github.com/1axen/blink/blob/main/docs/pages/language/2-scopes.mdx Define a scope named 'ExampleScope' containing a type 'InScopeType' and an event 'InScopeEvent'. This demonstrates how to group related definitions within a scope. ```blink scope ExampleScope { type InScopeType = u8 event InScopeEvent { From: Server, Type: Reliable, Call: SingleSync, Data: u8 } } struct Example { Reference = ExampleScope.InScopeType } ``` -------------------------------- ### Define a Network Event Source: https://github.com/1axen/blink/blob/main/docs/pages/getting-started/2-introduction.mdx This snippet shows how to define a network event named 'MyFirstEvent' with a string data type. It includes optional output paths for client and server code generation. ```blink -- these can be ignored if you are using the studio plugin option ClientOutput = "path/to/client.luau" option ServerOutput = "path/to/server.luau" event MyFirstEvent { from: Server, type: Reliable, call: SingleSync, data: string } ``` -------------------------------- ### Define Optional String Type Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Shows how to make a string type optional by appending a question mark. ```blink type Username = string(3..20)? ``` -------------------------------- ### Specify Future and Promise Libraries Source: https://github.com/1axen/blink/blob/main/docs/pages/language/1-options.mdx Provides paths to libraries used for future and promise yield types within functions. This is required for using these yield types. ```blink option FutureLibrary = "ReplicatedStorage.Packages.Future" option PromiseLibrary = "ReplicatedStorage.Packages.Promise" ``` -------------------------------- ### Define a Simple Event Source: https://github.com/1axen/blink/blob/main/docs/pages/language/5-events.mdx Define a reliable event named MyEvent that can be fired from the server and expects a single asynchronous listener. It sends a 64-bit floating-point number as data. ```blink event MyEvent { From: Server, Type: Reliable, Call: SingleAsync, Data: f64 } ``` -------------------------------- ### Using Scoped Definitions in Luau Source: https://github.com/1axen/blink/blob/main/docs/pages/language/2-scopes.mdx Shows how to interact with Blink scopes and their members from Luau code. Access scoped events and types via the nested table structure provided by the Blink runtime. ```lua local Blink = require(PATH_TO_BLINK) Blink.ExampleScope.InScopeEvent.FireAll(0) local Number: Blink.ExampleScope_InScopeType = 0 ``` -------------------------------- ### Update Blink with Rokit Source: https://github.com/1axen/blink/blob/main/docs/pages/getting-started/1-installation.mdx Use this command to update Blink to the latest version via Rokit. ```bash rokit update 1Axen/blink ``` -------------------------------- ### Listen for a Network Event on the Client Source: https://github.com/1axen/blink/blob/main/docs/pages/getting-started/2-introduction.mdx This Luau code shows how to use the generated Blink code on the client to listen for and handle a network event. Ensure you have required the correct client module. ```lua local Net = require(Path.To.Client) Net.MyFirstEvent.On(function(Text) print(Text) end) ``` -------------------------------- ### Enable Polling API Source: https://github.com/1axen/blink/blob/main/docs/pages/language/1-options.mdx Instructs the Blink compiler to automatically generate all events with a polling API. ```blink option UsePolling = true ``` -------------------------------- ### Fire Events from Client and Server Source: https://github.com/1axen/blink/blob/main/docs/pages/language/5-events.mdx Demonstrates how to fire events from both the client and server sides in Luau. The client fires MyEvent and MyTypePackEvent, while the server shows various methods for firing MyEvent to specific targets or all clients. ```lua blink.MyEvent.Fire(5) blink.MyTypePackEvent.Fire(2^8 - 1, 2^16 - 1, 2^32 - 1) ``` ```lua blink.MyEvent.Fire(Player, 5) blink.MyEvent.FireAll(5) blink.MyEvent.FireList({Player}, 5) blink.MyEvent.FireExcept(Player, 5) ``` -------------------------------- ### Define Map Type Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Defines a map with string keys and f64 values. ```blink map StringToNumber = { [string]: f64 } ``` -------------------------------- ### Specifying Instance Class Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Defines a type alias 'Player' for instances of the Player class. Subclasses are also accepted. ```blink type Player = Instance(Player) ``` -------------------------------- ### Control Manual Replication Source: https://github.com/1axen/blink/blob/main/docs/pages/language/1-options.mdx Manages automatic replication of events and functions. When true, automatic replication is disabled, and a StepReplication function is exposed. ```blink option ManualReplication = false ``` -------------------------------- ### Scope Capturing Parent Scope Definitions Source: https://github.com/1axen/blink/blob/main/docs/pages/language/2-scopes.mdx Demonstrates how a scope automatically captures definitions from its parent scope. 'Inner' type within 'CaptureExample' scope references 'Outer' type from the parent scope. ```blink type Outer = u8 scope CaptureExample { type Inner = Outer } ``` -------------------------------- ### Using the Unknown Type Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Represents values that are not known until runtime. Use sparingly as it bypasses many Blink benefits. ```blink type AnInstance = Instance ``` -------------------------------- ### Fire a Network Event on the Server Source: https://github.com/1axen/blink/blob/main/docs/pages/getting-started/2-introduction.mdx This Luau code demonstrates how to use the generated Blink code on the server to fire a network event. Ensure you have required the correct server module. ```lua local Net = require(Path.To.Server) Net.MyFirstEvent.FireAll("Hello World") ``` -------------------------------- ### Tagged Enum for Union Type Simulation Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Demonstrates simulating a union type using a tagged enum, with Number and String variants. ```blink enum Union = "Type" { Number { Value: f64 }, String { Value: string } } ``` -------------------------------- ### Bounding String Length Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Defines a string type that must be between 3 and 20 characters long. Use this to enforce minimum and maximum length requirements for text data. ```blink string(3..20) ``` -------------------------------- ### Watch for Changes and Recompile Automatically Source: https://github.com/1axen/blink/blob/main/docs/pages/getting-started/3-cli.mdx Enable watch mode to automatically recompile the target file and its imports whenever changes are detected. This is useful for rapid development. ```sh blink file-name --watch ``` -------------------------------- ### Define Set Type Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Defines a set named Flags with three static string keys: FeatureA, FeatureB, and FeatureC. ```blink set Flags = { FeatureA, FeatureB, FeatureC } ``` -------------------------------- ### Define an Event with a Type Pack Source: https://github.com/1axen/blink/blob/main/docs/pages/language/5-events.mdx Define an event named MyTypePackEvent that sends multiple data values (u8, u16, u32) using a type pack. It is fired from the server and uses a single asynchronous listener. ```blink event MyTypePackEvent { From: Server, Type: Reliable, Call: SingleAsync, Data: (u8, u16, u32) } ``` -------------------------------- ### Luau Facing API for Exports Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Shows the generated Luau types for reading and writing the exported 'MyInterface' struct. ```lua type MyInterfaceExport = { Read: (buffer) -> MyInterface, Write: (MyInterface) -> buffer } ``` -------------------------------- ### Bounding Buffer Size Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Defines a buffer type with a maximum size of 900 bytes. Use this to limit the amount of custom serialized data that can be transmitted. ```blink buffer(..900) ``` -------------------------------- ### Define Generic Tagged Enum Template and Usage Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Defines a generic tagged enum template for two types A and B, and then instantiates it for f64 and string. ```blink enum Union = "Type" { A { Value: A }, B { Value: B }, } enum NumberStringUnion = Union ``` -------------------------------- ### Set Remote Scope Prefix Source: https://github.com/1axen/blink/blob/main/docs/pages/language/1-options.mdx Adds a prefix to generated events, useful for isolating Blink instances within packages. If not specified, default names are used. ```blink option RemoteScope = "PACKAGE" ``` -------------------------------- ### Define a Blink Function Source: https://github.com/1axen/blink/blob/main/docs/pages/language/6-functions.mdx Defines a function named 'MyFunction' with specified yield, data, and return types. Use 'Coroutine' for the builtin Luau coroutine library, 'Future' for a user-provided future library, or 'Promise' for a user-provided promise library. ```blink function MyFunction { Yield: Coroutine, Data: f64, Return: f64 } ``` -------------------------------- ### Iterate Polling Events in Luau Source: https://github.com/1axen/blink/blob/main/docs/pages/language/5-events.mdx Demonstrates how to use the `Iter()` method to poll for events in Luau. This is applicable for events configured with the 'Polling' Call type. ```lua for Index, Value in MyEvent.Iter() do -- ... end for Index, Foo, Bar, FooBar in MyTypePackEvent.Iter() do -- ... end ``` ```lua for Index, Player, Value in MyEvent.Iter() do -- ... end for Index, Player, Foo, Bar, FooBar in MyTypePackEvent.Iter() do -- ... end ``` -------------------------------- ### Define Bounded Map Type Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Defines a map with string keys and f64 values, with a size constraint between 1 and 100 elements. ```blink map StringToNumber = { [string]: f64 }(1..100) ``` -------------------------------- ### Define Struct Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Defines a struct named Entity with fields for Health, Position, Rotation, and nested Animations. ```blink struct Entity { Health: u8(0..100), Position: vector, Rotation: u8, Animations: struct { First: u8?, Second: u8, Third: u8 } } ``` -------------------------------- ### Bounding Unsigned Integer Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Defines an unsigned 8-bit integer type with a maximum value of 100. Use this for values that must be non-negative and within a specific upper limit. ```blink u8(0..100) u8(..100) ``` -------------------------------- ### Exporting a Struct Definition Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Defines an exported struct 'MyInterface' with a single 'field' of type u8. Exports enable integration with Luau. ```blink export struct MyInterface = { field: u8, } ``` -------------------------------- ### Define Bounded Array Type Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Defines an array of strings with a specific length constraint between 25 and 50 elements. ```blink string[25..50] ``` -------------------------------- ### Defining a CFrame Type Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Defines a type alias 'Location' for the CFrame type, representing a point and rotation in 3D space. ```blink type Location = CFrame ``` -------------------------------- ### Generic Struct Definition Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Define a generic struct 'Fragment' that can hold data of any type 'T'. This allows for reusable data structures. ```blink struct Fragment { Index: u8, Sequence: u16, Fragments: u8, Data: T } type EntitiesFragment = Fragment ``` -------------------------------- ### Merged Struct Type in Luau Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Shows the equivalent Luau type definition for the Blink struct foo_bar after merging. ```lua type foo_bar = { foo: number, bar: string } ``` -------------------------------- ### Control Sync Validation Source: https://github.com/1axen/blink/blob/main/docs/pages/language/1-options.mdx Determines whether Blink checks if a sync call yielded. Defaults to true. ```blink option SyncValidation = true ``` -------------------------------- ### Tagged Enum Union Type in Luau Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Shows the equivalent Luau type definition for the Blink tagged enum simulating a union. ```lua type Union = | {Type: "Number", Value: number} | {Type: "String", Value: string} ``` -------------------------------- ### Define Unit Enum Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Defines a unit enum named CharacterStatus with possible values Idling, Walking, Running, Jumping, and Falling. ```blink enum CharacterStatus = { Idling, Walking, Running, Falling } ``` -------------------------------- ### Control Write Validations Source: https://github.com/1axen/blink/blob/main/docs/pages/language/1-options.mdx Enables or disables type checking when writing types (firing events/invoking functions). Useful for debugging but may impact performance. Recommended to disable in production. ```blink option WriteValidations = false ``` -------------------------------- ### Specifying CFrame Encoding Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Defines a custom CFrame type 'MyCFrame' with specific numerical types for positional (i16) and rotational (f16) encoding. ```blink type MyCFrame = CFrame ``` -------------------------------- ### Invoke Blink Function with Coroutine Source: https://github.com/1axen/blink/blob/main/docs/pages/language/6-functions.mdx Invokes 'MyFunction' from the client using the coroutine yield type. The 'Invoke' method sends data to the server and waits for a return value. ```lua local Value = blink.MyFunction.Invoke(5) ``` -------------------------------- ### Define Vector with i16 Encoding Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Defines a vector type that specifically uses i16 for encoding. ```blink type VectorI16 = vector ``` -------------------------------- ### Bounding Vector Magnitude Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Defines a vector type with a magnitude (length) between 0 and 1. This is useful for representing unit vectors or normalized directions. ```blink vector(0..1) ``` -------------------------------- ### Define Tagged Enum Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Defines a tagged enum for MouseEvent with variants Move, Drag, and Click, each carrying specific data. ```blink enum MouseEvent = "Type" { Move { Delta: vector, Position: vector, }, Drag { Delta: vector, Position: vector, }, Click { Button: enum { Left, Right, Middle }, Position: vector } } ``` -------------------------------- ### Boolean Type Definition Source: https://github.com/1axen/blink/blob/main/docs/pages/language/4-types.mdx Defines a boolean type, which can only hold 'true' or 'false' values. Use this for flags or status indicators. ```blink type Success = boolean ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.