### For Loop Example (1 to 100 step 10) Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/scripting-language Example of a for loop iterating from 1 to 100 in steps of 10, shown in both Pascal-like and C-like syntax. ```pascal for x := 1 to 100 step 10 do begin // Code to be executed end; ``` ```c for (x = 1; x <= 100; x += 10) { // Code to be executed } ``` -------------------------------- ### While Loop Example (a < b) Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/scripting-language Example of a while loop that increments 'a' and halves 'b' until 'a' is no longer less than 'b'. Comments show alternative C-like operators. ```pascal while a < b do begin a = a + 1; // you could use a++; b = b / 2; // you could use b /= 2; end; ``` -------------------------------- ### Loop with Break Example Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/scripting-language Example of a loop with a Break statement to exit when 'a' reaches or exceeds 'b'. Uses the Pascal-like syntax. ```pascal loop a++; if a >= b then Break; // exit the loop if a >= b end; ``` -------------------------------- ### Set global variable Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/basic-script-layout Optional: Sets a global variable. Example sets speed to 10. ```raylectron speed = 10; ``` -------------------------------- ### Array Assignment and Indexing Example Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/scripting-language Array assignment and indexing example. Indexing is zero-based, so Sequence[1] is the second element with value 65, not 23. ```pascal Sequence = [23, 65, 2, 9, 30]; x = Sequence[1]; // Assigns 65 to x ``` -------------------------------- ### Conditional Statement Example (if object = 'Spaceship') Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/scripting-language Example of an if/then statement that hides an object when its name equals 'Spaceship'. Shows the Pascal-like and C-like syntax variants. ```pascal if object = 'Spaceship' then Hide; ``` ```c if (object == 'Spaceship') { Hide; } ``` -------------------------------- ### For/Loop Statement Syntax Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/scripting-language For/loop statement syntax. Iterates 'x' from 'start' to 'end' with a specified step value. ```pascal for x = start to end step Value do Statement; ``` -------------------------------- ### Set unit of measure with setUnits Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/basic-script-layout Optional: Sets the unit of measure if different from the 'Options' menu. Example uses Meters. ```raylectron setUnits(Meters); ``` -------------------------------- ### Set unit of angle with SetAngleUnits Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/basic-script-layout Optional: Sets the unit of angle. Example uses Degree. ```raylectron SetAngleUnits(Degree); ``` -------------------------------- ### Raylectron fly-by ship animation script Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/examples/fly-by-ship Sets units to meters, makes the camera keep looking at the ship, and accelerates the ship 80 meters over 4 seconds starting at 1 second into the video. ```raylectron SetUnits(Meters); // set our unit of measurement to meters. Look; // camera keeps on looking at the ship Accelerate(py, 80, 1, 5); // accelerate 80 meters in 4 seconds, starting at 1 second into the video. ``` -------------------------------- ### Invoke Steer function Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/built-in-functions/specialized-functions Call Steer with the vehicle's yaw (rz), speed along Y-axis (py), wheelbase, and track to get the front wheel angle. ```raylectron frontWheelAngle = Steer(rz, py, wheelbase, track); ``` -------------------------------- ### Stargate iris animation script Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/examples/rings Script for the Stargate iris example. It detaches all 20 segments of the iris object and applies a roll animation with parameters 51, 1, and 5. ```raylectron uses 'iris'; if object = 'iris' then begin Detached; // detach all 20 segments Roll(51, 1, 5); end; ``` -------------------------------- ### CamRotAround function Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/rotation-variables/camera-rotation Rotates the camera around the specified axis (Xaxis, Yaxis, or Zaxis) by a given angle, with smooth rotation starting at StartAt seconds and ending at EndAt seconds into the video. The camera direction is not changed to face the object; use the Look command before this one for that. ```plaintext CamRotAround(Axis, Angle, StartAt, EndAt); ``` -------------------------------- ### Complete script using Steer Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/built-in-functions/specialized-functions A full Raylectron script demonstrating the Steer function in a vehicle animation, including object declarations, unit settings, initialization, and per-object scripts. ```raylectron // declare objects to use uses 'car', 'body', 'wheel fr', 'wheel br', 'wheel fl', 'wheel bl', 'wheel box fr', 'wheel box fl' ; // Set default units SetUnits(Meters); SetAngleUnits(Degree); // initialize variable(s) if FirstPass then begin wheelbase = Distance('wheel fr', 'wheel br'); track = Distance('wheel fr', 'wheel fl'); CurDist = 0; frontWheelAngle = 0; end; // scripts for object(s) case object of 'body': begin Look; end; 'car': begin Accelerate(py, 17, 1, 9); CurDist = py; Yaw(-47, 8, 16); Pitch(3.2, 11, 13.5); frontWheelAngle = Steer(rz, py, wheelbase, track); end; 'wheel box fr', 'wheel box fl': begin RotZ = frontWheelAngle; end; 'wheel fr', 'wheel fl', 'wheel br', 'wheel bl': begin Spin(Xaxis, CurDist); end; end; ``` -------------------------------- ### Define objects to animate with uses statement Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/basic-script-layout Lists the names of objects to animate between single quotes, separated by commas. This ensures the script runs only on these defined objects. ```raylectron uses 'Spaceship', 'Towtruck'; ``` -------------------------------- ### Define custom function CalculateSomething Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/basic-script-layout Optional: Write your own functions and include them in the first section. The function CalculateSomething computes b*b + a*a and assigns it to Result. ```raylectron function CalculateSomething(a, b) begin // Function logic goes here Result = b*b + a*a; end; ``` -------------------------------- ### F-302 advanced animation script with flight path and gear retraction Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/examples/f-302-by-gategirl86-advanced Complete Raylectron animation script for an F-302 fighter. It uses the 'uses' clause to reference model parts, initializes runway lights and jet engines on the first pass, sets up blinking lights, and defines a case statement that animates the craft's flight path and retracts the landing gear and bay doors at the specified times. ```pascal uses 'f302_g', 'starboard stern wheel assembly', 'starboard stern wheel arms', 'port stern wheel assembly', 'port stern wheel arms', 'bow wheel assembly', 'bow wheel arm', 'bow wheel left door', 'bow wheel right door', 'starboard wheel left door', 'starboard wheel right door', 'port stern wheel left door', 'port stern wheel right door'; if FirstPass then begin // runway lights SetLight('Emitter - B01', True); SetLight('Emitter - B02', True); SetLight('Emitter - B03', True); SetLight('Emitter - B04', True); SetLight('Emitter - B05', True); SetLight('Emitter - B06', True); SetLight('Emitter - B07', True); SetLight('Emitter - B08', True); SetLight('Emitter - B09', True); // Initialize jet engines SetLight('emitter_main-engine1', False); SetLight('emitter_jet2', True); end; // setup blinking runway lights BlinkLight('Emitter - B01', 1, 0.0, 87); BlinkLight('Emitter - B02', 1, 0.1, 87); BlinkLight('Emitter - B03', 1, 0.2, 87); BlinkLight('Emitter - B04', 1, 0.3, 87); BlinkLight('Emitter - B05', 1, 0.4, 87); BlinkLight('Emitter - B06', 1, 0.5, 87); BlinkLight('Emitter - B07', 1, 0.6, 87); BlinkLight('Emitter - B08', 1, 0.7, 87); BlinkLight('Emitter - B09', 1, 0.8, 87); // ship blinking lights BlinkLight('nav_light', 3, 0, 999); BlinkLight('emitter_tail_nav', 1, 0, 999); BlinkLight('emitter_blue_tailigh', 2, 0, 999); // when to hide wheel assembly StartAt = 62; HideIt = sec > StartAt+7; case object of 'f302_g': begin Look; // Keep craft in view Accelerate(py, 46, 1, 25); //start going TimeDecelerate(py, 20, 45); // slowdown Yaw(-90, 23, 38); // and turn Zoom(1.7, 1, 36); Zoom(1/1.7, 36, 50); // Turn on main engine if sec = 45 then SetLight('emitter_main-engine1', True); Accelerate(py, 400, 50, 55); // full takeoff Pitch(25, 55, 58); // nose up // Lets have a closer look at the craft Zoom(7, 57, 60); // come back Roll(45, 56, 62); Pitch(180, 56, 66); Yaw(85, 56, 62); // go back horizontal and keep watching Roll(-90, 62, 67); // Nose down a bit while we watch Pitch(-55, 66, 68); // do a 360.0 roll Roll(360, 68, 70); // Watch it leave Pitch(90, 70, 75); // Zoom back out Zoom(1/4, 70, 72); // Now zoom way in Zoom(7, 74, 76); end; // retract the wheels and close bay doors 'starboard stern wheel assembly', 'port stern wheel assembly': begin if HideIt then Hide; Accelerate(pz, 1.2, StartAt, StartAt+5.5); if sec > StartAt+4 then pz = 0; Pitch(95, StartAt+3, StartAt+7); end; 'bow wheel assembly': begin if HideIt then Hide; Accelerate(pz, 1.2, StartAt, StartAt+5.5); if sec > StartAt+4 then pz = 0; Pitch(-95, StartAt+3, StartAt+7); end; 'starboard stern wheel arms', 'port stern wheel arms': begin if HideIt then Hide; Pitch(-140, StartAt+3, StartAt+7); end; 'bow wheel arm': begin if HideIt then Hide; Pitch(140, StartAt+3, StartAt+7); end; 'bow wheel left door': begin Roll(-135.0, StartAt+6, StartAt+8); end; 'bow wheel right door': begin Roll(135.0, StartAt+6, StartAt+8); end; 'starboard wheel left door': begin Pitch(-105, StartAt+6, StartAt+8); end; 'starboard wheel right door', 'port stern wheel right door': begin Pitch(105, StartAt+6, StartAt+8); end; 'port stern wheel left door': begin Pitch(-104, StartAt+6, StartAt+8); end; end; ``` -------------------------------- ### Ball component script for falling and rolling animation Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/examples/falling-and-rolling-soccer-ball Script for the ball component that sets units to meters, initializes velocity on first pass, applies free fall with gravity, and adds forward motion and rotation to the ball and inner ball. ```raylectron uses 'Ball', 'Inner Ball'; SetUnits(Meters); if FirstPass then Velocity = 0; dist = 0.04; if object = 'Ball' then begin FreeFall(Velocity, 9.8, 0.7, 0.1090147); px = dist; // apply some forward motion end; if object = 'Inner Ball' then ry = (-dist / (PI2*0.1090147)) * 360; ``` -------------------------------- ### Camera rotation: CamPitch, CamYaw, CamRoll Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/built-in-functions/pitch-yaw-and-roll Use these functions to rotate the camera. Angle is in degrees, StartAt and EndAt define the time interval for the motion; after EndAt the camera keeps the final orientation. CamPitch adjusts CamRotX, CamYaw adjusts CamRotY, and CamRoll adjusts CamRotZ. ```plaintext CamPitch(Angle, StartAt, EndAt); CamYaw(Angle, StartAt, EndAt); CamRoll(Angle, StartAt, EndAt); ``` -------------------------------- ### Object-specific animation code with case statement Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/basic-script-layout Second section of the script: uses a case statement to differentiate between objects and execute corresponding code. Must include code for each object defined in the first section. ```raylectron case object of 'Spaceship': begin // Write your code for the Spaceship object here end; 'Towtruck': begin // Write your code for the Towtruck object here end; end; ``` -------------------------------- ### Calculate wheelbase and track using Distance Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/built-in-functions/specialized-functions Assuming wheel labels 'fr', 'fl', 'br', 'bl' and wheel axes at center of rotation, compute wheelbase as distance between front right and back right wheels, and track as distance between front right and front left wheels. ```raylectron wheelbase = Distance('wheel fr', 'wheel br'); track = Distance('wheel fr', 'wheel fl'); ``` -------------------------------- ### Conditional Statement Syntax (if/then) Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/scripting-language Conditional statement syntax in both Pascal-like and C-like forms. Use the Pascal-like form with 'then' and a semicolon, or the C-like form with parentheses and braces. ```pascal if Expression then Statement; ``` ```c if (Expression) { Statement; } ``` -------------------------------- ### Unless Loop Syntax Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/scripting-language Unless loop syntax in Pascal-like form and its C-like equivalent using a negated while condition. The loop executes while the expression is false. ```pascal unless Expression do Statement; ``` ```c while (!(Expression)) { Statement; } ``` -------------------------------- ### While Loop Syntax Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/scripting-language While loop syntax in both Pascal-like and C-like forms. The loop repeats the statement as long as the expression evaluates to true. ```pascal while Expression do Statement; ``` ```c while (Expression) { Statement; } ``` -------------------------------- ### Object rotation: Pitch, Yaw, Roll Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/built-in-functions/pitch-yaw-and-roll Use these functions to rotate an object around its local axes. Angle is in degrees, StartAt and EndAt define the time interval for the motion; after EndAt the object keeps the final orientation. Pitch adjusts rx, Yaw adjusts ry, and Roll adjusts rz. ```plaintext Pitch(Angle, StartAt, EndAt); Yaw(Angle, StartAt, EndAt); Roll(Angle, StartAt, EndAt); ``` -------------------------------- ### Repeat-Until Loop Syntax Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/scripting-language Repeat-until loop syntax. The statement executes at least once and repeats until the expression becomes true. ```pascal repeat Statement; until Expression; ``` -------------------------------- ### Spin object over distance: Spin(Axis, Distance) Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/built-in-functions/pitch-yaw-and-roll Use this function to spin an object over a given distance. Axis must be one of Xaxis, Yaxis, or Zaxis. The function automatically computes the object's circumference and the required rotation angle, updating the corresponding Rx, Ry, or Rz variable. ```plaintext Spin(Axis, Distance); ``` -------------------------------- ### Steer function signature Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/built-in-functions/specialized-functions The Steer function takes four parameters: angle, speed, wheelbase, and track, and returns the precise angle to rotate the front wheels of a four-wheeled vehicle. ```raylectron Steer(angle, speed, wheelbase, track); ``` -------------------------------- ### Apply front wheel angle to RotZ Source: https://raylectron.com/webver2/docs/welcome-to-the-raylectrons-animation-wiki/built-in-functions/specialized-functions Assign the output of Steer to the animator variable RotZ to rotate the front wheels around their Z-axis. ```raylectron RotZ = frontWheelAngle; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.