### Set Skybox Material and Activate Source: https://docs.edenspark.io/index/sky_component.html Example of how to create render settings, get the Sky component, activate it, and assign a custom material with a specified texture. ```lua let renderSettings = create_render_settings() // equals to set_skybox(renderSettings, texture) get_component(renderSettings) $(var sky : Sky?) { sky.active = true sky.materialId = create_material(MaterialImport( shaderName = "sky_box", diffuse = texture )) } ``` -------------------------------- ### Launch EdenSpark installer with wine Source: https://docs.edenspark.io/getting_started/linux.html Execute the EdenSpark Windows installer using wine. Follow the on-screen prompts to complete the installation. ```shell wine edenspark_updater_1.0.0.14.exe ``` -------------------------------- ### Server-side Example Source: https://docs.edenspark.io/index/daslang/stdlib/generated/jsonrpc.html A simple server-side example demonstrating how to use `dispatch_line` to handle incoming JSON-RPC requests and send back responses. ```das require daslib/jsonrpc [export] def main() { let wire = "{\"id\":1,\"method\":\"ping\"}" let response = jsonrpc::dispatch_line(wire, false) $(method, params_json) { if (method == "ping") return "\"pong\"" return "\"unknown\"" } print("{response}\n") // → {"jsonrpc":"2.0","id":1,"result":"pong"} } ``` -------------------------------- ### Client-side Example Source: https://docs.edenspark.io/index/daslang/stdlib/generated/jsonrpc.html A client-side example showing how to construct a JSON-RPC request using `make_request` and parse the response using `parse_response`. ```das require daslib/jsonrpc [export] def main() { let wire = make_request("echo", "[1,2,3]", 7) // → {"jsonrpc":"2.0","id":7,"method":"echo","params":[1,2,3]} let reply_wire = "{\"jsonrpc\":\"2.0\",\"id\":7,\"result\":[1,2,3]}" let r = parse_response(reply_wire) if (r.is_success) print("got result for id={r.id_str}\n") } ``` -------------------------------- ### Basic DECS Boost Usage Example Source: https://docs.edenspark.io/index/daslang/stdlib/generated/decs_boost.html Demonstrates creating an entity with components, committing changes, and querying entities. Ensure `persistent_heap` is enabled for this example. ```das options persistent_heap = true require daslib/decs_boost [export] def main() { restart() create_entity() @(eid, cmp) { cmp |> set("pos", float3(1, 2, 3)) cmp |> set("name", "hero") } commit() query() $(pos : float3; name : string) { print("{name} at {pos}\n") } } // output: // hero at 1,2,3 ``` -------------------------------- ### Install wine on Arch Linux Source: https://docs.edenspark.io/getting_started/linux.html Use pacman to install the wine package on Arch Linux systems. ```shell sudo pacman -S wine ``` -------------------------------- ### is_starting Source: https://docs.edenspark.io/index/sound_core.html Checks if a specific sound is in the starting state. ```APIDOC ## is_starting ### Description Check if the sound state is `starting` (the sound has already been initialized but is not playing yet). ### Parameters #### Path Parameters - **sid** (SoundHandle) - The handle of the sound to check. ``` -------------------------------- ### Complete DasLang Program Example Source: https://docs.edenspark.io/index/daslang/reference/language/program_structure.html Demonstrates a full DasLang program incorporating options, requires, struct, enum, constants, variables, functions, and annotations like [init], [export], and [finalize]. This example simulates particle updates and manages their lifecycle. ```daslang options gen2 require math require daslib/strings_boost struct Particle { pos : float3 vel : float3 life : float } enum State { alive dead } let GRAVITY = float3(0.0, -9.8, 0.0) var particles : array def update_particle(var p : Particle; dt : float) : State { p.vel += GRAVITY * dt p.pos += p.vel * dt p.life -= dt if (p.life > 0.0) { return State.alive } return State.dead } [init] def setup { for (i in range(100)) { particles |> push(Particle(pos=float3(0), vel=float3(0, 10.0, 0), life=5.0)) } } [export] def main { let dt = 0.016 for (p in particles) { update_particle(p, dt) } print("particles: {length(particles)}\n") } [finalize] def cleanup { unsafe { delete particles } } ``` -------------------------------- ### ApplyMacro Example using AstCallMacro Source: https://docs.edenspark.io/index/daslang/reference/language/macros.html An example of a call macro named 'apply' implemented by inheriting from AstCallMacro. It demonstrates how to use the [call_macro] annotation for registration and overrides the visit method. ```das [call_macro(name="apply")] // apply(value, block) class ApplyMacro : AstCallMacro { def override visit ( prog:ProgramPtr; mod:Module?; var expr:ExprCallMacro? ) : ExpressionPtr { ... } } ``` -------------------------------- ### is_starting Source: https://docs.edenspark.io/index/sound_core.html Checks if a specific sound is currently in the process of starting. ```APIDOC ## is_starting ### Description Checks if a specific sound is currently in the process of starting. ### Method is_starting ### Parameters #### Path Parameters - **sid** (SoundHandle) - Required - The handle of the sound to check. ### Returns - bool: True if the sound is starting, false otherwise. ``` -------------------------------- ### Complete [class_method] Example Source: https://docs.edenspark.io/index/daslang/reference/language/classes.html A full example showcasing mutable and const static methods on a struct using '[class_method]', including a main function to demonstrate usage. ```daslang require daslib/class_boost struct Counter { value : int = 0 [class_method] def static increment(amount : int = 1) { value += amount } [class_method] def static const get_value : int { return value } [class_method] def static reset { value = 0 } } [export] def main { var c = Counter() c.increment() c.increment(10) print("value = {c.get_value()}\n") c.reset() print("after reset = {c.get_value()}\n") } ``` -------------------------------- ### Enable SSR Effect Source: https://docs.edenspark.io/index/ssr_settings_component.html This example demonstrates how to get the SSRSettings component and activate the SSR effect by setting its 'active' property to true. ```lua let renderSettings = create_render_settings() get_component(renderSettings) $(var ssr : SSRSettings?) { ssr.active = true } ``` -------------------------------- ### Initialize Scene with Camera, Light, and Rotating Cube Source: https://docs.edenspark.io/index/scene_core.html This snippet demonstrates how to set up a basic 3D scene. It includes adding render settings, a fixed camera, a directional light, a parent node at the origin, and a cube as a child of the parent node. The cube is assigned a mesh component. ```lua require engine.core var parentNode : NodeId [export] def on_initialize() { // add render settings with shadows and tonemapping let renderSettings = create_render_settings() get_component(renderSettings) $(var tonemap : Tonemap?) { tonemap.active = true } // create fixed camera add_component(create_node(NodeData(name="camera", position=float3(0, 0, -7))), new Camera()) // create light add_component(create_node(NodeData(name="sun"))), new DirectionalLight()) // create the parent node for the cube at the origin parentNode = create_node(NodeData(name="parent", position=float3(0))) // create the cube let cubeNode = create_node(NodeData(name="child", position=float3(-1, 0, 0), parent=parentNode)) add_component(cubeNode, new Mesh(meshId=CUBE_MESH_ID)) } ``` -------------------------------- ### begin Source: https://docs.edenspark.io/index/daslang/stdlib/generated/strudel_pattern.html Fluent shorthand for set_begin. Sets sample start position (0..1). ```APIDOC ## begin ### Description Fluent shorthand for set_begin. Sets sample start position (0..1). ### Method Pattern ### Parameters #### Path Parameters - **pat** (Pattern) - Required - The input pattern. - **b** (float) - Required - The sample start position (0..1). #### Query Parameters - **pat** (Pattern) - Required - The input pattern. - **mod_pat** (Pattern) - Required - A pattern to modulate the sample start position. ``` -------------------------------- ### Enable Tonemapping Source: https://docs.edenspark.io/index/tonemap_component.html Example of how to enable the Tonemap component by setting its 'active' property to true. This is typically done after creating render settings and getting the component. ```lua let renderSettings = create_render_settings() get_component(renderSettings) $(var tonemap : Tonemap?) { tonemap.active = true } ``` -------------------------------- ### Applying a Visitor to a Program Source: https://docs.edenspark.io/index/daslang/reference/language/macros.html Demonstrates how to create a visitor instance and use `make_visitor` to create an adapter, which is then applied to the entire program using the `visit` function. ```daslang var astVisitor = new PrintVisitor() make_visitor(*astVisitor) $ (astVisitorAdapter) { visit(this_program(), astVisitorAdapter) } ``` -------------------------------- ### on_initialize Source: https://docs.edenspark.io/index/main_loop.html This function is called once when the scene is first loaded, serving as the initial setup point. ```APIDOC ## on_initialize ### Description This function is called once when the scene is first loaded. ### Usage Example ```python [export] def on_initialize() { print("Hello, world!") } ``` ``` -------------------------------- ### Draw Line (float2, float2) Source: https://docs.edenspark.io/index/pixel_render.html Draws a line between two points specified as float2. Coordinates will be floored as centers of pixels. Requires the bitmap, start point, end point, and color. ```Example line(pixel_buffer, float2(10.0, 30.0), float2(100., 200.), 0xFF0400FF) // draws a blue line from (10, 30) to (100, 200) ``` -------------------------------- ### Configure SSAO Settings Source: https://docs.edenspark.io/index/ssao_settings_component.html Example of how to create render settings and configure SSAO properties like activation, method, and radius. ```lua let renderSettings = create_render_settings() get_component(renderSettings) $(var ssao : SSAOSettings?) { ssao.active = true ssao.method = SSAOMethod.GTAO ssao.worldRadius = 1.0 ssao.screenRadius = 4.0 ssao.strength = 0.7 } ``` -------------------------------- ### Example daScript requiring external modules Source: https://docs.edenspark.io/index/daslang/reference/embedding/external_modules.html This daScript code demonstrates how to require and use functions from external C, C++, and pure-das modules. Ensure modules are correctly installed and discoverable. ```das options gen2 require Hello/hello_module require Hello/hello_module_cpp require HelloModule require HelloCPP [export] def main() { print("Hello world!\n") print("{hello_from_das()}\n") // from das module print("{hello_from_c_module()}\n") // from C module print("{hello_from_cpp_module(\"Daslang\")}\n") // from C++ module } ``` -------------------------------- ### Compile-time Regex Matching and Iteration Source: https://docs.edenspark.io/index/daslang/stdlib/generated/regex_boost.html Demonstrates how to use the %regex~ reader macro to create precompiled regex objects for matching and iterating over text. The example shows how to get the match length and find all occurrences of a pattern. ```das require daslib/regex_boost require strings [export] def main() { var inscope re <- %regex~\d+%% let m = regex_match(re, "123abc") print("match length = {m}\n") let text = "age 25, height 180" regex_foreach(re, text) $(r) { print("found: {slice(text, r.x, r.y)}\n") return true } } // output: // match length = 3 // found: 25 // found: 180 ``` -------------------------------- ### Initialize UITextInput Source: https://docs.edenspark.io/index/ui_text_input_component.html Example of how to initialize a UITextInput component and set up an onChange handler. ```Python def init_text_input() { get_component(node) $(var textInput : UITextInput?) { textInput.onChange = @(newText : string) { print("Text changed to {newText}") } } } ``` -------------------------------- ### Deactivate Action Set Source: https://docs.edenspark.io/index/action_set_core.html Deactivates an existing action set. After deactivation, actions within this set will be disabled and their states cannot be queried. For example, getting the state of a 'move' action after deactivating its set would return nothing. ```lua deactivate_action_set("player") // let currentDirection = get_action_vector2("move") - will return nothing ``` -------------------------------- ### Configure HDSky Component Properties Source: https://docs.edenspark.io/index/hd_sky_component.html This example demonstrates how to add the HDSky component to render settings and modify its atmosphere and cloud properties. It shows setting atmosphere density and tint, and adjusting the start height, thickness, and coverage of cloud layers. ```csharp let renderSettings = create_render_settings() add_component(renderSettings, new HDSky()) get_component(renderSettings) $(var sky : HDSky?) { sky.atmosphere.mediaDensity = 0.3 sky.atmosphere.atmosphereTint = float3(0.7, 0.85, 1.0) sky.clouds.layers[0].startHeight = 0.5 let secondLayerHandle = sky.clouds.layers.push() secondLayerHandle.startHeight = 1.5 secondLayerHandle.thickness = 6.0 secondLayerHandle.coverage = 0.5 } ``` -------------------------------- ### Using filter to get even numbers Source: https://docs.edenspark.io/index/daslang/stdlib/generated/functional.html This example demonstrates how to use the 'filter' function to extract even numbers from a range iterator. The 'filter' function takes an iterator and a predicate function, returning a new iterator with elements that satisfy the predicate. ```das require daslib/functional [export] def main() { var src <- [iterator for (x in range(6)); x] var evens <- filter(src, @(x : int) : bool { return x % 2 == 0; }) for (v in evens) { print("{v} ") } print("\n") } // output: // 0 2 4 ``` -------------------------------- ### Initialize Scene with Hello World Source: https://docs.edenspark.io/getting_started/first_game.html Implement the on_initialize function to print a message when the scene loads. This is called once. ```python require engine.core [export] def on_initialize() { print("Hello, World") } ``` -------------------------------- ### Accessing and Modifying a Collider's Shape Source: https://docs.edenspark.io/index/collider_component.html This example demonstrates how to get a Collider component, access its first shape, cast it to a specific type (capsule) to retrieve a property (height), and then modify that shape by creating a new capsule shape with a reduced height. ```gdscript add_component(node, new Collider(shape = capsule_shape([height = 2.0]))) get_component(node) $(var coll: Collider?) { // Get the height of the capsule let height = (coll.shape as capsule).height // Modify the height of the capsule coll.shape = capsule_shape([height = height - 0.5]) } ``` -------------------------------- ### Create and Add Camera Component Source: https://docs.edenspark.io/index/camera_component.html This example demonstrates how to create a new node at a specific position and then add a Camera component to it. The camera is configured with a 60-degree field of view and a zfar clipping plane at 1000 units. ```lua // create node at float3(0, 0, -10) position var node = create_node(NodeData(position=float3(0, 0, -10))) // camera with field of view of 60 degrees and zfar clipping plane at a distance of 1000 add_component(node, new Camera(fov=60.0 * PI / 180.0, zfar = 1000.)) ``` -------------------------------- ### GET Route Registration/Client Request Source: https://docs.edenspark.io/index/daslang/stdlib/generated/dashv.html Registers a GET route handler or performs an HTTP GET client request. This operation is marked as unsafe. ```APIDOC ## GET Route Registration/Client Request ### Description Registers a GET route handler, or performs an HTTP GET client request. This is an unsafe operation. ### Method GET ### Endpoint `/url` ### Parameters #### Path Parameters - **server** (WebSocketServer) - Required - The WebSocket server instance (for registration). - **url** (string) - Required - The URL path for the route or client request. - **lambda** (lambda<():void>) - Required - The callback function to execute for registered handlers. ### Request Example (Registration) ``` GET(server, "/path", lambda { ... }) ``` ### Request Example (Client Request) ``` GET("/path", block { |response| ... }) ``` ### Response (No specific response details provided in the source) ``` ```APIDOC ## GET Route Registration (with headers) ### Description Registers a GET route handler with custom headers. ### Method GET ### Endpoint `/url` ### Parameters #### Path Parameters - **url** (string) - Required - The URL path for the route. - **headers** (table) - Required - A table of custom headers. - **block** (block<(HttpResponse?):void>) - Required - The callback function to execute. ### Request Example ``` GET("/path", {"Accept": "application/json"}, block { |response| ... }) ``` ### Response (No specific response details provided in the source) ``` -------------------------------- ### Initialize and Configure Blur Component Source: https://docs.edenspark.io/index/blur_component.html Example of how to create render settings, add a Blur component, and then activate it with a specific radius. The blur can be toggled on and off using the 'active' property. ```lua let renderSettings = create_render_settings() add_component(renderSettings, new Blur()) get_component(renderSettings) $(var blur : Blur?) { blur.active = true blur.radius = 5.0 } ``` -------------------------------- ### Get Current Character Source: https://docs.edenspark.io/index/daslang/stdlib/generated/peg.html A matching primitive function to get the current character being parsed. ```daslang def get_current_char (var parser: auto) : int ``` -------------------------------- ### slice (start) Source: https://docs.edenspark.io/index/daslang/stdlib/generated/strings.html Returns a substring of the input string from a specified start index to the end. ```APIDOC ## slice (start) ### Description Returns a substring of `str` from index `start` to the end of the string. Negative indices count from the end. ### Parameters * **str** (string) - The input string. * **start** (int) - The starting index for the slice. ``` -------------------------------- ### Configure Render Pipeline Settings Source: https://docs.edenspark.io/index/render_pipeline_component.html Example of how to create render settings and configure HDR mode and transparency sort mode using the Render Pipeline component. ```lua let renderSettings = create_render_settings() get_component(renderSettings) $(var rpSetup : RenderPipeline?) { rpSetup.hdrMode = HDRMode.HDR_RGBA16F rpSetup.transparencySortMode = TransparencySortMode.ByDistance } ``` -------------------------------- ### Start Game Coroutine on Initialization Source: https://docs.edenspark.io/index/coroutines_core.html This function is called on application initialization and starts the 'start_game' coroutine. ```lua def on_initialize() : void { start_coroutine(start_game()) } ``` -------------------------------- ### Configure Shadows for Small Scene Source: https://docs.edenspark.io/index/shadow_settings_component.html Example of setting up shadow properties for a small scene. Adjust shadow strength, number of cascades, and maximum shadow distance. ```lua let renderSettings = create_render_settings() // Set up shadows for small scene get_component(renderSettings) $(var shadows : ShadowSettings?) { shadows.shadowStrength = 0.5 // reduce shadow impact shadows.numCascades = 1 // use only one cascade because our scene is too small shadows.maxDist = 25f // set maximal distance for shadows to 25 meters, it is enough for our scene } ``` -------------------------------- ### get_physics_fps Source: https://docs.edenspark.io/index/physics_core.html Gets the fixed timestep for the physics. Note that if you want to get the frame time, you should use get_delta_time(). ```APIDOC ## get_physics_fps ### Description Gets the fixed timestep for the physics. Note that if you want to get the frame time, you should use get_delta_time(). ### Returns * **float** - frames per second of the physics simulation ``` -------------------------------- ### Check if String Starts With (Offset) Source: https://docs.edenspark.io/index/daslang/stdlib/generated/strings.html Checks if a string begins with a specified comparison string starting from a given offset. ```das starts_with (str: string; offset: int; cmp: string) : bool ``` -------------------------------- ### Create Base Render Settings Source: https://docs.edenspark.io/index/render_core.html Use `create_base_render_settings` to create render settings without any default components, useful for custom configurations. ```lua create_base_render_settings(_name: string = "render_settings") ``` -------------------------------- ### Install Debug Agent Source: https://docs.edenspark.io/index/daslang/stdlib/generated/debugapi.html Installs a low-level smart_ptr under a given category name. Prefer `install_new_debug_agent` for the high-level pattern. ```das install_debug_agent (agent: smart_ptr; category: string_) ``` -------------------------------- ### Scene Initialization Source: https://docs.edenspark.io/index/main_loop.html This function is called once when the scene is first loaded. Use it for initial setup. ```gdscript [export] def on_initialize() { print("Hello, world!") } ``` -------------------------------- ### slice (start, end) Source: https://docs.edenspark.io/index/daslang/stdlib/generated/strings.html Returns a substring of the input string from a specified start index to a specified end index (exclusive). ```APIDOC ## slice (start, end) ### Description Returns a substring of `str` from index `start` to `end` (exclusive). Negative indices count from the end. ### Parameters * **str** (string) - The input string. * **start** (int) - The starting index for the slice. * **end** (int) - The ending index for the slice (exclusive). ``` -------------------------------- ### CompositeBehNode.init Source: https://docs.edenspark.io/index/behtree.html Sets up parent references for all children and initializes them. ```APIDOC ## CompositeBehNode.init ### Description Sets up parent references for all children and initializes them. ### Method `init` ### Response #### Success Response - **void** - This method does not return a value. ``` -------------------------------- ### Install Thread-Local Debug Agent Source: https://docs.edenspark.io/index/daslang/stdlib/generated/debugapi.html Installs a low-level `smart_ptr` as the thread-local debug agent. Each thread can have only one thread-local agent. ```das install_debug_agent_thread_local (agent: smart_ptr) ``` -------------------------------- ### Define and Use an Interface with Implementations Source: https://docs.edenspark.io/index/daslang/stdlib/generated/interfaces.html This example demonstrates defining an abstract interface `IGreeter`, implementing it with `MyGreeter`, and using dynamic dispatch through an interface proxy. ```daslang require daslib/interfaces [interface] class IGreeter { def abstract greet(name : string) : string } [implements(IGreeter)] class MyGreeter { def IGreeter`greet(name : string) : string { return "Hello, {name}!" } } [export] def main() { var obj = new MyGreeter() var greeter = obj as IGreeter print("{greeter->greet("world")}\n") } // output: Hello, world! ``` -------------------------------- ### Get Multiple Components (Read-Only) Source: https://docs.edenspark.io/index/components_core.html Gets specific components attached to a node and calls a block for them. The components cannot be modified within the block. ```plaintext get_component(node) $(var comp1 : T1?, var comp2 : T2?, var comp3 : T3?) { // do something with the components } ``` -------------------------------- ### Get Multiple Components (Mutable) Source: https://docs.edenspark.io/index/components_core.html Gets specific components attached to a node and calls a block for them. The components can be modified within the block. ```plaintext get_component(node) $(var comp1 : T1?, var comp2 : T2?) { // do something with the components } ``` -------------------------------- ### Array Initialization and Manipulation Source: https://docs.edenspark.io/index/daslang/reference/language/datatypes.html Illustrates the creation of a fixed-size array with initial values and a dynamic array, including adding elements using `push`. ```daslang var a = fixed_array(1, 2, 3, 4) // fixed size of array is 4, and content is [1, 2, 3, 4] var b: array // empty dynamic array push(b,"some") // now it is 1 element of "some" ``` -------------------------------- ### Configure Ambient Light Settings Source: https://docs.edenspark.io/index/ambient_settings_component.html Example of how to set ambient light color, strength, and source using the AmbientSettings component. Ensure render settings are created and the component is obtained before configuration. ```lua let renderSettings = create_render_settings() get_component(renderSettings) $(var ambient : AmbientSettings?) { ambient.ambientColor = float3(0.95, 0.5, 0.7) ambient.ambientStrength = 1f ambient.ambientSource = AmbientSource.ConstColor } ``` -------------------------------- ### Perlin Noise 1D Usage Example Source: https://docs.edenspark.io/index/noise.html Example of using the 1D Perlin noise function. Scales the input coordinate before sampling. ```glsl let scale = 0.1 let value = perlin_noise(x * scale) ``` -------------------------------- ### Add SpotLight Component to Node Source: https://docs.edenspark.io/index/spot_light_component.html Example of creating a node and adding a SpotLight component with specified properties like color, intensity, shadow casting, radius, attenuation, and angle. ```lua var node = create_node(NodeData()) add_component(node, new SpotLight( color = float3(1), intensity = 0.5f, castShadows = false, radius = 10f, attenuation = 0.5f, angle = PI/4f )) ``` -------------------------------- ### Init Function for Initialization Source: https://docs.edenspark.io/index/daslang/reference/language/program_structure.html Demonstrates an '[init]' function that runs automatically during context initialization. These functions cannot have arguments or return values. ```daslang [init] def setup { print("initializing\n") } ``` -------------------------------- ### regex_search Source: https://docs.edenspark.io/index/daslang/stdlib/generated/regex.html Searches for the first occurrence of the regular expression anywhere in the string, starting from the specified offset. Returns the start and end positions of the match. ```APIDOC ## regex_search ### Description Searches for the first occurrence of the regular expression anywhere in `str`, starting from `offset`. Returns `int2(start, end)` on success, or `int2(-1, -1)` if not found. Unlike `regex_match`, this function scans the entire string. ### Signature regex_search(regex: Regex, str: string, offset: int = 0) : int2 ### Parameters * **regex** (Regex) - The compiled regular expression to search for. * **str** (string) - The string to search within. * **offset** (int) - The position in the string to start the search from. Defaults to 0. ``` -------------------------------- ### Base64 Encode and Decode Example Source: https://docs.edenspark.io/index/daslang/stdlib/generated/base64.html Demonstrates encoding a string to Base64 and then decoding it back. Shows the usage of base64_encode and base64_decode functions. ```daslang require daslib/base64 [export] def main() { let encoded = base64_encode("Hello, daslang!") print("encoded: {encoded}\n") let decoded = base64_decode(encoded) print("decoded: {decoded.text}\n") } // output: // encoded: SGVsbG8sIGRhU2NyaXB0IQ== // decoded: Hello, daslang! ``` -------------------------------- ### Perlin Noise 4D Usage Example Source: https://docs.edenspark.io/index/noise.html Example of using the 4D Perlin noise function. Scales the input 4D coordinate before sampling. ```glsl let scale = 0.1 let value = perlin_noise(float4(x, y, z, time) * scale) ``` -------------------------------- ### Perlin Noise 3D Usage Example Source: https://docs.edenspark.io/index/noise.html Example of using the 3D Perlin noise function. Scales the input 3D coordinate before sampling. ```glsl let scale = 0.1 let value = perlin_noise(float3(x, y, z) * scale) ``` -------------------------------- ### Batch Request Example Source: https://docs.edenspark.io/index/daslang/stdlib/generated/jsonrpc.html Demonstrates how to create and send a batch of JSON-RPC requests using `make_request`, `make_notification`, and `make_batch`. ```das require daslib/jsonrpc let entries <- [ make_request("a", "null", 1), make_notification("log", "{\"msg\":\"hi\"}"), make_request("b", "null", 2) ] let batch = make_batch(entries) let response = jsonrpc::dispatch_line(batch, false) $(method, params_json) { return "\"ok-{method}\"" } // response is a JSON array with two entries (notification suppressed). ``` -------------------------------- ### Initialize and Configure HDWater Source: https://docs.edenspark.io/index/hd_water_component.html Example of how to add the HDWater component to a render settings object and configure its level and wave strength. This demonstrates basic usage after including the necessary module. ```javascript let renderSettings = create_render_settings() add_component(renderSettings, new HDWater()) get_component(renderSettings) $(var water : HDWater?) { water.level = 1.0 water.wavesStrength = 0.8 } ``` -------------------------------- ### Perlin Noise 2D Usage Example Source: https://docs.edenspark.io/index/noise.html Example of using the 2D Perlin noise function. Scales the input 2D coordinate before sampling. ```glsl let scale = 0.1 let value = perlin_noise(float2(x, y) * scale) ``` -------------------------------- ### Using the `get` Function with a Callback Source: https://docs.edenspark.io/index/daslang/reference/language/tables.html Shows how to safely retrieve a value from a Daslang table using the `get` function and process it with a callback if the key exists. ```daslang let tab <- { "one"=>1, "two"=>2 } let found = get(tab,"one") $(val) { assert(val==1) } assert(found) ``` -------------------------------- ### Launch AI Tool from Project Directory Source: https://docs.edenspark.io/getting_started/vibecoding.html Navigate to your project directory in the terminal and launch your AI tool. This ensures the tool detects the MCP configuration for EdenSpark integration. ```bash cd /path/to/your/project claude ``` -------------------------------- ### Get Single Component (Mutable) Source: https://docs.edenspark.io/index/components_core.html Gets a specific component attached to a scene node and calls a block for the component. The component can be modified within the block. ```plaintext get_component(node) $(var rigidBodyComp : RigidBody?) { // do something with the component } ``` -------------------------------- ### Variable Initialization Modes in Daslang Source: https://docs.edenspark.io/index/daslang/reference/language/move_copy_clone.html Demonstrates the three fundamental initialization operators for variables: copy, move, and clone. ```daslang var x = expr // copy initialization var x <- expr // move initialization var x := expr // clone initialization ``` -------------------------------- ### Custom EnumTotalAnnotation Example Source: https://docs.edenspark.io/index/daslang/reference/language/macros.html Example of a custom enumeration annotation that registers a macro named 'enum_total' to modify enumerations. The annotation is applied to an enum definition. ```daslang [enumeration_macro(name="enum_total")] class EnumTotalAnnotation : AstEnumerationAnnotation { def override apply(var enu : EnumerationPtr; var group : ModuleGroup; args : AnnotationArgumentList; var errors : das_string) : bool { // modify enu.list or generate code return true } } [enum_total] enum Direction { North; South; East; West } ``` -------------------------------- ### Audio Setup Functions Source: https://docs.edenspark.io/index/daslang/stdlib/generated/strudel_midi_player.html Functions for configuring audio output and setting track volumes. ```APIDOC ## midi_set_audio_vis_channel ### Description Register a channel that will receive rendered audio chunks for visualization. Should be called before `midi_init`. ### Method N/A (Function call) ### Endpoint N/A ### Parameters #### Path Parameters - **ch** (Channel?) - Required - The channel to register for audio visualization. ### Response No specific response documented, assumed to be void or status. ### Response Example (No example provided) ``` ```APIDOC ## midi_set_volume ### Description Set the linear gain of a named track, optionally fading over a specified duration. ### Method N/A (Function call) ### Endpoint N/A ### Parameters #### Path Parameters - **name** (string) - Required - The name of the track to adjust. - **volume** (float) - Required - The target linear gain (volume). - **fade** (float) - Optional - The duration in seconds over which to fade to the new volume (default: 0.0, meaning instantaneous). ### Response No specific response documented, assumed to be void or status. ### Response Example (No example provided) ``` -------------------------------- ### smoothStartArch3 Source: https://docs.edenspark.io/index/easing.html Smooth start arch function. This is a cubic arch that starts with a slow increase to 1 and then a fast decrease to 0. Note that it ends at 0, not 1. ```APIDOC ## smoothStartArch3 ### Description Smooth start arch function (cubic arch, slow increase to 1 and then fast decrease to 0). Note that it ends at 0., not 1. ### Parameters #### Path Parameters - **p** (float) - Required - Normalized time (0..1). ``` -------------------------------- ### Create and Configure HDSkyOrigin Source: https://docs.edenspark.io/index/hd_sky_origin_component.html Example of creating a node, adding the HDSkyOrigin component, and specifying which sky components it should affect using bitwise OR. ```plaintext let skyOrigin = create_node(NodeData(position = float3(0, 5, 10))) add_component(skyOrigin, new HDSkyOrigin(targets = HDSkyOriginTargets.BaseClouds | HDSkyOriginTargets.StrataClouds)) ``` -------------------------------- ### Enable and Configure Bloom Component Source: https://docs.edenspark.io/index/bloom_component.html This example demonstrates how to enable the Bloom component and set its intensity. It retrieves the Bloom component from render settings and modifies its properties. ```lua let renderSettings = create_render_settings() get_component(renderSettings) $(var bloom : Bloom?) { bloom.active = true bloom.intensity = 0.8 } ``` -------------------------------- ### install_debug_agent_thread_local Source: https://docs.edenspark.io/index/daslang/stdlib/generated/debugapi.html Installs a low-level `smart_ptr` as the thread-local debug agent. There can be only one thread-local agent per thread — installing a new one replaces the previous. ```APIDOC ## install_debug_agent_thread_local ### Description Installs a low-level `smart_ptr` as the thread-local debug agent. There can be only one thread-local agent per thread — installing a new one replaces the previous. ### Method (Implicitly a function call, not HTTP) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Arguments * **agent** (smart_ptr) - The debug agent to install as thread-local. ``` -------------------------------- ### Creating and Configuring a UIImage Source: https://docs.edenspark.io/index/ui_image_component.html This snippet demonstrates how to create a UI element with an image component, set its texture, and define its size. Ensure the 'size' property is set for the image to be visible. ```rust let canvas = create_node() add_component(canvas, new UICanvas()) let image = create_node(NodeData(parent = canvas, position = float3(100.0, 100.0, 0.0) )) add_component(image, new UIImage( textureId = request_texture("image.png"), size = float2(100., 100.) )) ``` -------------------------------- ### Complete Class Example with Inheritance and Virtual Dispatch Source: https://docs.edenspark.io/index/daslang/reference/language/classes.html Demonstrates inheritance, abstract methods, custom initializers, and virtual dispatch in DasLang classes. Includes Shape, Circle, and Rectangle classes with a main function to showcase polymorphism. ```das class Shape { name : string def abstract area : float def describe { print("{name}: area = {area()}\n") } } class Circle : Shape { radius : float def Circle(r : float) { name = "Circle" radius = r } def override area : float { return 3.14159 * radius * radius } } class Rectangle : Shape { width, height : float def Rectangle(w, h : float) { name = "Rectangle" width = w height = h } def override area : float { return width * height } } [export] def main { var shapes : array unsafe { shapes |> push(new Circle(5.0)) shapes |> push(new Rectangle(3.0, 4.0)) } for (s in shapes) { s.describe() } unsafe { for (s in shapes) { delete s } } } ``` -------------------------------- ### Get Velocity at World Position Source: https://docs.edenspark.io/index/physics_core.html Gets the velocity of a rigid body at a specific point in world coordinates. This can be useful for calculating forces or understanding motion at a particular location. ```gdscript get_velocity_at(_rigidBody: RigidBody?; worldPosition: float3_): float3 ``` -------------------------------- ### Move, Copy, and Clone Example in Daslang Source: https://docs.edenspark.io/index/daslang/reference/language/move_copy_clone.html Demonstrates the usage of copy, move, and clone operators with scalar and container types. Shows how 'a = b' copies scalars, 'data <- make_data()' moves container ownership, and 'cloned := moved' creates a deep copy. ```daslang options gen2 def make_data() : array { var result : array result |> push(1) result |> push(2) result |> push(3) return <- result } [export] def main { // Copy (scalars) var a = 10 var b = a print("copy: a={a} b={b}\n") // Move (containers) var data <- make_data() print("data = {data}\n") var moved <- data print("moved = {moved}\n") print("data after move = {data}\n") // Clone (deep copy) var cloned : array cloned := moved cloned |> push(4) print("cloned = {cloned}\n") print("moved = {moved}\n") } ``` -------------------------------- ### Get Single Component with Callback (Read-Only) Source: https://docs.edenspark.io/index/components_core.html Gets a specific component attached to a scene node and calls a provided block for the component. The component cannot be modified within the block. ```plaintext get_component(node) $(rigidBodyComp : RigidBody?) { // do something with the component } ``` -------------------------------- ### Initialize UIButton Source: https://docs.edenspark.io/index/ui_button_component.html Example of how to initialize a UIButton and assign an onClick event handler. The UIFrame component is automatically added if not present. ```lua def init_button() { get_component(node) $(var btn : UIButton?) { btn.onClick = @() { print("Button {btn.nodeId} clicked!") } } } ``` -------------------------------- ### Add DirectionalLight to a Node Source: https://docs.edenspark.io/index/directional_light_component.html Example of adding a DirectionalLight component to a node. This specific example creates a light with white color, 0.5 intensity, and disables shadow casting. ```lua var node = create_node(NodeData()) // directional light with color (1f, 1f, 1f), intencity 0.5f and no shadow casting add_component(node, new DirectionalLight( color = float3(1), intensity = 0.5f, castShadows = false )) ``` -------------------------------- ### Container Move During Iteration Example Source: https://docs.edenspark.io/index/daslang/reference/language/very_safe_context.html Shows a hazard where a container is moved while being iterated over, potentially leading to runtime errors. This example illustrates the issue that `very_safe_context` helps to manage. ```daslang var a <- [1, 2, 3, 4] var b : array for (i, x in count(), a) { if (i == 0) { b <- a } x++ } ``` -------------------------------- ### simulate Source: https://docs.edenspark.io/index/daslang/stdlib/generated/rtti.html Simulates (links and initializes) a compiled `Program`, returning a `Context` pointer ready for function execution, or null on failure. ```APIDOC ## simulate ### Description Simulates (links and initializes) a compiled `Program`, returning a `Context` pointer ready for function execution, or null on failure. ### Method simulate ### Parameters #### Path Parameters - **program** (smart_ptr const&) - implicit - A constant reference to the compiled `Program` object to simulate. - **block** (block<(bool;smart_ptr;das_string):void>) - implicit - A callback block that is executed after simulation, receiving the success status, the created `Context` pointer, and any error string. ``` -------------------------------- ### BlendingMethod Weight Calculation Example Source: https://docs.edenspark.io/index/scene_core.html Shows the resulting weight distribution after applying BlendingMethod.Overlay and BlendingMethod.BlendSublayer. ```plaintext Top Layer = 50% Middle Layer, Sublayer 1 = 20% * 80% * (100 - 50%) = 8% Middle Layer, Sublayer 2 = 30% * 80% * (100 - 50%) = 12% Middle Layer, Sublayer 3 = 50% * 80% * (100 - 50%) = 20% Bottom Layer = (100 - 50%) * (100 - 80%) = 10% Total = 100% (always normalized). ``` -------------------------------- ### Expect Declaration with Code Example Source: https://docs.edenspark.io/index/daslang/reference/language/program_structure.html Provides a concrete example of using 'expect' to verify that the compiler correctly rejects copying an array, expecting a specific error code. ```daslang expect 30507 // cant_copy [export] def main { var a <- [1, 2, 3] var b = a // error: can't copy array } ``` -------------------------------- ### Define Coroutine to Start Game Sequence Source: https://docs.edenspark.io/index/coroutines_core.html This coroutine orchestrates the game start sequence by first awaiting a mouse press and then initiating a smooth movement coroutine for a 'cube' node. ```lua [async] def start_game() : void { // Step 1 - wait for mouse press await(await_mouse_press()) // Step 2 - move the cube // 'cube' is a NodeId created earlier start_coroutine(cube, smooth_move(cube, float3(0, 0, 0), float3(0, 0, 1), 1.)) } ```