Sauerworld Forum

Sauerbraten Talk => Ideas for Sauerbraten => Topic started by: Salatiel on January 04, 2018, 02:51:44 PM

Title: selectface command
Post by: Salatiel on January 04, 2018, 02:51:44 PM
I really miss a command that selects the faces of a previously selected cube
/selectface N (N is the face number)

 Why would it be useful?
 -You could bind a key to select a back face of a cube, without having to move there to select
- It would be possible to create loop of cubes in different positions instantly using something like:
draw = [
    sleep 10 [selectface 1 ; loop i 6 [universaldelta -1]]
    sleep 20 [selectface 2 ; loop i 6 [universaldelta -1]]
]

^ Then imagining that 1 is the front face of the cube, and 2 the left side, this would result in a curve with 10 cubes...  :o

(https://imgur.com/N5KyG6t.png)

Maybe if it could depend on the position of the player's camera would be better

Here is a gif, colors are just to exemplify:
(https://imgur.com/8jP3EBw.gif)

(if this command already exists, ignore this suggestion and please tell me what it is  :P)

-Update-
Check out this function and a few other new commands to move the selection:
http://sauerworld.org/forum/index.php?topic=574.0
Title: Re: selectface command
Post by: Salatiel on November 07, 2018, 03:58:24 PM
After a while trying to do this on my own, I came up with a reasonable result:

Code: [Select]
void pushface(int *dir, int *pface)
{
    if(noedit(moving!=0)) return;
    int s = *dir;
    sel.o[*pface] += s*sel.grid;
}
COMMAND(pushface, "ii");

Is a variation/modification of the Pushsel command, and should be added in src/engine/octaedit.cpp
This does not select the face, but moves the selection to the chosen direction.

arg1: -1 || 1 (add or subtract arg2)
arg2: 0 = X || 1 = Y || 2 = Z