Since the current Sauerbraten version does not have commands to select a specific face or an edge of a cube, this script uses some workarounds to achieve a similar result using the existing commands, not requiring a modified client (thus being slower than it would be if implemented natively).
Just download and place the cubedeformer.cfg
file in the Sauerbraten root folder and run /exec cubedeformer.cfg
ingame, the cubedeformer_examples.cfg
file is optional.
gotoface
f
[c]
s
Teleports to facef
(0..3) and executes[c]
.s
is an optional delay that gives time for the gotoface to finish before running another gotoface (otherwise some sync problems may occur), default: 500ms when there is an nested gotoface or 1ms when there is none.
gotoedge
e
[c]
b
Teleports to the edgee
(0..3) of the face being looked at and executes[c]
.b
(0/1) is optional and determines whether the gridpower should be changed to an equivalent of the selected edge.
-
moveseldo
x
y
z
c
Addsx
,y
andz
to the position of the current selection, executing[c]
every move. -
getlookatface
Returns the face the camera is looking at relative to the world (not the selected face).
The commands below are already available in the Sauerbraten 2020 edition natively.
-
editface
d
t
t
determines whether the face (0), selection (1) or edge (2) of a cube will be pushed tod
. -
flip
Inverts selected geometry. -
movesel
a
d
d
determines whether the selection will be moved to x (0), y (1) or z (2)a
times. -
rotate
d
Rotates once left (-1) or right (1) relative to the selected face. -
setselpos
x
y
z
Sets the position of the current selection tox
y
andz
or creates a new one.
There are two limitations you should be aware of:
-
In order for the native
editface
command to work properly (you will use it to push an edge or a face), the camera needs to be slightly aligned to the horizon (the camera's pitch and yaw), you don't have to worry about the camera's yaw (horizontal) value,gotoface
will fix it automatically, however the only way to correct the pitch automatically is to respawn the player. You can use thegotoface_fixpitch
f
[c]
shortcut or simply move the camera closer to the horizon manually. -
For the same reason mentioned above, you cannot access the top or bottom face of the selection (+Z and -Z) directly with
gotoface
, to make changes to them you will have to rotate the geometry. Example of how to apply colors to the top and bottom face of a geometry:
gotoface 2 [ // go to a side face (2, -Y).
rotate 1 // rotates the cube so that the top face becomes a side face (0, +X).
gotoface 0 [ // go to the "top" face which is now temporarily on the side.
allfaces 0 // makes sure that only the selected face has its color changed.
vcolor 1 0 0 // sets the red color.
flip // flips the geometry to access the "bottom" face.
vcolor 0 0 1 // sets the blue color.
gotoface 2 [ // go back to the side face (2, -Y).
rotate 1 // returns the bottom and top faces to their initial rotation.
]
]
]
Regarding other limitations or problems you may run into, usually a half-second sleep
fixes them :P
Although handy, the commands below might not be a good idea if you want to have absolute control over gotoface
and gotoedge
.
-
gotoface_fixpitch
f
[c]
Respawns the player to fix the camera orientation and callsgotoface
withf
and[c]
as its parameters. -
pushedge
e
d
[c]
Usesgotoedge
andeditface
to go to an edge and push itd
times,[c]
is executed at the end. -
editfaceedge
f
e
d
[c]
Usesgotoface
(f
),pushedge
(e
) andeditface
(d
), with the difference that it handles +Z (4) and -Z (5) faces automatically (rotating them back and forth).
Keep in mind that you want to avoid anything involving gotoface
and gotoedge
as much as possible, most of the time you only need to change faces twice and edge only once, everything else can be handled with flip
and rotate
.
See more examples in the cubedeformer_examples.cfg
file.
Moved to a repository https://github.com/CubeScript/Sauer-Cube-Deformer