*******************************************************************************
                   NINE THINGS TO KEEP ALWAYS IN MIND!!
*******************************************************************************

1) An Elastic Game is made of independent elements doing actions into virtual space or on the screen, just like the real world. There is not a single program controlling the game. The graphic engine does not control any game's event. It just shows what happens in the virtual world at any time.

2) All game's elements are listed in the main 3D Rad screen (List Editor).

3) Modifying an Elastic Game means just modifying elements brain, graphic and sound.

4) All elements actions are defined in their brain, as a list of instructions (brain script).

5) Each brain script is entirely executed 30 times per second.

6) The first step for a novice user is loading an Elastic Game, choosing an element on the list, entering the Brain Script Editor (B button), hacking with the brain instructions, run the game and see what happens.

7) In brain scripts, lines starting with the ; character are just comments, to explain what the following brain instructions do. All lines NOT starting with the ; character are brain instructions. To know more about an instruction, press the Ctrl+H keys combination and search for it scrolling the text.

8) In brain scripts, the word 'element' indicates the current element, that is the element hosting the current brain. The form element#1, element#2, etc. indicates the first, second, etc. element following the current one, in the list (the element#-1, element#-2, etc. syntax is permitted too).

9) In brain scripts, measure units can be: generic (simple value), meters (mt), meters per second (ms), degrees (dg), round per minute (rm).  

All brain scripts are self-explaining. For more info see the complete 3D Rad manual in the c:\3drad\3draddoc.hlp file.

Below you can find detailed information about all brain instructions (press PagUp/PagDown keys to scroll)
 
*******************************************************************************
                HOW TO AUTOMATICALLY FIND WORDS IN THIS DOCUMENT
*******************************************************************************

1. type the text to find and select it (click and drag)
2. press F4 to store it as text to find
3. press F3 to find the text (press again for next occurrence)

*******************************************************************************
                              HOT KEYS REFERENCE
*******************************************************************************

LIST EDITOR
F2. Save current project
CursorUp/Dn. Move yellow cursor to the previous/next element group
Shift+CursorUp/Dn. Move yellow cursor to the previous/next element
R. Rename selected elements
B. Edit selected element's brain
Ctrl+C. Change selected element's brain
Esc. Exit 3D Rad

VIRTUAL EDITOR
A/Z. Zoom in/out current view
PagUp/Dn. Select previous/next element group
Shift+PagUp/Dn. Select previous/next element
Alt+Mouse. Set current element velocity property

NUMERIC EDITOR
CursorUp/Dn. Select previous/next item
PagUp/Dn. Select previous/next element
Ctrl+Space. Run current project

BRAIN SCRIPT EDITOR
F1. Load a brain script
F2. Save current brain script
F3. Find the text stored (see F4)
F4. Store selected block as text to find
Mouse drag. Select a block of text
Ctrl+X. Cut selected block
Ctrl+C. Copy selected block
Ctrl+V. Paste selected block
Alt+D. Kill current line
Ctrl+U. Undo last text editing
Ctrl+R. Redo last undone text editing
Ctrl+A. Indent the listing
Ctrl+H. View help doc

LOAD SELECTORS
Esc. Abort load operation.
MousePointer+Del. Erase pointed item from the system.

INPUT GADGETS
RightMouseButton or Esc. Confirm typed data

DIALOG BOXES
Enter. Select left choice
Del. Select Right choice

FUNCTION MENUS
F1. First item
F2. Second item
...and so on 

*******************************************************************************
               BRAIN INSTRUCTIONS REFERENCE (ALPHABETICAL ORDER)
*******************************************************************************

-------------------------------------------------------------------------------
ABOVE_GROUND_LEVEL(Element)
Returns the specified element above ground level, that is the Y distance from the ground element. 

-------------------------------------------------------------------------------
ABSOLUTE_VALUE(Value)
Returns the absolute value of Value.

-------------------------------------------------------------------------------
ANIMATE(Element,ShapeStart,ShapeEnd,Rate)
Performs animation loop for specified element. Animation cycles from ShapeStart to ShapeEnd. The Rate parameter specifies the animation frame rate (128=30fps).

If Rate is negative the animation is backward.

If the specified element aspect component is not an animation, or if the ShapeEnd value is bigger than the available animation frames, the animation is not performed.

;animating an element with
;an aspect component made of
;a 30 frames loop animation
animate(element,1,30,128)

It can be used as a function too, giving the last played frame as return value:

;animating an element with
;an aspect component made of
;a 30 frames non-looping animation
if animate(element,1,30,128)=30
  off(element)
endif

-------------------------------------------------------------------------------
ANIMATION_FRAME(Element)
Returns the current animation frame for the specified Element.

-------------------------------------------------------------------------------
ANIMATION_FRAME_SET(Element,Frame)
Sets the specified animation Frame for the specified Element. If the specified Frame doesn't exists, nothing happens.

-------------------------------------------------------------------------------
ANY_INPUT()
Returns -1 if any keyboard key, or any joystick button, is pressed (returns 0 otherwise). 

-------------------------------------------------------------------------------
ATAN_512(Value)
Returns the specified value arctangent (degrees*512).

-------------------------------------------------------------------------------
ATTRACT(Element,Target,Intensity)
Attracts the specified Element towards the Target element. Intensity is the attraction intensity. Negative intensity values perform a repulsion.

;making a flying bomb follow the
;target element
attract(element,target,12000)

-------------------------------------------------------------------------------
ATTRACT_POINT(Element,TargetX,TargetY,TargetZ,Intensity)
Attracts the specified Element towards the target location (TargetX,TargetY,TargetZ). Intensity is the attraction intensity. Negative intensity values perform a repulsion.

-------------------------------------------------------------------------------
ATTRACT_XR(Element,Degrees,Step)
Makes the specified X element rotation tend to the specified rotation (degrees). The Step value is in degrees and it is the strength of the trend. The ATTRACT_YR and ATTRACT_ZR syntax is permitted too.

;holding a boat upright
attract_xr(element,0dg,2dg)
attract_zr(element,0dg,1dg)

-------------------------------------------------------------------------------
ATTRACT_XZ(Element,Target,Intensity)
Attracts the specified Element towards the Target element (vertical position and velocity are not changed). Intensity is the attraction intensity. Negative intensity values perform a repulsion.

-------------------------------------------------------------------------------
ATTRACT_Y(Element,Target,Intensity)
Attracts the specified Element to the same Target element Y position (horizontal position and velocity are not changed). Intensity is the attraction intensity. Negative intensity values perform a repulsion.

-------------------------------------------------------------------------------
BACKGROUND_COLOR(Element)
Returns the color code of the specified camera element. If it is a bitmapped background, returns unpredictable results.

-------------------------------------------------------------------------------
BETWEEN(Value,Min,Max)
Returns -1 if the Value is between Min and Max, zero otherwise.

-------------------------------------------------------------------------------
BOTTOM(Element)
Returns the lowest point (relative Y coordinate) of the specified element.

;keeping a rolling element sticking to the ground
temp1=ground_level(element)
temp2=bottom(element)
position_y_set(element,temp1-temp2)

-------------------------------------------------------------------------------
CAMERA_FOV(Element)
Returns the field of view parameter of the specified camera element.

-------------------------------------------------------------------------------
CHILD_POS(ChildElement,ParentElement,XOffset,YOffset,ZOffset)
Makes the ChildElement location be relative to the ParentElement location. Specified offsets are X,Y,Z location offsets of the child element from the parent center.

;Making the steering wheels elements
;be attached to the car body
child_pos(leftwheel,element,-1.5mt,-0.4mt,1.8mt)
child_pos(rightwheel,element,1.5mt,-0.4mt,1.8mt)
child_rot(leftwheel,element,0,steerangle,0)
child_rot(rightwheel,element,0,steerangle,0)

NOTE: the ChildElement should always be placed below the ParentElement, in the List Editor. This ensures an exact ChildElement position computation, as it is calculated when the Element2 position is already updated.

NOTE: child elements position cannot be edited in the Virtual Editor. To move child elements you have to move their parent.

-------------------------------------------------------------------------------
CHILD_ROT(ChildElement,ParentElement,LocalRx,LocalRy,LocalRz)
Makes ChildElement rotation be relative to ParentElement rotation. This lets you rotate locally child elements, as they are attached to the parent. Specified angles are in degrees (dg) and relative to x,y,z local axes.
NOTICE: the ChildElement should always be placed below the ParentElement, in the List Editor. This ensures an exact ChildElement rotation computation, as it is calculated when the Element2 rotation is already updated.

NOTE: child elements local rotation cannot be edited in the Virtual Editor. Absolute rotation can be edited by editing the parent element. 

-------------------------------------------------------------------------------
COLLISION(Element,BitMask)
Returns the collision status for specified element, that is the Element ID of the element colliding with it. The BitMask can be used to test only specified bits for the incoming Element ID, to check up to 32 simultaneous colliding elements. Usually BitMask is set to -1 (all IDs).

-------------------------------------------------------------------------------
COLLISION_COLOR(Color)
Returns -1 if a collision marked with the specified color code in the Collision Map happened.

-------------------------------------------------------------------------------
COLLISION_LIST(StartElement,Repetitions,Step,BitMask)
Returns the collision status for a list of elements. The check gives zero only if it is zero for ALL the range elements, otherwise it is the result of all collision status (logical AND). The list is like: StartElement, StartElement+Step*1, StartElement+Step*2, StartElement+Step*3, ..., StartElement+Step*Repetitions.

;Checking if one or more rockets elements
;in the list (List Editor) hit an element
;with Element ID = 1
if collision_list(FirstRocket,NumberOfRockets,1,1)>0
  ;yes
else
  ;no
endif

-------------------------------------------------------------------------------
COLLISION_OFF(Element)
Disables collision checking for the specified element. The element is still visible and working.

-------------------------------------------------------------------------------
COLLISION_ON(Element)
Re-enable collision checking for the specified element (see COLLISION_OFF instruction).

-------------------------------------------------------------------------------
COS_512(Degrees)
Returns the specified degrees cosine (result*512). The 3D Rad engine works with integer values only, so the returned value is multiplied by 512 to reduce precision loss.

-------------------------------------------------------------------------------
CREDITS(Element)
Returns the specified element credits value.

-------------------------------------------------------------------------------
CREDITS_ADD(Element,Value)
Adds the value to the specified element credits.

-------------------------------------------------------------------------------
CREDITS_SET(Element,Value)
Sets the specified element credits value.

-------------------------------------------------------------------------------
DIMENSION_ABS(Element,Code)
Returns the specified element dimensions (meters). Code selects the center-relative dimension to return (1=x+,2=y+,3=z+,4=x-,5=y-,6=z-).

;performing a jumping element action (spacebar)
;temp1 contains the right element-on-ground Y position
temp1=dimension_abs(element,5)
if position_y(element)<=temp1
  ;element ON ground
  position_y_set(element,temp1)
  if keyboard(57)=-1
    ;spacebar pressed
    velocity_y_set(element,10ms)
  endif
else
  ;element OVER ground
  gravity(element,0,-1ms,0)
endif

-------------------------------------------------------------------------------
DISTANCE(Element1,Element2)
Returns Element1-Element2 relative distance

-------------------------------------------------------------------------------
DIRECTION_XZ(Element,Target)
Returns the Target direction (Y axis angle), as seen from the Element position.

-------------------------------------------------------------------------------
ELEMENT_ID(Element)
Returns the specified element identifier value.

-------------------------------------------------------------------------------
ELEMENT_ID_SET(Element,ID)
Sets the specified element identifier value.

-------------------------------------------------------------------------------
ELEMENT_INDEX(Element,Position)
Returns the index of the element at the specified position after the Element. For instance, if Position is 3, this function gives the index of the element at Element+3 position on the element list (in the List Editor). This is the same as ELEMENT#3 special variable, but using the ELEMENT_INDEX function instead, you can write configurable grouped elements brains. 

-------------------------------------------------------------------------------
EVERY_TICS(Step,MaxTics)
Returns -1 if the realtime-engine clock value is multiple of Step. The realtime-engine clock tics 30 times per second. Step must be 1,2,4,8,16,...

If the current clock tic is greather than MaxTics, the function gives always 0.

;Executing a brain section only once
;at the beginning of the element's life
if every_tics(1,1)=-1
  ;this section is executed once
endif

;Executing a brain section about one
;time per second, forever
if every_tics(32,-1)=-1
  ;this section is executed about once per second
endif

-------------------------------------------------------------------------------
EXECUTE(Element)
Executes the  brain of the specified element. This instruction can be used to run the brain of disabled elements too. 

-------------------------------------------------------------------------------
EXIT(Code)
Breaks the project execution, exiting with the specified code (value). If in self-executable mode, the exit code is the number of the next level to load and run.

If Code is -2 the game exits to the ending screen and waits for a key press before terminating.

If Code is -3 the game exits directly back to Windows.

If Code is -4 the game exits to the options menu.  

-------------------------------------------------------------------------------
FACTOR_512(Value,Factor)
Returns result of the following expression: (Value*Factor)/512

-------------------------------------------------------------------------------
FRAME_REFRESH(Element)
Forces the engine to redraw the specified frame type element.

WARNING, this instruction requires a lot of computation, and if a brain executes it 30 time per second the entire game is dramatically slowed down. So, this function must be used in rarely executed brain sections only. For instance, it can be used in a brain section that replaces (disable) the current frame with another one (enabling and refreshing it), as soon as the player press a specific key.

-------------------------------------------------------------------------------
FRICTION(Element,Intensity)
Performs a velocity reduction for the specified element. Intensity is the friction intensity (0=max friction, 512=no friction).

-------------------------------------------------------------------------------
FRICTION_XR(Element,Intensity)
Performs a spin reduction for the specified element (X axis). Intensity is the friction intensity (0=max friction, 512=no friction). The FRICTION_YR and FRICTION_ZR syntax is allowed too.

;simulating the upset vehicles swinging
attract_xr(element,180dg,5rm)
attract_zr(element,0dg,5rm)
friction_xr(element,480)
friction_zr(element,480)

-------------------------------------------------------------------------------
FRICTION_XZ(Element,Intensity)
Performs a velocity reduction for specified element (does not affect vertical velocity). Intensity is the friction intensity (0=max friction, 512=no friction).

-------------------------------------------------------------------------------
FRICTION_Y(Element,Intensity)
Performs a vertical velocity reduction for the specified element. Intensity is the friction intensity (0=max friction, 512=no friction).

-------------------------------------------------------------------------------
FOLLOW(Element1,Element2,YOffset,ZOffset,Hardness)
Makes Element1 following Element2. Following element tend to reach a point specified by YOffset,ZOffset (x offset always zero) from the center of the followed element. The last parameter is the 'hardness' of the chase action (0=very smooth, 512=very hard).

-------------------------------------------------------------------------------
GLOBAL(Index)
Returns the value of the specified global variable. Global variables let you share values among brains. You can access up to 2048 global variables specifying the respective index (0-2047). Usually the 2047 variable contains the current game score and the 2046 the current player life amount.

NOTE: in self-executable projects global variables are saved, even if the system is shut down. This lets you use global variables to store high-scores and other non-volatile data.

-------------------------------------------------------------------------------
GLOBAL_ADD(Index,Value)
Adds the Value to the specified global variable. Global variables let you share values among brains.

-------------------------------------------------------------------------------
GLOBAL_SET(Index,Value)
Sets the value for the specified global variable. Global variables let you share values among brains.

-------------------------------------------------------------------------------
GRAVITY(Element,VectorX,VectorY,VectorZ)
Performs a gravity effect for the specified element. Vector parameters specify the gravity intensity and direction.

;simulates vertical gravity effect
GRAVITY(element,0,-0.9ms,0)

-------------------------------------------------------------------------------
GROUND_COLOR(Element)
Returns color of the ground polygon at the specified element location (X,Z coordinates). If the polygon is not filled mode, the function gives the texture code (each texture has its unique code). 

-------------------------------------------------------------------------------
GROUND_COLOR_REBOUND(Element,Radius)
Keep an element inside an uniformly colored (or textured) area of the ground (that is, made of adjoining polygons). Also, it returns -1 if the element hit the area limits. The Radius parameter specifies the actual element size. That is, if the element's center distance from the limit of the area is less than Radius (in meters) the element rebounds.
 
-------------------------------------------------------------------------------
GROUND_LEVEL(Element)
Returns the ground level at the specified element location (X,Z coordinates).

-------------------------------------------------------------------------------
GROUND_SLOPE(Element)
Returns the ground slope factor at the specified element location (X,Z coordinates). If the factor is zero the ground is horizontal.

-------------------------------------------------------------------------------
HEARER(Element)
Sets the specified element as listening object. That is, the sound engine will use the hearer position as reference point to compute the "the-nearer-an-element-the-higher-its-sound" effect.

-------------------------------------------------------------------------------
HIDE(Element)
Hides the specified element. Hide elements are invisible, but their brain does still work, and collision are still performed.

-------------------------------------------------------------------------------
INSIDE_AREA_XZ(Element,MinX,MaxX,MinZ,MaxZ)
Returns -1 if the specified element is inside the MinX,MaxX,MinZ,MaxZ area, zero otherwise.

-------------------------------------------------------------------------------
INTERPOLATE(Value,R1,R2,R3,R4)
Returns result of the following expression: R3+(Value*(R4-R3))/(R2-R1)

-------------------------------------------------------------------------------
JOIN(Parent,Child)
Joins the specified elements. Makes the Child element position and rotation be the same as the Parent's. Child element position, rotation, velocity and spin settings are ignored. 

NOTE: the Child element should always be placed below the Parent one, in the List Editor. This ensures the Child position being exactly the same as the Parent position, because settings are gotten from the already updated Parent.

-------------------------------------------------------------------------------
JOIN_POS(Parent,Child)
Joins the specified elements (position only). It is the same as the JOIN instruction (see above), but does not affects the child element rotation/spin parameters. Useful to assemble pivot-joined elements (parts) to a single 3d object.

-------------------------------------------------------------------------------
JOY_B(BitMask)
Returns the joystick/joysticks buttons status. Button 1 pressed = 16. Button 2 pressed = 32. Button 3 pressed = 64. Button 4 pressed = 128. The BitMask can be used to test only specified buttons (bits), no matter the other buttons status. For instance, 'If joy_b(16)>0' executes the if...endif brain section if the button 1 is pressed.

-------------------------------------------------------------------------------
JOY1_X(Value1,Value2)
Returns a value between Value1 and Value2, according to the joystick horizontal position. If Value1>Value2 the joystick behavior is reversed.

-------------------------------------------------------------------------------
JOY1_Y(Value1,Value2)
Returns a value between Value1 and Value2, according to the joystick vertical position. If Value1>Value2 the joystick behavior is reversed.

-------------------------------------------------------------------------------
KEYBOARD(Scancode)
Returns -1 if the specified key is pressed (0=not pressed). Scancode is the desired key code. To know the scancode for any key, use the 'Scancode Find' function in the Options/Configuration menu.

-------------------------------------------------------------------------------
LIMIT(Value,Min,Max)
Returns Value if it is between Min and Max, returns Max if it is bigger than Max and returns Min if it is smaller than Min.

-------------------------------------------------------------------------------
MOUSE_CLICK()
Returns a value bigger than zero if a mouse button is pressed (1=left button, 2=right button, 3=both buttons). Note that this function does not require the mouse enabled to work.

-------------------------------------------------------------------------------
MOUSE_OFF()
Disables the mouse.

-------------------------------------------------------------------------------
MOUSE_ON()
Enables the mouse. Warning, when the mouse is enabled, the 3d engine may be slowed down on some systems. So, remember to disable it when possible (see MOUSE_OFF).

-------------------------------------------------------------------------------
MOUSE_X()
Returns the current mouse position (pixel row). Leftmost screen row is zero and the rightmost screen row is 639. The MOUSE_Y() syntax is allowed too (pixel line, uppermost=0 lowermost=479). Note that this functions wont work if the mouse is disabled (see MOUSE_ON/OFF)

;using a sprite-type element as mouse pointer
position_x_set(element,mouse_x())
position_y_set(element,mouse_y())

-------------------------------------------------------------------------------
NEAREST_ELEMENT(Element,BitMask)
Considering the specified element as reference point, and the bitmask matching elements only, returns the nearest element. The bitmask matching selection is performed by an AND operation between the bitmask and all the element's Element IDs. If the result is zero, the respective element is ignored.

;knowing the monster nearest the current element
;(supposing all the monsters Element ID is 4)
monster=nearest_element(element,4) 

;knowing the monster nearest the current element
;(supposing some monsters Element ID is 4, some 16)
monster=nearest_element(element,20) ;bitmask=4+16 

-------------------------------------------------------------------------------
OFF(Element)
Disable specified element. Disabled elements are completely ignored by the 3d engine

-------------------------------------------------------------------------------
ON(Element)
Enables the specified element. The element starts living from its initial location, as defined in the Virtual Editor or in the Numeric Editor, or it restarts from where it was turned off (see OFF instruction).

-------------------------------------------------------------------------------
ON_LIST(StartElement,Repetitions,Step)
Enables the first disabled element found in the specified list. Returns the enabled element or 0 if all elements was already enabled. The element list is like: StartElement, StartElement+Step*1, StartElement+Step*2, StartElement+Step*3, ..., StartElement+Step*Repetitions.

-------------------------------------------------------------------------------
ORIENT_STRAIGHT(Element,Xoff,Yoff)
Makes the specified element be oriented according to its movement direction, setting its X and Y rotation properly. Xoff and Yoff are X/Y rotation offset from the straight rotation (in degrees).

-------------------------------------------------------------------------------
OVER_GROUND(Element,YOffset)
Makes the specified element be at the current ground level (+/- YOffset, in meters). This instruction forces to zero the element Y velocity too.

-------------------------------------------------------------------------------
OVER_GROUND_G(Element,YOffset,Thrust)
Makes the specified element be at the current ground level (+/- YOffset, in meters), and simulates a gravity effect thrusting the element to the ground slope direction. Also, this instruction makes the element Y velocity be zero too.

-------------------------------------------------------------------------------
OVER_GROUND_SLOPE(Element,YOffset,Thrust)
Makes the specified element be at the current ground level (+/- YOffset, in meters), and having the same slope of the ground. Also, this instruction makes Y velocity and X/Z axis spin be zero too.

-------------------------------------------------------------------------------
PLAY_SOUND(Element)
Start playing the Element's sound. Usually used for non-looping sounds. 

-------------------------------------------------------------------------------
POCKET(Element,Pocket)
Returns the value (0-255) in the specified pocket (0-11) for the specified element. All 3D Rad elements have 12 pockets that can be used to pass messages one another.

-------------------------------------------------------------------------------
POCKET_ADD(Element,Pocket,Value)
Adds the specified value (0-255) to the current value in the specified pocket (0-11) for the specified element. All 3D Rad elements have 12 pockets that can be used to pass messages one another.

-------------------------------------------------------------------------------
POCKET_SET(Element,Pocket,Value)
Sets the specified value (0-255) in the specified pocket (0-11) for the specified element. All 3D Rad elements have 12 pockets that can be used to pass messages one another.

-------------------------------------------------------------------------------
POSITION_COPY(SourceElement,DestinationElement)
Places the destination element at the same coordinates of the source element.

-------------------------------------------------------------------------------
POSITION_X(Element)
Returns the current specified element X position. The POSITION_Y and POSITION_Z syntax is allowed too.

-------------------------------------------------------------------------------
POSITION_X_ADD(Element,Value)
Adds to the specified element Y position the specified value (degrees). The POSITION_Y_ADD and POSITION_Z_ADD syntax is allowed too.

-------------------------------------------------------------------------------
POSITION_X_SET(Element,Value)
Sets the specified element X position. Value should be in meters (mt). The POSITION_Y_SET and POSITION_Z_SET syntax is allowed too.

-------------------------------------------------------------------------------
RADIUS(Element)
Returns the specified element collision radius (radius parameter in the Numeric Editor, or automatically set if set to 0 by the user).

-------------------------------------------------------------------------------
RANDOM(MinValue,MaxValue)
Returns an integer random number between MinValue and MaxValue.

-------------------------------------------------------------------------------
RANDOM_ELEMENT(Element)
Considering the bitmask matching elements only, returns a random element. The bitmask matching selection is performed by an AND operation between the bitmask and all the element's Element IDs. If the result is zero, the respective element is ignored.

;choosing a random target
;(supposing all the target Element ID is 4)
target=random_element(4) 

;choosing a random target
;(supposing some targets Element ID is 4, some 16)
target=random_element(20) ;bitmask=4+16 

-------------------------------------------------------------------------------
RANDOM_POSITION_XZ(Element,MinX,MaxX,MinZ,MaxZ)
Places the specified element at a random location (X,Z plane), inside the MinX,MaxX,MinZ,MaxZ area. The instruction does not change the element Y position. Values are in meters.

-------------------------------------------------------------------------------
REBOUND_X(Element)
Performs a X direction rebound effect for the specified element (x velocity inversion).

-------------------------------------------------------------------------------
REBOUND_Y(Element)
Performs a vertical rebound effect for the specified element (y velocity inversion).

-------------------------------------------------------------------------------
REBOUND_Z(Element)
Performs a Z direction rebound effect for the specified element (z velocity inversion).

-------------------------------------------------------------------------------
ROTATION_COPY(SourceElement,DestinationElement,OffsetX,OffsetY,OffsetZ)
Rotates the destination element at the same angles of the source element. Offsets are in degrees.

-------------------------------------------------------------------------------
ROTATION_X(Element)
Returns the current specified element X rotation (between 0dg and 359dg). ROTATION_Y and ROTATION_Z syntax is allowed too.

;checking if the element X rotation is
;between -10dg and +10dg ()
temp1=rotation_x(element)
if temp1=>350dg or temp1<=10dg
  ;yes
else
  ;no
endif

-------------------------------------------------------------------------------
ROTATION_X_ADD(Element,Value)
Adds to the specified element X rotation the specified rotation value (degrees). The ROTATION_Y_ADD and ROTATION_Z_ADD syntax is allowed too.

-------------------------------------------------------------------------------
ROTATION_X_SET(Element,Value)
Sets the specified element X rotation. Value should be in degrees. The ROTATION_Y_SET and ROTATION_Z_SET syntax is allowed too.

-------------------------------------------------------------------------------
SHOW(Element)
Switches to visible the specified hide element (see HIDE instruction).

-------------------------------------------------------------------------------
SIGNAL(Element,Signal)
Returns a value bigger than zero if the specified signal (1, 2, 4, 8, ...) is switched on. All 3D Rad elements have 32 signal switches that can be used to send signals to other elements. The signal parameter  can be a sum of two or more signals (e.g. 1+4+8=13).

-------------------------------------------------------------------------------
SIGNAL_RESET(Element,Signal)
Switches off the specified signal (1, 2, 4, 8, ...). All 3D Rad elements have 32 signal switches that can be used to send signals to other elements. The signal parameter  can be a sum of two or more signals (e.g. 1+4+8=13).

-------------------------------------------------------------------------------
SIGNAL_SET(Element,Signal)
Switches on the specified signal (1, 2, 4, 8, ...). All 3D Rad elements have 32 signal switches that can be used to send signals to other elements. The signal parameter  can be a sum of two or more signals (e.g. 1+4+8=13).

-------------------------------------------------------------------------------
SOUND_MODE_SET(Element,Mode)
Sets the element's sound playing mode (0=loop, 1=single).

-------------------------------------------------------------------------------
SOUND_RATE_SET(Element,Rate)
Sets the sample rate alteration for the specified element sound. If rate is 4096, the original .wav file frequency is not altered.

-------------------------------------------------------------------------------
SOUND_STATUS(Element)
Returns the element's sound current status (-1=playing, 0=mute)
 
-------------------------------------------------------------------------------
SPRITE_DIM_X(element)
Returns the specified sprite-type element width (in pixels). The SPRITE_DIM_Y syntax, giving the sprite height, is allowed too.
NOTE: the returned sprite size is the size of the original .pcx image used as aspect component.

-------------------------------------------------------------------------------
SIGHT(Element1,Element2,Value1,Value2)
Returns 1 if Element1 is oriented toward Element2 (otherwise -1). The check will not be done if elements distance is bigger than Value1 meters. Value2 is the tolerance for the check. Big tolerance means a positive check easier (default is 128)

-------------------------------------------------------------------------------
SIN_512(Degrees)
Returns the specified degrees sinus (result*512). The 3D Rad engine works with integer values only, so the returned value is multiplied by 512 to reduce precision loss.

-------------------------------------------------------------------------------
SPEED(Element)
Returns current velocity for specified element (meters per second).

-------------------------------------------------------------------------------
SPEED_XZ(Element)
Returns current horizontal velocity for specified element, in meters per second. Vertical velocity (Y) is ignored. 

-------------------------------------------------------------------------------
SPEED_SET(Element,Velocity)
Sets the specified element velocity, according to the element orientation. Velocity is in meters per second (ms).

-------------------------------------------------------------------------------
SPEED_XZ_SET(Element,Velocity)
Sets the specified element velocity, according to the element orientation (Y rotation only). The Y velocity component is ignored. Velocity is in meters per second (ms).

-------------------------------------------------------------------------------
SPIN_UPDATE(Element)
Updates rotation for specified element, according to x,y,z spin parameters. This instruction must be present in any brain performing spin based actions (angular attracting, angular slowing, etc.) or hosted by elements with spin properties bigger than zero (Numeric Editor panel).

This instruction just add the spin parameters value to the respective rotation value, every time it is executed.

NOTE: knowing when this instruction can be omitted is not always easy, so, if you are not sure, just place it at the start of all your own brain scripts.

-------------------------------------------------------------------------------
SPIN_X(Element)
Returns the specified element X spin. The SPIN_Y and SPIN_Z syntax is allowed too.

-------------------------------------------------------------------------------
SPIN_X_ADD(Element,Value)
Add Value to the specified element X spin. The SPIN_Y_ADD and SPIN_Z_ADD syntax is allowed too.

-------------------------------------------------------------------------------
SPIN_X_SET(Element,Value)
Sets the specified element X spin. Value should be in rounds per minute. The SPIN_Y_SET and SPIN_Z_SET syntax is allowed too.

-------------------------------------------------------------------------------
SQRT_512(Value)
Returns the specified value square root (result*512). The 3D Rad engine works with integer values only, so the returned value is multiplied by 512 to reduce precision loss.

-------------------------------------------------------------------------------
STATUS(Element)
Returns 1 if specified element is enabled (0 otherwise)

-------------------------------------------------------------------------------
STEER(Element,Angle,Friction)
Performs a steer effect for the specified element and returns the element velocity (local Z axis). Angle is the angle of the steer (maxLeft=-90dg, maxRight=90dg). Friction is the wheels friction over the ground (max=0, min=512).

;performing a vehicle behavior and
;animating it according to its speed
temp1=steer(element,steerangle,holding)
temp1=temp1/350
animate(element,1,9,temp1)

-------------------------------------------------------------------------------
STEER_ANGLE_TO(Element,Target,Step)
Returns the angle you should add to the steer angle of a vehicle-like element, to make it steer to the Target element. Step is the max angle (degrees) the instruction can give (little steps mean slow steering correction).

;performing an intelligent, target
;following, vehicle behavior
thrust(element,5000)
temp1=steer_angle_to(element,target,5dg)
temp2=temp2+temp1
if temp2<-30dg
  temp2=-30dg
endif
if temp2>30dg
  temp2=30dg
endif
steer(element,temp2,480)

-------------------------------------------------------------------------------
STOP_SOUND(Element)
Mutes the specified element's sound. 

-------------------------------------------------------------------------------
TAN_512(Degrees)
Returns the specified degrees tangent (result*512). The 3D Rad engine works with integer values only, so the returned value is multiplied by 512 to reduce precision loss.

-------------------------------------------------------------------------------
THRUST(Element,Value)
Performs an acceleration for the specified element. Value is the thrust intensity. The direction for the thrust is the same of the element orientation. Negative values are permitted.

-------------------------------------------------------------------------------
THRUST_XZ(Element,Value)
Performs an acceleration for the specified element. Value is the thrust intensity. The direction for the thrust is the same of the element orientation (Y rotation only). Negative values are permitted.

-------------------------------------------------------------------------------
TIMER(Element)
Returns the timer status (seconds/30) for the specified element. The timer starts with the element's life.

-------------------------------------------------------------------------------
TIMER_SET(Element,Value)
Sets the timer for the specified element. Value is in seconds/30

-------------------------------------------------------------------------------
TRACK(Element1,Element2)
Orients Element1 toward Element2.

-------------------------------------------------------------------------------
TRACK_PLAY(Element,TrackElement)
Forces the specified Element to follow the recorded 3d course stored in the specified track-type element. When the course tracking finish, this function is ignored.

-------------------------------------------------------------------------------
TRACK_PLAY_LOOP(Element,TrackElement)
Forces the specified Element to follow the recorded 3d course stored in the specified track-type element. The course tracking starts again from the beginning, when finished.

-------------------------------------------------------------------------------
TRACK_RECORD(Element)
Records the specified element 3d course. Recorded course can be saved as a track-type element using the 'Save Recorded Track As' option (Options/Configuration menu). Note that this function wont work in compiled brains.

-------------------------------------------------------------------------------
TRACK_PLAY_RESET(Element,TrackElement)
Forces the specified Element to re-start following (reading) the recorded track from the beginning. Note that this function does not place the element to its original starting position.

-------------------------------------------------------------------------------
TRACK_YR(Element1,Element2)
Orients Element1 toward Element2 (Y rotation only).

-------------------------------------------------------------------------------
VELOCITY_UPDATE(Element)
Updates the position for the specified element, according to x,y,z velocity parameters. This instruction must be present in any brain performing velocity based actions (attracting, accelerating, slowing, etc.) or hosted by element with velocity properties bigger than zero (Numeric Editor panel).

This instruction just add the velocity parameters value to the respective positions value, every time it is executed.

NOTE: knowing when this instruction can be omitted is not always easy, so, if you are not sure, just place it at the start of all your own brain scripts.

-------------------------------------------------------------------------------
VELOCITY_X(Element)
Returns the current specified element X velocity. The VELOCITY_Y and VELOCITY_Z syntax is allowed too.

-------------------------------------------------------------------------------
VELOCITY_X_ADD(Element,Value)
Adds Value to the specified element X velocity. The VELOCITY_Y_ADD and VELOCITY_Z_ADD syntax is allowed too.

-------------------------------------------------------------------------------
VELOCITY_X_SET(Element,Value)
Sets the specified element X velocity. Value should be in meters per second. The VELOCITY_Y_SET and VELOCITY_Z_SET syntax is allowed too.

-------------------------------------------------------------------------------
WRAP(Value,Min,Max)
Returns Value if it is between Min and Max, otherwise wraps it around until it is between Min and Max (e.g. wrap(13,0,10) gives 2).


