### LineEdit Context Menu Example Source: https://context7_llms Example demonstrating how to customize the LineEdit's context menu. ```APIDOC ## LineEdit Context Menu Customization ### Description This example shows how to modify the default context menu of a LineEdit, such as adding a 'Date' option. ### Method `get_menu()` ### Usage Example (GDScript) ```gdscript func _ready(): var menu = get_menu() # Remove items after 'Redo'. menu.item_count = menu.get_item_index(MENU_REDO) + 1 # Add a separator and a custom item. menu.add_separator() menu.add_item("Insert Date", MENU_MAX + 1) # Connect the callback for item presses. menu.id_pressed.connect(_on_item_pressed) func _on_item_pressed(id): if id == MENU_MAX + 1: insert_text_at_caret(Time.get_date_string_from_system()) ``` ### Usage Example (C#) ```csharp public override void _Ready() { var menu = GetMenu(); // Remove items after 'Redo'. menu.ItemCount = menu.GetItemIndex(LineEdit.MenuItems.Redo) + 1; // Add a separator and a custom item. menu.AddSeparator(); menu.AddItem("Insert Date", LineEdit.MenuItems.Max + 1); // Connect the event handler for item presses. menu.IdPressed += OnItemPressed; } public void OnItemPressed(int id) { if (id == LineEdit.MenuItems.Max + 1) { InsertTextAtCaret(Time.GetDateStringFromSystem()); } } ``` ``` -------------------------------- ### AudioStreamGenerator Sine Wave Example Source: https://context7_llms Demonstrates how to use AudioStreamGenerator to procedurally generate a sine wave sound. It involves setting up the audio player, getting the playback stream, and pushing audio frames. ```GDScript var playback # Will hold the AudioStreamGeneratorPlayback. @onready var sample_hz = $AudioStreamPlayer.stream.mix_rate var pulse_hz = 440.0 # The frequency of the sound wave. func _ready(): $AudioStreamPlayer.play() playback = $AudioStreamPlayer.get_stream_playback() fill_buffer() func fill_buffer(): var phase = 0.0 var increment = pulse_hz / sample_hz var frames_available = playback.get_frames_available() for i in range(frames_available): playback.push_frame(Vector2.ONE * sin(phase * TAU)) phase = fmod(phase + increment, 1.0) ``` -------------------------------- ### InputEventMIDI: Handling MIDI Input (GDScript) Source: https://context7_llms Example of how to open MIDI inputs, get connected devices, and process incoming MIDI messages using InputEventMIDI in GDScript. It prints details of each MIDI event received. ```gdscript func _ready(): OS.open_midi_inputs() print(OS.get_connected_midi_inputs()) func _input(input_event): if input_event is InputEventMIDI: _print_midi_info(input_event) func _print_midi_info(midi_event): print(midi_event) print("Channel ", midi_event.channel) print("Message ", midi_event.message) print("Pitch ", midi_event.pitch) print("Velocity ", midi_event.velocity) print("Instrument ", midi_event.instrument) print("Pressure ", midi_event.pressure) print("Controller number: ", midi_event.controller_number) print("Controller value: ", midi_event.controller_value) ``` -------------------------------- ### SkeletonModification2D: Set Setup State Source: https://context7_llms Manually sets the setup state of the modification. This method should be used sparingly, as the SkeletonModificationStack2D typically manages the setup state. ```GDScript void set_is_setup ( bool is_setup ) ``` -------------------------------- ### Start SkeletonIK Source: https://context7_llms Starts the SkeletonIK process. If 'one_time' is true, the effect is applied immediately but resets on the next frame. Otherwise, it starts on the next frame. This method is part of the SkeletonIK3D class. ```gdscript skeleton_ik_node.start(false) ``` -------------------------------- ### Body Entered Signal Example (GDScript) Source: https://context7_llms Example demonstrating how to connect to the `body_entered` signal of an Area2D node. This signal is emitted when a PhysicsBody2D or TileMap enters this area, provided monitoring is enabled. ```GDScript func _ready(): $MyArea2D.body_entered.connect(_on_body_entered) func _on_body_entered(body: Node2D): print("Body entered: ", body.name) ``` -------------------------------- ### InputEventKey Processing in C# Source: https://context7_llms Example of how to handle keyboard input events in C# within a Godot project. This code snippet shows the equivalent logic to the GDScript example for retrieving and printing key information. ```csharp public override void _Input(InputEvent @event) { if (@event is InputEventKey inputEventKey) { var keycode = DisplayServer.KeyboardGetKeycodeFromPhysical(inputEventKey.PhysicalKeycode); GD.Print(OS.GetKeycodeString(keycode)); } } ``` -------------------------------- ### Area Entered Signal Example (GDScript) Source: https://context7_llms Example demonstrating how to connect to the `area_entered` signal of an Area2D node. This signal is emitted when another Area2D enters this area, provided monitoring is enabled. ```GDScript func _ready(): $MyArea2D.area_entered.connect(_on_area_entered) func _on_area_entered(area: Area2D): print("Area entered: ", area.name) ``` -------------------------------- ### Create and Configure SpinBox (C#) Source: https://context7_llms This C# example demonstrates creating a SpinBox, adding it to the scene, disabling the context menu, and aligning the text to the right. ```csharp var spinBox = new SpinBox(); AddChild(spinBox); var lineEdit = spinBox.GetLineEdit(); lineEdit.ContextMenuEnabled = false; spinBox.AlignHorizontal = LineEdit.HorizontalAlignEnum.Right; ``` -------------------------------- ### Get and Set Color Ramps Source: https://context7_llms Defines how particle colors vary over time or initially. `color_initial_ramp` sets the starting color variation, while `color_ramp` adjusts color throughout the particle's lifetime. Both multiply vertex colors and require specific material setup for visibility. ```gdscript Gradient color_initial_ramp void set_color_initial_ramp ( Gradient value ) Gradient get_color_initial_ramp ( ) Each particle's initial color will vary along this GradientTexture1D (multiplied with color). Note: color_initial_ramp multiplies the particle mesh's vertex colors. To have a visible effect on a BaseMaterial3D, BaseMaterial3D.vertex_color_use_as_albedo must be true. For a ShaderMaterial, ALBEDO *= COLOR.rgb; must be inserted in the shader's fragment() function. Otherwise, color_initial_ramp will have no visible effect. Gradient color_ramp void set_color_ramp ( Gradient value ) Gradient get_color_ramp ( ) Each particle's color will vary along this GradientTexture1D over its lifetime (multiplied with color). Note: color_ramp multiplies the particle mesh's vertex colors. To have a visible effect on a BaseMaterial3D, BaseMaterial3D.vertex_color_use_as_albedo must be true. For a ShaderMaterial, ALBEDO *= COLOR.rgb; must be inserted in the shader's fragment() function. Otherwise, color_ramp will have no visible effect. ``` -------------------------------- ### Setting and Getting Node Size (GDScript) Source: https://context7_llms Provides examples for setting and getting the size of a Control node's bounding rectangle. Container nodes automatically update this property. ```GDScript func set_node_size(s: Vector2): size = s func get_node_size() -> Vector2: return size ``` -------------------------------- ### GDExtension Initialization Source: https://context7_llms Documentation for methods related to initializing GDExtension libraries and managing initialization levels. ```APIDOC ## GDExtension Initialization ### Description Methods for initializing GDExtension libraries and retrieving the minimum required initialization level. ### Methods #### `initialize_library` - **Method:** `void initialize_library(InitializationLevel level)` - **Description:** Initializes the GDExtension library with the specified initialization level. #### `get_minimum_library_initialization_level` - **Method:** `InitializationLevel get_minimum_library_initialization_level() const` - **Description:** Returns the minimum initialization level required for the GDExtension library. ### Enumerations #### `InitializationLevel` - `INITIALIZATION_LEVEL_CORE` (0): Core initialization level. - `INITIALIZATION_LEVEL_SERVERS` (1): Initialization level for servers. - `INITIALIZATION_LEVEL_SCENE` (2): Initialization level for the scene. - `INITIALIZATION_LEVEL_EDITOR` (3): Initialization level for the editor. ### Request Example ```json { "method": "initialize_library", "params": { "level": 2 } } ``` ### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Get Selection Range in LineEdit Source: https://context7_llms Provides the starting and ending column indices of the current text selection in the LineEdit. `get_selection_from_column` returns the start index, and `get_selection_to_column` returns the end index. ```gdscript int get_selection_from_column ( ) const int get_selection_to_column ( ) const ``` -------------------------------- ### Setting and Getting Node Rotation (GDScript) Source: https://context7_llms Provides examples for setting and getting the rotation of a Control node in radians. Rotation is performed around the node's pivot point. The inspector displays rotation in degrees. ```GDScript func set_node_rotation(rad: float): rotation = rad func get_node_rotation() -> float: return rotation ``` -------------------------------- ### Setup Local to Scene Method Source: https://context7_llms Calls the internal _setup_local_to_scene method. If 'resource_local_to_scene' is true, this is automatically called by PackedScene.instantiate on duplicated resources. This method is deprecated and should not be called directly; override _setup_local_to_scene instead. ```GDScript void setup_local_to_scene ( ) ``` -------------------------------- ### Create and Configure SpinBox (GDScript) Source: https://context7_llms This GDScript example creates a SpinBox node, adds it to the scene, disables its context menu, and sets the text alignment to the right. ```gdscript var spin_box = SpinBox.new() add_child(spin_box) var line_edit = spin_box.get_line_edit() line_edit.context_menu_enabled = false spin_box.horizontal_alignment = LineEdit.HORIZONTAL_ALIGNMENT_RIGHT ``` -------------------------------- ### Setting and Getting Vertical Size Flags (GDScript) Source: https://context7_llms Illustrates how to set and get the vertical size flags for a Control node. These flags guide parent Container nodes in resizing and positioning the node along the Y-axis. ```GDScript func set_node_v_size_flags(flags: BitField): set_v_size_flags(flags) func get_node_v_size_flags() -> BitField: return get_v_size_flags() ``` -------------------------------- ### Get Clicked Tile Power - GDScript Source: https://context7_llms A practical example demonstrating how to get the 'power' custom data from a clicked tile. It converts mouse position to map coordinates, retrieves tile data, and returns the custom data or 0 if none is found. ```GDScript func get_clicked_tile_power() -> int: var clicked_cell = tile_map.local_to_map(tile_map.get_local_mouse_position()) var data = tile_map.get_cell_tile_data(0, clicked_cell) if data: return data.get_custom_data("power") else: return 0 ``` -------------------------------- ### InputEventMIDI: Handling MIDI Input (C#) Source: https://context7_llms Demonstrates how to initialize MIDI input handling, retrieve connected MIDI devices, and process MIDI events within the _Input method using InputEventMIDI in C#. It logs detailed information about each MIDI message. ```csharp public override void _Ready() { OS.OpenMidiInputs(); GD.Print(OS.GetConnectedMidiInputs()); } public override void _Input(InputEvent inputEvent) { if (inputEvent is InputEventMidi midiEvent) { PrintMIDIInfo(midiEvent); } } private void PrintMIDIInfo(InputEventMidi midiEvent) { GD.Print(midiEvent); GD.Print($"Channel {midiEvent.Channel}"); GD.Print($"Message {midiEvent.Message}"); GD.Print($"Pitch {midiEvent.Pitch}"); GD.Print($"Velocity {midiEvent.Velocity}"); GD.Print($"Instrument {midiEvent.Instrument}"); GD.Print($"Pressure {midiEvent.Pressure}"); GD.Print($"Controller number: {midiEvent.ControllerNumber}"); GD.Print($"Controller value: {midiEvent.ControllerValue}"); } ``` -------------------------------- ### Create a Triangular Face with ImmediateMesh (C#) Source: https://context7_llms Demonstrates how to generate a simple triangular face using ImmediateMesh in C#. This involves beginning a surface, adding vertices, and ending the surface. ```C# var mesh = new ImmediateMesh(); mesh.SurfaceBegin(Mesh.PrimitiveType.Triangles); mesh.SurfaceAddVertex(Vector3.Left); mesh.SurfaceAddVertex(Vector3.Forward); mesh.SurfaceAddVertex(Vector3.Zero); mesh.SurfaceEnd(); ``` -------------------------------- ### Get MultiMesh Instance Transform (2D) Source: https://context7_llms Retrieves the 2D transform of a specific instance from a MultiMesh. This is used when dealing with 2D transformations within a MultiMesh setup. ```GDScript Transform2D get_instance_transform_2d ( int instance ) const ``` -------------------------------- ### Get Pre-process Time for GPUParticles3D Source: https://context7_llms Retrieves the current pre-process time setting for a GPUParticles3D node. This value indicates how long particles are pre-processed before the animation starts. ```GDScript var particles = GPUParticles3D.new() var preprocess_time = particles.get_pre_process_time() print("Pre-process time: ", preprocess_time) ``` -------------------------------- ### Create and Configure Button in C# Source: https://context7_llms This C# snippet shows how to instantiate a Button, assign text, link the Pressed event to a method, and add it to the scene tree. This is the equivalent of the GDScript example for C# users. ```csharp public override void _Ready() { var button = new Button(); button.Text = "Click me"; button.Pressed += ButtonPressed; AddChild(button); } private void ButtonPressed() { GD.Print("Hello world!"); } ``` -------------------------------- ### Load and Apply Font in C# Source: https://context7_llms Demonstrates how to load a font file (e.g., TTF) and apply it to a Label node in C#. It also shows how to set the font size. ```csharp var f = ResourceLoader.Load("res://BarlowCondensed-Bold.ttf"); GetNode("Label").AddThemeFontOverride("font", f); GetNode("Label").AddThemeFontSizeOverride("font_size", 64); ``` -------------------------------- ### Set and Get Distance Fade Min Distance Source: https://context7_llms Sets the distance at which the object starts to fade out or become invisible. If this value is greater than `distance_fade_max_distance`, the fading behavior is reversed. ```GDScript func set_distance_fade_min_distance(value: float) -> void: # Implementation to set min fade distance pass func get_distance_fade_min_distance() -> float: # Implementation to get min fade distance return 0.0 ``` -------------------------------- ### Get TwoBoneIK Joint Two Bone2D Node Source: https://context7_llms Returns the index of the Bone2D node currently used as the second bone in the TwoBoneIK modification. This is useful for debugging or inspecting the IK setup. ```GDScript func get_joint_two_bone2d_node() -> NodePath: pass ``` -------------------------------- ### Environment Methods Source: https://context7_llms This section details the methods available for the Environment resource, such as getting and setting glow levels. ```APIDOC ## Environment Methods ### Description Provides methods for interacting with the Environment resource, specifically for managing glow levels. ### Methods - **get_glow_level(idx: int) const -> float** - Gets the intensity of a specific glow level. - **Parameters**: - **idx** (int) - The index of the glow level to retrieve. - **Returns**: - (float) - The intensity of the specified glow level. - **set_glow_level(idx: int, intensity: float) -> void** - Sets the intensity of a specific glow level. - **Parameters**: - **idx** (int) - The index of the glow level to set. - **intensity** (float) - The desired intensity for the glow level. ``` -------------------------------- ### Configure and Show Script Creation Dialog (GDScript) Source: https://context7_llms Demonstrates how to create, configure, and display the ScriptCreateDialog in Godot using GDScript. It shows how to set up templates for both in-engine types and script types before popping up the dialog. ```gdscript func _ready(): var dialog = ScriptCreateDialog.new(); dialog.config("Node", "res://new_node.gd") # For in-engine types. dialog.config("\"res://base_node.gd\"", "res://derived_node.gd") # For script types. dialog.popup_centered() ``` -------------------------------- ### Get Delimiter Information Source: https://context7_llms Retrieves information about string and comment delimiters, including their start and end keys and positions within the code. Handles cases where delimiters are not found by returning -1. ```cpp String get_delimiter_end_key ( int delimiter_index ) const Gets the end key for a string or comment region index. Vector2 get_delimiter_end_position ( int line, int column ) const If line column is in a string or comment, returns the end position of the region. If not or no end could be found, both Vector2 values will be -1. String get_delimiter_start_key ( int delimiter_index ) const Gets the start key for a string or comment region index. Vector2 get_delimiter_start_position ( int line, int column ) const If line column is in a string or comment, returns the start position of the region. If not or no start could be found, both Vector2 values will be -1. ``` -------------------------------- ### Loading Resources in GDScript Source: https://context7_llms Demonstrates how to load resources from disk in GDScript using the @GDScript.load and @GDScript.preload functions. These functions return a reference to the resource, ensuring that only one instance is loaded. ```GDScript var my_texture = @GDScript.load("res://path/to/texture.png") var my_scene = @GDScript.preload("res://path/to/scene.tscn") ``` -------------------------------- ### Get Pre-Process Time for Particle System (GDScript) Source: https://context7_llms Retrieves the pre-process time of the particle system. This value indicates how many seconds the particle system is considered to have already run at its start. ```gdscript float get_pre_process_time ( ) ``` -------------------------------- ### Initialize Script Creation Dialog (C#) Source: https://context7_llms Shows the basic initialization of the ScriptCreateDialog in Godot using C#. This snippet is typically part of a larger script where further configuration and display logic would follow. ```csharp public override void _Ready() { var dialog = new ScriptCreateDialog(); // Further configuration and popup logic would go here. ``` -------------------------------- ### Getting Collider Information from RayCast2D Source: https://context7_llms Retrieves details about the first object intersected by the RayCast2D, including the object itself, its RID, and the shape ID. Includes examples for accessing shape details in GDScript and C#. ```GDScript func get_collider() -> CollisionObject2D: # Returns the first object that the ray intersects, or null if no object is intersecting. pass func get_collider_rid() -> RID: # Returns the RID of the first object that the ray intersects, or an empty RID. pass func get_collider_shape() -> int: # Returns the shape ID of the first object that the ray intersects, or 0. pass # Example to get the intersected shape node: var target = get_collider() # A CollisionObject2D. var shape_id = get_collider_shape() # The shape index in the collider. var owner_id = target.shape_find_owner(shape_id) # The owner ID in the collider. var shape = target.shape_owner_get_owner(owner_id) ``` ```C# public CollisionObject2D GetCollider() { // Returns the first object that the ray intersects, or null if no object is intersecting. return null; } public RID GetColliderRid() { // Returns the RID of the first object that the ray intersects, or an empty RID. return new RID(); } public int GetColliderShape() { // Returns the shape ID of the first object that the ray intersects, or 0. return 0; } // Example to get the intersected shape node: var target = (CollisionObject2D)GetCollider(); // A CollisionObject2D. var shapeId = GetColliderShape(); // The shape index in the collider. var ownerId = target.ShapeFindOwner(shapeId); // The owner ID in the collider. var shape = target.ShapeOwnerGetOwner(ownerId); ``` -------------------------------- ### Configure AnimationTree State Machine Properties (GDScript) Source: https://context7_llms This GDScript example demonstrates how to configure properties of an AnimationTree state machine, such as allowing transitions to the same state and resetting end states. It uses setter methods like set_allow_transition_to_self and set_reset_ends. ```gdscript state_machine.allow_transition_to_self = true state_machine.reset_ends = false ``` -------------------------------- ### AudioStreamGenerator Sine Wave Example (C#) Source: https://context7_llms Provides a C# implementation for generating a sine wave using AudioStreamGenerator. This includes setting up playback, sample rate, and pushing audio frames to the stream. ```C# [Export] public AudioStreamPlayer Player { get; set; } private AudioStreamGeneratorPlayback _playback; // Will hold the AudioStreamGeneratorPlayback. private float _sampleHz; private float _pulseHz = 440.0f; // The frequency of the sound wave. // Assuming _playback and _sampleHz are initialized elsewhere, e.g., in _Ready() // Example initialization: // _playback = GetNode("AudioStreamPlayer").GetStreamPlayback() as AudioStreamGeneratorPlayback; // _sampleHz = AudioStreamPlayer.Stream.MixRate; public void FillBuffer() { float phase = 0.0f; float increment = _pulseHz / _sampleHz; int framesAvailable = _playback.GetFramesAvailable(); for (int i = 0; i < framesAvailable; i++) { _playback.PushFrame(Vector2.One * Mathf.Sin(phase * Mathf.Tau)); phase = Mathf.Fmod(phase + increment, 1.0f); } } ``` -------------------------------- ### Get Collision Point (GDScript) Source: https://context7_llms Returns the global coordinates of the point where the ray intersects the closest object. If hit_from_inside is true and the ray starts within a collision shape, it returns the ray's origin. ```GDScript Vector3 get_collision_point ( ) const ``` -------------------------------- ### AnimationNodeStateMachinePlayback Methods Source: https://context7_llms Provides methods to control and query the playback state of an AnimationNodeStateMachine. It allows getting the current node, playback position, fading states, and managing transitions like next, start, stop, and travel. ```GDScript func get_current_node() -> StringName: # Returns the currently playing animation state. pass func get_current_play_position() -> float: # Returns the playback position within the current animation state. pass func get_fading_from_node() -> StringName: # Returns the starting state of currently fading animation. pass func get_travel_path() -> PackedStringArray: # Returns the current travel path as computed internally by the A* algorithm. pass bool is_playing() const: # Returns true if an animation is playing. pass func next() -> void: # If there is a next path by travel or auto advance, immediately transitions from the current state to the next state. pass func start(node: StringName, reset: bool = true) -> void: # Starts playing the given animation. If reset is true, the animation is played from the beginning. pass func stop() -> void: # Stops the currently playing animation. pass func travel(to_node: StringName, reset_on_teleport: bool = true) -> void: # Transitions from the current state to another one, following the shortest path. If the path does not connect from the current state, the animation will play after the state teleports. If reset_on_teleport is true, the animation is played from the beginning when the travel cause a teleportation. pass ``` -------------------------------- ### Create and Populate a Tree Control Source: https://context7_llms Demonstrates how to create a new Tree control, add a root item, hide the root, and add child and sub-child items with text. This is a fundamental example for initializing a Tree structure. ```gdscript func _ready(): var tree = Tree.new() var root = tree.create_item() tree.hide_root = true var child1 = tree.create_item(root) var child2 = tree.create_item(root) var subchild1 = tree.create_item(child1) subchild1.set_text(0, "Subchild1") ``` ```csharp public override void _Ready() { var tree = new Tree(); TreeItem root = tree.CreateItem(); tree.HideRoot = true; TreeItem child1 = tree.CreateItem(root); TreeItem child2 = tree.CreateItem(root); TreeItem subchild1 = tree.CreateItem(child1); subchild1.SetText(0, "Subchild1"); } ``` -------------------------------- ### Get Collision Normal (GDScript) Source: https://context7_llms Returns the normal vector of the intersected object's shape at the collision point. Returns Vector3(0, 0, 0) if the ray starts inside the shape and hit_from_inside is true. ```GDScript Vector3 get_collision_normal ( ) const ``` -------------------------------- ### MeshInstance3D - Add Surface from Arrays Source: https://context7_llms Demonstrates how to create a 3D mesh using ArrayMesh and add a surface to it from vertex data. ```APIDOC ## POST /MeshInstance3D/add_surface_from_arrays ### Description Adds a surface to the ArrayMesh using the provided primitive type and vertex arrays. This method is fundamental for procedural mesh generation. ### Method POST ### Endpoint /MeshInstance3D/add_surface_from_arrays ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **primitive** (Mesh.PrimitiveType) - Required - The primitive type for the surface (e.g., Triangles, Quads). - **arrays** (Godot.Collections.Array) - Required - An array containing vertex data, normals, UVs, etc. - **blend_shapes** (Array[]) - Optional - Blend shape data for the surface. - **lods** (Dictionary) - Optional - Level of detail data. - **flags** (BitField) - Optional - Flags to specify the format of the arrays. ### Request Example ```json { "primitive": "Triangles", "arrays": [ [ [0, 1, 0], [1, 0, 0], [0, 0, 1] ] ] } ``` ### Response #### Success Response (200) - **void** - This method does not return a value upon success. #### Response Example (No response body for void methods) ``` -------------------------------- ### Getting Collision Normal and Point from RayCast2D Source: https://context7_llms Retrieves the normal vector of the intersecting object's shape at the collision point and the exact collision point in global coordinates. Handles cases where the ray starts inside a shape. ```GDScript func get_collision_normal() -> Vector2: # Returns the normal of the intersecting object's shape at the collision point. pass func get_collision_point() -> Vector2: # Returns the collision point at which the ray intersects the closest object. pass ``` ```C# public Vector2 GetCollisionNormal() { // Returns the normal of the intersecting object's shape at the collision point. return Vector2.Zero; } public Vector2 GetCollisionPoint() { // Returns the collision point at which the ray intersects the closest object. return Vector2.Zero; } ``` -------------------------------- ### Initialize and Play Audio Stream Generator (C#) Source: https://context7_llms Initializes the AudioStreamPlayer with an AudioStreamGenerator, sets the sample rate, plays the stream, and gets the playback instance. This function is typically called when the node is ready. ```csharp public override void _Ready() { if (Player.Stream is AudioStreamGenerator generator) // Type as a generator to access MixRate. { _sampleHz = generator.MixRate; Player.Play(); _playback = (AudioStreamGeneratorPlayback)Player.GetStreamPlayback(); FillBuffer(); } } ``` -------------------------------- ### Start SkeletonIK Node Source: https://context7_llms Initiates the SkeletonIK effect. The `start()` method can be called with an optional boolean argument to control whether the IK effect is applied on the next frame or the current frame. This is useful for dynamically adjusting bone poses. ```gdscript # Apply IK effect automatically on every new frame (not the current) skeleton_ik_node.start() # Apply IK effect only on the current frame skeleton_ik_node.start(true) ``` -------------------------------- ### Get Root Motion Scale Delta (GDScript) Source: https://context7_llms Retrieves the scale change from the root motion track as a Vector3. Returns Vector3(0, 0, 0) if the track is not of type Animation.TYPE_SCALE_3D. Provides the basic example of applying scale to CharacterBody3D. ```GDScript Vector3 get_root_motion_scale ( ) const Retrieve the motion delta of scale with the root_motion_track as a Vector3 that can be used elsewhere. If root_motion_track is not a path to a track of type Animation.TYPE_SCALE_3D, returns Vector3(0, 0, 0). See also root_motion_track and RootMotionView. The most basic example is applying scale to CharacterBody3D: GDScript var current_scale: Vector3 = Vector3(1, 1, 1) var scale_accum: Vector3 = Vector3(1, 1, 1) func _process(delta): if Input.is_action_just_pressed("animate"): current_scale = get_scale() scale_accum = Vector3(1, 1, 1) state_machine.travel("Animate") ``` -------------------------------- ### Initialize GDExtension Library (GDScript) Source: https://context7_llms Initializes a GDExtension library to a specified initialization level. This allows for controlling when and how an extension is integrated into the engine's systems. ```GDScript var gde_extension = GDExtension.new() gde_extension.initialize_library(GDExtension.InitializationLevel.INITIALIZATION_LEVEL_SCENE) ``` -------------------------------- ### Set and Get AudioStreamWAV Loop Points Source: https://context7_llms Defines the start and end points for audio looping within an AudioStreamWAV. These points are specified in the number of samples and are automatically imported from WAV files if present. This allows for seamless repetition of audio segments. ```GDScript func set_loop_begin(value: int) -> void: # Sets the loop start point in number of samples. pass func get_loop_begin() -> int: # Returns the loop start point in number of samples. pass func set_loop_end(value: int) -> void: # Sets the loop end point in number of samples. pass func get_loop_end() -> int: # Returns the loop end point in number of samples. pass ``` -------------------------------- ### Load and Display Image using HTTPRequest (GDScript) Source: https://context7_llms This GDScript example demonstrates how to use the HTTPRequest node to fetch an image from a URL and prepare it for display. It includes setting up the request and connecting the completion signal. ```gdscript func _ready(): # Create an HTTP request node and connect its completion signal. var http_request = HTTPRequest.new() add_child(http_request) http_request.request_completed.connect(self._http_request_completed) # Perform the HTTP request. The URL below returns a PNG image as of writing. var error = http_request.request("https://via.placeholder.com/512") if error != OK: push_error("An error occurred in the HTTP request.") ``` -------------------------------- ### Configure TorusMesh Properties in Godot Engine (GDScript) Source: https://context7_llms This GDScript example shows how to set and get properties for a TorusMesh, which represents a torus shape. You can adjust the inner and outer radii, as well as the number of segments for the rings and the overall rings of the torus. ```gdscript # Set inner radius torusMesh.inner_radius = 0.5 # Get outer radius var outer_radius = torusMesh.outer_radius # Set ring segments torusMesh.ring_segments = 32 # Get rings var rings = torusMesh.rings ``` -------------------------------- ### Get RichTextLabel Text Content Source: https://context7_llms Retrieves different representations of the text content within a RichTextLabel. `get_parsed_text` returns the text without BBCode markup. `get_selected_text` returns the currently selected text, excluding BBCode. `get_selection_from` and `get_selection_to` return the start and end indices of the selection, respectively. ```gdscript String get_parsed_text ( ) const String get_selected_text ( ) const int get_selection_from ( ) const int get_selection_to ( ) const ``` -------------------------------- ### Node Initialization and Ready State Source: https://context7_llms Methods related to the node's initialization and its state when it becomes ready in the scene tree. ```APIDOC ## Node Initialization and Ready State ### Description These methods handle the initial setup of a node. `_ready` is called when the node and its children are ready in the scene tree, typically used for initialization tasks. ### Methods #### `_ready()` - **Description**: Called when the node is "ready", i.e. when both the node and its children have entered the scene tree. If the node has children, their `_ready` callbacks get triggered first, and the parent node will receive the ready notification afterwards. Corresponds to the `NOTIFICATION_READY` notification. See also the `@onready` annotation for variables. Usually used for initialization. For even earlier initialization, `Object._init` may be used. See also `_enter_tree`. Note: This method may be called only once for each node. After removing a node from the scene tree and adding it again, `_ready` will not be called a second time. This can be bypassed by requesting another call with `request_ready`, which may be called anywhere before adding the node again. - **Method**: `virtual` - **Parameters**: None. ``` -------------------------------- ### Instantiate Custom Tooltip Scene with C# Source: https://context7_llms This C# method demonstrates instantiating a custom tooltip from a scene file. It loads the PackedScene, instantiates it, and then sets the text of a Label node within the instantiated scene. ```C# public override Control _MakeCustomTooltip(string forText) { Node tooltip = ResourceLoader.Load("res://some_tooltip_scene.tscn").Instantiate(); tooltip.GetNode