Description of the Script Editor for the program "Best Virtual Rubik's Cube."
Overview.
To run the Script Editor for Virtual Rubik's Cube, select Script from the Edit menu.
The Script Editor window contains two edit controls - multiline edit control on the top and single line edit control under it.
Scripts are written in the multiline edit control, single line edit control for error messages.
To execute the script click the «Run» button.
To open a saved script file, click «Load Script» button.
When you click the «Save» button dialog box with a proposal to save the script appeared
(If the script was not loaded from a file). If the script was loaded from a file it will be overwrite.
If you click the «Save Script as» button dialog box with a proposal to save the script appeared.
Script file for the Best Virtual Rubik's Cube has an extension CRS and the icon
.
Note, that *.CRS is ordinary text file, you can edit it with any text editor.
You can run saved scripts without having to load them into the Script Editor.
To do it, from File menu select Open - Script for Rubik's Cube.
Click «Exit» button to close the Script Editor for Virtual Rubik's Cube.
Options.
"Script for current Rubik's Cube." If this option is selected, and if the dimension of the current
Virtual Rubik's Cube coincides with the dimension specified in the script, the script will be executed
for the current Cube.
Otherwise, the program will generate a new Virtual Rubik's Cube and the script, thereby
will be start "from scratch".
"Save current Rubik's Cube." If this option is selected, then every time you
run the script, will appear a dialog box with a proposal to save the current Rubik's Cube.
"Minimize this window when run a script." The Script Editor will be minimized
when you run the script and restored after execution the script.
"Enable rotations of the Rubik's Cube." During the execution of the script, the scene with a Rubik's Cube
will rotate if this option is selected, and will remain fixed otherwise.
How to write scripts for the Best Virtual Rubik's Cube program. Full guide.
Really, writing scripts for Virtual Rubik's Cube is very simply and easy.
First of all in the Edit menu, select Options item. In the appeared
dialog box, select "Enable axes XYZ" option.
By clicking on the «OK» button close the dialog panel.
Then, run the Script Editor by selecting Script item from the Edit menu.
Copy it and, via the clipboard, paste it into the multiline edit control of
Script Editor. Execute the script by clicking the "Run" button. OK?
Let us consider the script in detail.
First of all, pay attention to the first line of the script.
At the beginning of the script always must be some number,
determining the dimension of the Virtual Rubik's Cube.
In the example above, this number is five, and as you saw,
the dimension Cube became 5x5x5.
Next, the script has a series of expressions in parentheses.
Each of them is the command that determines the rotation of the selected
layer (or layers!) Virtual Rubik's Cube about the selected axis at a given angle.
For example, "X3" in command "(X3 + 1)" means
that you want to turn the third layer about "X" axis,
and "Y5" in the command "(Y5 + 1)" means a rotation the fifth layer about the axis
"Y", etc.
Layers numbered in ascending order, starting with 1 in the positive direction of the axis.
If you have not understand in the text, then just look at the picture on the left, which
all the layers of Cube are numbered.
For example, as seen from the picture, the axis "Y" comes from the below to the upwards
and so the "Y1" is the lowest layer, and "Y5" - the very top.
Note: you can use both uppercase and lowercase letters,
and, therefore, for example, the commands (Z5 +1) and (z5 +1) are equivalent.
At the end of each command is an expression that specifies the rotation angle of the selected layers:
"+1" here means rotation by +90 degrees, and
"– 1" will turn the selected layer to -90 degrees.
Positive and negative rotations are determined as usual, accepted the agreement in mathematics:
if the axis of rotation is aimed at the observer, counter-clockwise rotations is a positive, and clock-wise rotations is a negative.
The figure below shows the rotations at +90 degrees (left), at -90 degrees (right)
and their designation in the scripts.
You can also with expressions of "+2" and "–2" set a 180 degree rotation. Of course, the
"+" and "–" in these expressions do not matter (because the rotation by 180
degrees is the same as rotation -180 degrees), but must be present - this is hard rule!
So, for example, the following two scripts ultimately produce an entirely
the same effect, although the layers in each of them rotate in opposite directions:
Other turns in the script can not be specified, so any script command must have in the end"1"or"2".
In all scripts above, each command determined the rotation of a single layer.
However, you can turn several layers,
if these layers are located directly next to each other.
Here is an example of this command: (2X3+1) Here the "X3 +1" as usually defines the rotation of the third layer about the "X" axis
to +90°, and the positive number "2" at the beginning of the command means,
that you want to rotate two layers additionally.
These two layers arranged beyond the third layer - that is, the fourth and fifth layers.
Thus, this command turns right three layers.
Command (-2X3+1)
also turn on the +90° right three layers, but since the number of
at the beginning of the command is negative, they already will be located on the other side
third layer - the first and second layers.
The picture below shows three examples of the implementation of three scripts: 5 (2 X 3 +1) (left), 5 (-2 Y 3 +1) (center) and 5 (-2 Z 4 +1) (right).
Two scripts below, the different at first glance, in fact, completely equivalent:
5
(2X2+1)
(2Y2+1)
(2X2-1)
(2Y2-1)
5
(-2X4+1)
(-2Y4+1)
(-2X4-1)
(-2Y4-1)
You can write a script, not only in the column, but in one or more lines,
use any number of spaces both outside and inside parentheses, parentheses themselves can be arbitrary:
round brackets - () or square brackets - [] or braces - {}.
Finally, you can include in the script any comments, such as your name and the date of writing,
but comment can not be in the beginning of the script, and inside the parentheses and themselves can not contain brackets.
This script will be executed without any problem, because all that is
not at the beginning of the script and is not enclosed in the parentheses the program just will skip.
Summary.
At the beginning of the script always must be some number,
determining the dimension of the Virtual Rubik's Cube.
Each expression in parentheses is the command that determines the rotation of a selected number of
layer (or layers) of a cube about a selected axis at a given angle.
Parentheses can be anything: round brackets, square brackets or braces.
Inside the parentheses is permissible to use only the following characters:
spaces;
numbers 0,1,2,3,4,5,6,7,8,9,0;
signs "+" è "–";
Letters of the alphabet "X", "x", "Y", "y", "Z", "z".
Other characters are not allowed inside the parentheses.
If a command has to turn to only one layer, then it must begin by
one of the letters - "X", "x", "Y", "y", "Z", "z", defining the axis of rotation.
After the letter is a number that specifies the number of rotated layer, herewith
layers are numbered in ascending order, starting with 1 in the positive direction of the axis.
At the end of each command is an expression that determines the angle of rotation:
"+1" specifies the turn by +90°;
"–1" specifies the turn by –90°;
"+2" and "–2" specifies the turn by 180°.
Other expressions in the end of the are not allowed.
It is possible to turn with one command of several layers, provided that
these layers are located directly next to each other.
The number that stands at the beginning of this command specifies the number of additional rotated layers.
If this number is positive, it will be rotated additional layers, located on this
side of the selected layer, which directed the axis of rotation, otherwise
will be rotated layers, located on the another side.
You can write a script in a column or in one or more lines,
use any number of spaces both outside and inside the parentheses.
Comments can not be in the beginning of the script, and inside the parentheses and can not contain parentheses themselves.
Examples of scripts for the "Best Virtual Rubik's Cube."
You can find examples of interesting scripts here.
Currently, there are scripts for a Rubik's Cube such dimension: