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).
sTeleports to face
f(0..3) and executes
sis 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.
bTeleports to the edge
e(0..3) of the face being looked at and executes
b(0/1) is optional and determines whether the gridpower should be changed to an equivalent of the selected edge.
zto the position of the current selection, executing
getlookatfaceReturns 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.
tdetermines whether the face (0), selection (1) or edge (2) of a cube will be pushed to
flipInverts selected geometry.
ddetermines whether the selection will be moved to x (0), y (1) or z (2)
dRotates once left (-1) or right (1) relative to the selected face.
zSets the position of the current selection to
zor creates a new one.
There are two limitations you should be aware of:
In order for the native
editfacecommand 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,
gotofacewill fix it automatically, however the only way to correct the pitch automatically is to respawn the player. You can use the
[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
[c]Respawns the player to fix the camera orientation and calls
[c]as its parameters.
editfaceto go to an edge and push it
[c]is executed at the end.
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
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
See more examples in the