Thread overview
September 24
So I'm making some sort of library(it's not online yet).
In that Library there is a class called dextend.gameengine.shape. 
 In this class, I've made part of an update function(that the user of the library calls to update the status of the flag). Now, this update function has to check a lot of things(flags, certain variables, checks that are in these checks,etc.)  Here is the function so far(It probably has errors and bugs but I'll fix those when I actually finish the function):

void Update(shape* check_if_hit = null)
{
if(flags & Flags.Gravity)
{
if(check_if_hit is null)
    throw new Exception("If Flags.Gravity is true, then check_if_hit must point to a shape.");
if(this.move_speed) {
double[3] sorted_point = sortLowtoHigh!double([next_move.x,next_move.y,next_move.z]);
for(int i = 0;i < this.points.length;i++) {
    if(sorted_point[2] == this.next_move.x)
    {
        this.points[i].x += this.move_speed;
        this.next_move.x -= this.move_speed;
        this.points[i].y += this.move_speed(this.next_move.y / this.next_move.x);
        this.next_move.y -= this.move_speed(this.next_move.y / this.next_move.x);
        this.points[i].z += this.move_speed(this.next_move.z / this.next_move.x);
        this.next_move.z -= this.move_speed(this.next_move.z / this.next_move.x);
    }
    else if(sorted_point[2] == this.next_move.y)
    {
        this.points[i].x += this.move_speed(this.next_move.x / this.next_move.y);
        this.next_move.x -= this.move_speed(this.next_move.x / this.next_move.y);
        this.points[i].y += this.move_speed;
        this.next_move.y -= this.move_speed;
        this.points[i].z += this.move_speed(this.next_move.z / this.next_move.y);
        this.next_move.z -= this.move_speed(this.next_move.z / this.next_move.y);
    }
    else if(sorted_point[2] == this.next_move.z)
    {
        this.points[i].x += this.move_speed(this.next_move.x / this.next_move.z);
        this.next_move.x -= this.move_speed(this.next_move.x / this.next_move.z);
        this.points[i].y += this.move_speed(this.next_move.y / this.next_move.z);
        this.next_move.y -= this.move_speed(this.next_move.y / this.next_move.z);
        this.points[i].z += this.move_speed;
        this.next_move.z -= this.move_speed;
    }
}
if(this.next_move.x <= 0 || this.next_move.y <= 0 || this.next_move.z <= 0) {
    for(int i = 0;i < this.points.length;i++)
    {
        this.points[i].x += this.next_move.x;
        this.points[i].y += this.next_move.y;
        this.points[i].z += this.next_move.z;
    }
this.move_speed = 0;
}
}
}
}

There. Does that look confusing or what?
September 24
On 9/24/20 12:15 PM, Ruby The Roobster wrote:
> So I'm making some sort of library(it's not online yet).
[...]
> There. Does that look confusing or what?

Just a friendly reminder that we have a "Learn" newsgroup[1] as well. I think some of your posts including this one would be more suitable there because many of us on that newsgroup are eagerly looking forward to posts like these. :)

Ali

[1] The forum interface: https://forum.dlang.org/group/learn
September 24
On Thursday, 24 September 2020 at 19:15:00 UTC, Ruby The Roobster wrote:
> So I'm making some sort of library(it's not online yet).
> In that Library there is a class called dextend.gameengine.shape.
>  In this class, I've made part of an update function(that the user of the library calls to update the status of the flag). Now, this update function has to check a lot of things(flags, certain variables, checks that are in these checks,etc.)  Here is the function so far(It probably has errors and bugs but I'll fix those when I actually finish the function):
>
...
>
> There. Does that look confusing or what?

There are parts of that I don't understand at all, like the
sorted_point logic, and this.next_move, so that limits what I
can suggest.

But you might prefer writing this with an eye on

https://dlang.org/spec/arrays.html#array-operations
https://dlang.org/phobos/std_exception.html#enforce

ex:

struct Mobile {
    int[3] pos, delta;

    void step() {
        import std.exception : enforce;

        pos[] += delta[];
        enforce(pos[] < [666, 666, 666], "example position violation");
    }
}

unittest {
    import std.stdio : writeln;

    auto m1 = Mobile([0, 0, 0], [5, 0, -1]);
    m1.step;
    m1.step;
    m1.step;
    writeln(m1);
}

unittest {
    import std.exception : assertThrown;

    auto m1 = Mobile([0, 0, 0], [1000, 1000, 1000]);
    m1.step.assertThrown; // position violation
}
September 24
On Thursday, 24 September 2020 at 19:54:40 UTC, mipri wrote:
> There are parts of that I don't understand at all, like the
> sorted_point logic, and this.next_move, so that limits what I
> can suggest.

To add a little context, this.next_move has to do with where the shape is moving:

struct position{
double x;
double y;
double z;
}
class shape {
//Bunch of member functions
protected:
position next_move;
}

sorted_point after the sortLowtoHigh!double() call is the member values of next_move sorted from lowest(sorted_point[0]) to highest(sorted_point[2])
September 24
On Thursday, 24 September 2020 at 19:54:40 UTC, mipri wrote:
>
> There are parts of that I don't understand at all, like the
> sorted_point logic, and this.next_move, so that limits what I
> can suggest.
>
> But you might prefer writing this with an eye on
>
> https://dlang.org/spec/arrays.html#array-operations
> https://dlang.org/phobos/std_exception.html#enforce
>
> ex:
>
> struct Mobile {
>     int[3] pos, delta;
>
>     void step() {
>         import std.exception : enforce;
>
>         pos[] += delta[];
>         enforce(pos[] < [666, 666, 666], "example position violation");
>     }
> }
>
> unittest {
>     import std.stdio : writeln;
>
>     auto m1 = Mobile([0, 0, 0], [5, 0, -1]);
>     m1.step;
>     m1.step;
>     m1.step;
>     writeln(m1);
> }
>
> unittest {
>     import std.exception : assertThrown;
>
>     auto m1 = Mobile([0, 0, 0], [1000, 1000, 1000]);
>     m1.step.assertThrown; // position violation
> }

Even if I did something similar to what you suggested, the code would still be confusing, just because of how many checks have to be done in this function. I can't really improve the way the checks look. Also, implementing that would be a huge pain because I use position(the struct) like this(not with a lot of checks but the .x = .x,.y = .y,etc. thing) in basically any function involving position of the shape.
September 24
On Thursday, 24 September 2020 at 19:54:40 UTC, mipri wrote:
>[..]

What I can do is look for all for loops using shape.points(points is an array of positions) with something like:
this.points[].member op someposition.member


September 24
On Thursday, 24 September 2020 at 20:56:46 UTC, Ruby The Roobster wrote:
> On Thursday, 24 September 2020 at 19:54:40 UTC, mipri wrote:
>>[..]
>
> What I can do is look for all for loops using shape.points(points is an array of positions) with something like:

I meant 'replace with something like', not 'with something like'