### Create Conditional Action with Middleware Source: https://github.com/rimuy/gamejoy/blob/main/README.md Explains how to create actions that are triggered only under specific conditions using `Middleware`. This example shows a middleware that checks if the current time is even, causing the bound action to execute only half the time. ```javascript const timeMiddleware = () => os.time() % 2 === 0; context.Bind(new Middleware("M", timeMiddleware), () => { print("Works half of the time, haha..."); }); ``` -------------------------------- ### Create GameJoy Context with Minimal Options (TypeScript) Source: https://context7.com/rimuy/gamejoy/llms.txt This snippet shows how to instantiate a GameJoy Context using the default configuration. When no options are provided to the Context constructor, all settings utilize their default values, simplifying the setup for basic input management needs. ```typescript import { Context } from "@rbxts/gamejoy"; // Minimal context with defaults const simpleContext = new Context(); // All options use defaults ``` -------------------------------- ### Binding Events to a Context Source: https://github.com/rimuy/gamejoy/blob/main/README.md This snippet shows how to bind custom events to a GameJoy context. It includes examples for `BindEvent` which uses the action queue, and `BindSyncEvent` for immediate execution. Both methods require an event identifier and a callback function, with `BindEvent` also accepting optional parameters for the event. ```javascript context.BindEvent("onCharacterDamaged", CharacterController.Damaged, (oldHealth, health) => { const damage = oldHealth - health; print(`You lost ${damage}HP!`); task.wait(0.3); // The player must wait 0.3 seconds before being able to counter-attack. }); context.BindSyncEvent("onRender", RunService.RenderStepped, (delta) => { print(delta); }); ``` -------------------------------- ### Create and Bind Basic Action in JavaScript Source: https://github.com/rimuy/gamejoy/blob/main/README.md Demonstrates how to create a basic action object with a keybind and bind it to a callback function. It also shows how to bind to the 'onReleased' event for the action. This is useful for simple key presses and releases. ```javascript const action = new Action("Q"); context .Bind(action, () => { print("Q was pressed!"); }) .BindEvent("onReleased", action.Released, () => { print("Q was released!"); }); ``` -------------------------------- ### Create and Bind Configurable Action in JavaScript Source: https://github.com/rimuy/gamejoy/blob/main/README.md Shows how to create an action with configuration options such as repeat count and timing between repeats. This is useful for actions that require multiple presses within a time limit, like running or double-tapping. It binds the action and its release event. ```javascript let isRunning = false; const runAction = new Action("W", { Repeat: 2, Timing: 0.3, }); context .Bind(runAction, () => { isRunning = true; }) .BindEvent("onRunningStopped", runAction.Released, () => { isRunning = false; }); ``` -------------------------------- ### Whitelist Actions with Sync Source: https://github.com/rimuy/gamejoy/blob/main/README.md Demonstrates how to ensure a specific action triggers synchronously, even if other actions are pending, using the `Sync` class. This is useful for actions that need to execute immediately regardless of the current execution state. ```javascript context .Bind("A", () => { task.wait(5); }) .Bind("B", () => print("Needs to wait till A is done...")) .Bind(new Sync("C"), () => { print("Will be executed even if there is already a pending action!"); }); ``` -------------------------------- ### Create and Bind Action with Optional Input in JavaScript Source: https://github.com/rimuy/gamejoy/blob/main/README.md Illustrates how to incorporate an optional input into `Composite`, `Sequence`, and `Unique` actions using the `Optional` class. It shows how to check the active state of an optional input within the action's callback. This allows for flexible input requirements. ```javascript const optional = new Optional("G"); context.Bind(new Composite(["F", optional]), () => { if (optional.IsActive) { print("Do a barrel roll!"); } }); context .Bind(new Sequence(["F", new Optional("G")]), () => { // ... }) .Bind(new Unique(["F", new Optional("G"), "H"]), () => { // ... }); ``` -------------------------------- ### Context - Create and Manage Input Actions Source: https://context7.com/rimuy/gamejoy/llms.txt Demonstrates creating and configuring input contexts in GameJoy. Contexts manage actions, event bindings, and global behaviors like action ghosting and pre-trigger validation. It shows binding simple keys, multiple inputs, and managing actions by checking and unbinding them. ```typescript import { Context, Actions } from "@rbxts/gamejoy"; // Create a context with configuration options const gameplayContext = new Context({ // Limit overlapping actions that share inputs (0 = no limit) ActionGhosting: 1, // Validation check before any action triggers OnBefore: () => !!Player.Character && Player.Character.Humanoid.Health > 0, // Filter by whether game processed the input (undefined = no filter) Process: false, // Execute actions immediately without queuing RunSynchronously: false, }); // Bind a simple action gameplayContext.Bind("F", () => { print("F key pressed!"); }); // Bind action with multiple possible inputs gameplayContext.Bind(["Q", "ButtonX"], () => { print("Q or X button pressed!"); }); // Check if action is bound and remove it const action = new Actions.Action("E"); gameplayContext.Bind(action, () => print("E pressed")); if (gameplayContext.Has(action)) { gameplayContext.Unbind(action); } // Clean up all bindings gameplayContext.UnbindAll(); ``` -------------------------------- ### Creating and Binding Actions in a Context Source: https://github.com/rimuy/gamejoy/blob/main/README.md This code illustrates how to create a new context in GameJoy and bind actions to it. The context can be configured with options like `ActionGhosting`, `OnBefore` checks, `Process` flags, and `RunSynchronously`. Actions are bound using an array of input identifiers and a callback function. ```javascript import { Context } from "@rbxts/gamejoy"; const context = new Context({ /** * Limits the amount of actions that can trigger if those have any raw action in common. * If set to 0, this property will be ignored. (defaults to 0) */ ActionGhosting: 1, /** * Applies a check on every completed action. * If the check fails, the action won't be triggered. (defaults to () => true) */ OnBefore: () => !!Player.Character, /** * Specifies that the action should trigger if gameProcessedEvent matches the setting. * If nothing is passed, the action will trigger independently. (defaults to nil) */ Process: false, /** * Specifies if the actions are going to run synchronously or not. * This will ignore the action queue and resolve the action instantly. (defaults to false) */ RunSynchronously: false, }); context.Bind(["MouseButton1", "ButtonX"], () => { CharacterController.Attack(); }); ``` -------------------------------- ### Create and Bind Sequence Action in JavaScript Source: https://github.com/rimuy/gamejoy/blob/main/README.md Demonstrates using the `Sequence` class to create an action that requires child actions to be pressed in a specific order. It also covers binding to the `Cancelled` event for sequences and notes that sequences are cancellable. This is useful for ordered input commands. ```javascript context.Bind(new Sequence(["LeftAlt", "E"]), () => { print("Yay"); }); context.BindEvent("onCancel", sequence.Cancelled, () => { print("Composite was cancelled."); }); ``` -------------------------------- ### Context Configuration Source: https://context7.com/rimuy/gamejoy/llms.txt Configure how actions are triggered, queued, and filtered within a specific game context. This includes settings for action ghosting, global pre-action validation, input processing state, and synchronous execution. ```APIDOC ## Context Options - Configure Action Behavior Context constructor accepts options to control action triggering, queuing, and filtering behavior. ### Parameters #### Request Body - **ActionGhosting** (number) - Optional - Limits simultaneous actions sharing inputs. If multiple actions share inputs, only the one with the most unique inputs triggers. `0` disables this feature, while a positive integer `n` allows up to `n` shared inputs. - **OnBefore** (function) - Optional - A global validation function that runs before any action triggers. Return `false` to prevent action execution. - **Process** (boolean | undefined) - Optional - Filters actions based on the game input processing state. `true` triggers only if the game processed input, `false` triggers only if the game did not process input, and `undefined` triggers regardless of the input processing state. - **RunSynchronously** (boolean) - Optional - Disables the action queuing system. `true` makes all actions execute immediately without queuing, while `false` allows actions to queue and wait for previous actions to complete. ### Request Example ```typescript import { Context } from "@rbxts/gamejoy"; const advancedContext = new Context({ ActionGhosting: 1, OnBefore: () => { const character = Player.Character; if (!character) return false; const humanoid = character.FindFirstChild("Humanoid") as Humanoid; return humanoid && humanoid.Health > 0 && !isStunned; }, Process: false, RunSynchronously: false, }); const simpleContext = new Context(); // Uses default values for all options ``` ### Response #### Success Response (200) This endpoint does not return a specific response body as it is used for constructor configuration. The result is the creation of a `Context` object with the specified options. ``` -------------------------------- ### Configure GameJoy Context with Advanced Options (TypeScript) Source: https://context7.com/rimuy/gamejoy/llms.txt This snippet demonstrates how to create a new GameJoy Context with advanced configuration options. It shows how to set ActionGhosting, define a global validation function for OnBefore, specify input processing behavior with Process, and control action queuing with RunSynchronously. The configuration aims to limit simultaneous actions, ensure actions are only triggered when the player is alive, and disable action queuing for immediate execution. ```typescript import { Context } from "@rbxts/gamejoy"; // Full configuration example const advancedContext = new Context({ // ActionGhosting: Limit simultaneous actions sharing inputs // If multiple actions share inputs, only the one with most unique inputs triggers // 0 = disabled, 1 = allow 1 shared input, etc. ActionGhosting: 1, // OnBefore: Global validation before any action triggers // Return false to prevent action execution OnBefore: () => { const character = Player.Character; if (!character) return false; const humanoid = character.FindFirstChild("Humanoid") as Humanoid; return humanoid && humanoid.Health > 0 && !isStunned; }, // Process: Filter by game input processing state // true = only trigger if game processed input // false = only trigger if game didn't process input // undefined = always trigger regardless Process: false, // RunSynchronously: Disable action queuing // true = all actions execute immediately, no queue // false = actions enter queue and wait for previous to complete RunSynchronously: false, }); ``` -------------------------------- ### Create and Bind Composite Action in JavaScript Source: https://github.com/rimuy/gamejoy/blob/main/README.md Shows how to use the `Composite` class to create an action that requires multiple child actions to be pressed simultaneously. The action only triggers when all specified inputs are active at the same time. This is ideal for complex key combinations. ```javascript context.Bind(new Composite(["J", "K", "L"]), () => { print("You pressed J, K and L!"); }); ``` -------------------------------- ### Importing Action Classes from GameJoy Source: https://github.com/rimuy/gamejoy/blob/main/README.md This snippet demonstrates how to import various action classes provided by the GameJoy library. These classes allow for different types of action handling, such as basic actions, axis inputs, dynamic actions, and middleware. ```javascript import { Actions } from "@rbxts/gamejoy"; const { Action, Axis, Dynamic, Manual, Middleware, Optional, Sequence, Synchronous, Union, Unique } = Actions; ``` -------------------------------- ### Bind Raw Input Actions in JavaScript Source: https://github.com/rimuy/gamejoy/blob/main/README.md Illustrates binding raw input types like single keys or arrays of keys directly to callback functions. This method is simpler than creating Action objects and is suitable for basic input mapping without event-specific handling. It handles single key presses and multiple keys triggering the same action. ```javascript context.Bind("F", () => { print("F was pressed!"); }); context.Bind(["Q", "E"], () => { print("Q or E was pressed!"); }); ``` -------------------------------- ### Handle Continuous Inputs with Axis Source: https://github.com/rimuy/gamejoy/blob/main/README.md Shows how to use the `Axis` class to handle inputs with a continuous range, such as joysticks or analog buttons. It demonstrates binding different input devices like gamepads, mouse movement, and thumbsticks, and accessing their properties like delta and position. ```javascript const gamepad1 = new Axis("Gamepad1"); const mouse = new Axis("MouseMovement"); const thumbstick = new Axis("Thumbstick1"); const l2 = new Axis("ButtonL2"); context .Bind(gamepad1, () => { // Last controller button that was changed print(gamepad1.KeyCode); print(gamepad1.Delta); print(gamepad1.Position); }) .Bind(mouse, () => { print(mouse.Delta); print(mouse.Position.X, mouse.Position.Y); }) .Bind(thumbstick, () => { print(thumbstick.Position.X, thumbstick.Position.Y); }) .Bind(l2, () => { print(l2.Position.Z); }); ``` -------------------------------- ### Create and Bind Union of Actions in JavaScript Source: https://github.com/rimuy/gamejoy/blob/main/README.md Demonstrates using the `Union` class to create an action that triggers if any of the specified child actions are activated. It also shows a shorthand for creating unions using arrays of raw inputs. This is useful for scenarios where multiple inputs should perform the same function. ```javascript context.Bind(new Union(["F", "ButtonB"]), () => { print("You pressed either F or ButtonB!"); }); context.Bind(["F", "ButtonB"], () => { print("Easier to write :D"); }); ``` -------------------------------- ### Action - Single Key/Button Press with Timing Source: https://context7.com/rimuy/gamejoy/llms.txt Illustrates creating and binding single input actions with optional timing constraints. Actions can be configured to require multiple presses within a specified time window, and events like release or cancellation can be bound. ```typescript import { Context, Actions } from "@rbxts/gamejoy"; const context = new Context(); // Simple action const jumpAction = new Actions.Action("Space"); context.Bind(jumpAction, () => { character.Jump(); }); // Action requiring double-press within 0.3 seconds const dodgeAction = new Actions.Action("LeftShift", { Repeat: 2, Timing: 0.3, }); context .Bind(dodgeAction, () => { print("Double-tap shift - dodge!"); character.Dodge(); }) .BindEvent("onDodgeRelease", dodgeAction.Released, () => { print("Dodge ended"); }) .BindEvent("onDodgeCancelled", dodgeAction.Cancelled, () => { print("Dodge cancelled - timing failed"); }); ``` -------------------------------- ### Remove Specific and All Actions Source: https://github.com/rimuy/gamejoy/blob/main/README.md Shows how to remove specific actions from a context using `Unbind` and how to remove all bound actions at once with `UnbindAllActions`. This is essential for managing the lifecycle of actions within the context. ```javascript const action1 = new Action("X"); const action2 = new Action("Y"); const action3 = new Action("Z"); context .Bind(action1, /** ... */) .Bind(action2, /** ... */) .Bind(action3, /** ... */) .Unbind(action2) // Unbinds action2 from the context .UnbindAllActions(); // Unbinds all of the remaining bound actions ``` -------------------------------- ### Manually Trigger Action with Custom Parameters Source: https://github.com/rimuy/gamejoy/blob/main/README.md Illustrates how to manually trigger an action using the `Manual` class and provide custom parameters to its listener. The `Trigger` method allows for sending data to the bound callback function. ```typescript const manual = new Manual<[string, number]>(); context.Bind(manual, (name, age) => print(name, age)); manual.Trigger("Kevin", 19); ``` -------------------------------- ### Union - Multiple Alternative Inputs Source: https://context7.com/rimuy/gamejoy/llms.txt Shows how to create a 'Union' action in GameJoy, which triggers when any one of the specified inputs is pressed. This is useful for actions that can be performed using different keys or buttons. ```typescript import { Context, Actions } from "@rbxts/gamejoy"; const context = new Context(); // Either F or ButtonB triggers interaction const interactAction = new Actions.Union(["F", "ButtonB"]); context.Bind(interactAction, () => { print("Interacting with object"); interactWithNearestObject(); }); // Shorthand: array syntax is equivalent to Union context.Bind(["E", "ButtonY"], () => { print("Open inventory"); openInventory(); }); ``` -------------------------------- ### Synchronous Action Execution with Sync Source: https://context7.com/rimuy/gamejoy/llms.txt Sync wraps an action to ensure it executes synchronously, bypassing the action queue even if queuing is enabled. This is useful for actions that must complete immediately without being affected by other queued actions. ```typescript import { Context, Actions } from "@rbxts/gamejoy"; // Context with queuing enabled (default) const context = new Context({ RunSynchronously: false }); // This action takes 5 seconds context.Bind("A", () => { print("A started"); task.wait(5); print("A finished"); }); // This action must wait for A to complete context.Bind("B", () => { print("B executes after A"); }); // This action bypasses the queue context.Bind(new Actions.Sync("C"), () => { print("C executes immediately, even if A is running!"); }); ``` -------------------------------- ### Update Action with Dynamic Type Source: https://github.com/rimuy/gamejoy/blob/main/README.md Demonstrates how to update an action using the Dynamic class. It shows how to define a specific type for updatable actions and how to trigger updates with new values. The `Dynamic` class allows for flexible updates of action states. ```typescript type ActionThatChanges = "X" | "Y" | "Z"; const dynamic = new Dynamic("X"); context.Bind(dynamic, () => { print(dynamic.RawAction); }); task.wait(1); dynamic.Update("Y"); task.wait(1); dynamic.Update("Z"); ``` -------------------------------- ### Composite - Multiple Simultaneous Inputs Source: https://context7.com/rimuy/gamejoy/llms.txt Demonstrates creating a 'Composite' action in GameJoy, requiring all specified inputs to be held down simultaneously. This is common for complex move combinations or modifier key shortcuts. ```typescript import { Context, Actions } from "@rbxts/gamejoy"; const context = new Context(); // Requires J, K, and L to be pressed together const specialMoveAction = new Actions.Composite(["J", "K", "L"]); context.Bind(specialMoveAction, () => { print("Special move activated!"); character.PerformSpecialMove(); }); // Common use case: modifier key combinations const saveAction = new Actions.Composite(["LeftControl", "S"]); context.Bind(saveAction, () => { print("Saving game..."); saveGame(); }); ``` -------------------------------- ### Optional - Optional Input in Combinations Source: https://context7.com/rimuy/gamejoy/llms.txt Allows specific inputs within Composite, Sequence, or Unique actions to be optional. This enables variations of the same action, like a light or heavy attack based on an additional key press. It depends on the 'gamejoy' library. ```typescript import { Context, Actions } from "@rbxts/gamejoy"; const context = new Context(); // Action triggers with F alone or F+G together const optionalG = new Actions.Optional("G"); const attackAction = new Actions.Composite(["F", optionalG]); context.Bind(attackAction, () => { if (optionalG.IsActive) { print("Heavy attack!"); character.HeavyAttack(); } else { print("Light attack"); character.LightAttack(); } }); // Sequence with optional modifier const optional = new Actions.Optional("LeftShift"); const moveAction = new Actions.Sequence(["W", optional]); context.Bind(moveAction, () => { if (optional.IsActive) { character.Sprint(); } else { character.Walk(); } }); ``` -------------------------------- ### Dynamic - Updatable Action Bindings Source: https://context7.com/rimuy/gamejoy/llms.txt Wraps any action and allows its binding to be updated at runtime without changing the underlying action. This is useful for dynamically reconfiguring controls. It depends on the 'gamejoy' library. ```typescript import { Context, Actions } from "@rbxts/gamejoy"; type WeaponKey = "X" | "Y" | "Z"; const context = new Context(); // Create dynamic action starting with X const weaponAction = new Actions.Dynamic("X"); context .Bind(weaponAction, () => { print(`Current weapon key: ${weaponAction.RawAction}`); fireWeapon(); }) .BindEvent("onWeaponChanged", weaponAction.Updated, () => { print("Weapon keybind updated!"); }); // Update the bound key at runtime task.wait(2); weaponAction.Update("Y"); task.wait(2); weaponAction.Update("Z"); // Works with complex actions too const dynamicCombo = new Actions.Dynamic<"A" | "B" | "C" | "D"> (new Actions.Composite(["A", "B"])); dynamicCombo.Update(new Actions.Sequence(["C", "D"])); ``` -------------------------------- ### Programmatic Action Triggering with Manual Source: https://context7.com/rimuy/gamejoy/llms.txt Manual creates actions that can only be triggered programmatically, not by user input. This is ideal for actions initiated by game events, network messages, or other internal game logic, and supports both parameterless and typed actions. ```typescript import { Context, Actions } from "@rbxts/gamejoy"; const context = new Context(); // Manual action with no parameters const simpleManual = new Actions.Manual(); context.Bind(simpleManual, () => { print("Manual action triggered!"); }); simpleManual.Trigger(); // Manual action with typed parameters const damageManual = new Actions.Manual<[string, number]>(); context.Bind(damageManual, (damagerName, damageAmount) => { print(`${damagerName} dealt ${damageAmount} damage!`); character.TakeDamage(damageAmount); showDamageIndicator(damagerName); }); // Trigger from game events enemy.Attacked.Connect((damage) => { damageManual.Trigger("Enemy", damage); }); // Network event triggers remoteEvent.OnClientEvent.Connect((eventName, value) => { damageManual.Trigger(eventName, value); }); ``` -------------------------------- ### Sequence - Ordered Input Combination Source: https://context7.com/rimuy/gamejoy/llms.txt Implements actions that require inputs to be pressed in a specific order. This is useful for combos or timed sequences. It depends on the 'gamejoy' library. ```typescript import { Context, Actions } from "@rbxts/gamejoy"; const context = new Context(); // Alt must be pressed before E const abilityAction = new Actions.Sequence(["LeftAlt", "E"]); context .Bind(abilityAction, () => { print("Ultimate ability!"); character.UseUltimate(); }) .BindEvent("onAbilityCancelled", abilityAction.Cancelled, () => { print("Ultimate cancelled - key released early"); showCancelledMessage(); }); // Complex combo sequence const comboAction = new Actions.Sequence(["Q", "W", "E", "R"]); context.Bind(comboAction, () => { print("Combo executed!"); character.ExecuteCombo(); }); ``` -------------------------------- ### Conditional Action Execution with Middleware Source: https://context7.com/rimuy/gamejoy/llms.txt Middleware allows you to add conditional checks before an action is triggered. These checks can be simple boolean functions or sequences of other actions. They are useful for validating conditions like time of day, resource availability, or character state before executing an action. ```typescript import { Context, Actions } from "@rbxts/gamejoy"; const context = new Context(); // Action only works during even seconds const timeLimitedAction = new Actions.Middleware("M", () => { return os.time() % 2 === 0; }); context.Bind(timeLimitedAction, () => { print("Time-limited action succeeded!"); }); // Check resource availability const resourceCheck = (action: Actions.Middleware<"R">) => { return player.GetMana() >= 50; }; const spellAction = new Actions.Middleware("R", resourceCheck); context.Bind(spellAction, () => { player.CastSpell(); player.DeductMana(50); }); // Conditional combo const comboMiddleware = new Actions.Middleware( new Actions.Sequence(["Q", "E"]), () => character.CanPerformCombo() ); context.Bind(comboMiddleware, () => { character.ExecuteCombo(); }); ``` -------------------------------- ### Non-Queued Event Handling with BindSyncEvent Source: https://context7.com/rimuy/gamejoy/llms.txt BindSyncEvent registers events that execute immediately without entering the action queue. This is crucial for high-frequency events like rendering or physics updates that should not block other actions and must run without delay, while still respecting 'OnBefore' checks. ```typescript import { Context, Actions } from "@rbxts/gamejoy"; import { RunService } from "@rbxts/services"; const context = new Context({ OnBefore: () => !!Player.Character, }); // Render loop - must not be queued context.BindSyncEvent("onRender", RunService.RenderStepped, (delta) => { updateCamera(delta); updateUI(delta); }); // Heartbeat - runs every frame without blocking context.BindSyncEvent("onHeartbeat", RunService.Heartbeat, (delta) => { physicsStep(delta); }); // Frequent updates that shouldn't block actions context.BindSyncEvent("onMouseMove", userInputService.InputChanged, (input) => { if (input.UserInputType === Enum.UserInputType.MouseMovement) { updateCrosshair(input.Position); } }); ``` -------------------------------- ### Queue-Based Event Handling with BindEvent Source: https://context7.com/rimuy/gamejoy/llms.txt BindEvent integrates external events, such as Roblox signals, into the action queue. This ensures that event handlers execute in the order actions are processed, respecting the game's action queue and allowing for sequential execution and queuing of responses. ```typescript import { Context, Actions } from "@rbxts/gamejoy"; import { RunService } from "@rbxts/services"; const context = new Context(); // Bind to character damage event context.BindEvent("onCharacterDamaged", character.Damaged, (oldHealth, health) => { const damage = oldHealth - health; print(`Took ${damage} damage!`); task.wait(0.3); // Uses action queue - blocks other actions print("Stun duration over"); }); // Bind to network event context.BindEvent("onServerMessage", remoteEvent.OnClientEvent, (message) => { print(`Server says: ${message}`); showNotification(message); }); // Unbind specific events context.UnbindEvent("onCharacterDamaged"); // Remove all event bindings context.UnbindAllEvents(); ``` -------------------------------- ### Create and Bind Unique Action in JavaScript Source: https://github.com/rimuy/gamejoy/blob/main/README.md Explains how to use the `Unique` class to create an action that only triggers if one of its child actions is active and the others are not. This prevents simultaneous activation of related inputs for a single action. It's useful for exclusive input handling. ```javascript context.Bind(new Unique(["C", "V"]), () => { print("Either C or V... but one must be inactive for the another one to work."); }); ``` -------------------------------- ### Update Action with Composite Type Source: https://github.com/rimuy/gamejoy/blob/main/README.md Illustrates updating an action that can accept multiple input types using `Dynamic` with a `Composite` type. This approach is useful when an action needs to handle a combination of different inputs. ```typescript type ActionThatChanges = "X" | "Y" | "Z" | "A" | "B"; const dynamic = new Dynamic(new Composite(["A", "B"])); ``` -------------------------------- ### Unique - Mutually Exclusive Inputs Source: https://context7.com/rimuy/gamejoy/llms.txt Ensures that only one action from a specified group can be active at any given time, preventing simultaneous activation. It can also incorporate optional inputs. It depends on the 'gamejoy' library. ```typescript import { Context, Actions } from "@rbxts/gamejoy"; const context = new Context(); // Only C or V can be active, never both const weaponSwitch = new Actions.Unique(["C", "V"]); context.Bind(weaponSwitch, () => { print("Weapon switched - only one can be active"); switchWeapon(); }); // Optional inputs can break Unique rules const uniqueWithOptional = new Actions.Unique([ "One", new Actions.Optional("Two"), "Three" ]); context.Bind(uniqueWithOptional, () => { print("Unique action with optional override"); }); ``` -------------------------------- ### Axis - Continuous Input Range Source: https://context7.com/rimuy/gamejoy/llms.txt Handles inputs that provide continuous values, such as joysticks, mouse movement, and analog triggers. It allows for nuanced control based on the input's position or delta. It depends on the 'gamejoy' library. ```typescript import { Context, Actions } from "@rbxts/gamejoy"; const context = new Context(); // Gamepad thumbstick const thumbstickAction = new Actions.Axis("Thumbstick1"); context.Bind(thumbstickAction, () => { const x = thumbstickAction.Position.X; const y = thumbstickAction.Position.Y; print(`Thumbstick: ${x}, ${y}`); character.Move(x, y); }); // Mouse movement const mouseAction = new Actions.Axis("MouseMovement"); context.Bind(mouseAction, () => { print(`Mouse delta: ${mouseAction.Delta.X}, ${mouseAction.Delta.Y}`); camera.Rotate(mouseAction.Delta.X, mouseAction.Delta.Y); }); // Analog trigger const triggerAction = new Actions.Axis("ButtonL2"); context.Bind(triggerAction, () => { const pressure = triggerAction.Position.Z; // 0 to 1 print(`Trigger pressure: ${pressure}`); vehicle.Accelerate(pressure); }); // Track which gamepad button changed const gamepadAction = new Actions.Axis("Gamepad1"); context.Bind(gamepadAction, () => { print(`Last button: ${gamepadAction.KeyCode}`); }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.