Jump to content

AutoIt inspired Scripting language I'm making


UberFoX
 Share

Recommended Posts

This looks like the language i always wanted. Amazing job, will look at it later :)

 

I just saw your process call script nice work indeed you sure know your stuff.

Could use somebody of your skills to help build stuff/test/find bugs and generally making cool stuff lol.

Sputnik has very detailed and powerful parsing functions that go beyond anything seen in AutoIt and Regex.

(look here http://uberfox.no-ip.org/Sputnik/wiki/index.php/Core_Function_Parser_Engine (this can even be used to parse Sputnik scripts perfectly) which is useful when making custom features like you did with your own DLLCall.)

Sputnik has a lot of nice DLL calling features such as the ability for a person to define say 100,000 dll call function protos etc and dump it as a DLL so instead of having to parse all that code every time you open your script it simply boots it from the DLL you created.

The DLLCall (along with DLLOpen and DLLClose) in Sputnik is actually a wrapper for the DLLImport() function (with direct calling after creation).

Althought many functions looks similar to AutoIt in function name (like above) that is only to make it less stressful for somebody who wants to make a script with any additional features Sputnik gives without having to re-learn everything from scratch.

I like adding new functions and improving existing ones basically any function ideas you have I would be happy to add them in (if possible).

With Sputnik I place everything in core the library is actually very very small and does need some growth. AutoIt has quite an amazing library really in its size.

Converting existing functions from AutoIt to Sputnik is actually trivial as most function names remain the same (or with very minor modifications).

Take this example:

Func _StringReverse($s_String)

    Local $i_len = StringLen($s_String)
    If $i_len < 1 Then Return SetError(1, 0, "")

    Local $t_chars = DllStructCreate("char[" & $i_len + 1 & "]")
    DllStructSetData($t_chars, 1, $s_String)

    Local $a_rev = DllCall("msvcrt.dll", "ptr:cdecl", "_strrev", "struct*", $t_chars)
    If @error Or $a_rev[0] = 0 Then Return SetError(2, 0, "")

    Return DllStructGetData($t_chars, 1)
EndFunc

In Sputnik you could do

MsgBox( StringReverse("Hello World") );
Function StringReverse($s_String)
{
    my $i_len = StrLen($s_String);
    If($i_len < 1) Return null;

    my $t_chars = DllStructCreate("char myval [{++$i_len}];"); //; Do the +1 in the string actual   
    DllStructSetData($t_chars, 'myval', $s_String); 

    my $a_rev = DllCall("msvcrt.dll", "_strrev", "int", "t", "Ansi:cdecl", $t_chars); //; t = struct
    if($a_rev == @PtrZero || $a_rev == null) { unset($t_chars); return null; } //; Free object

    my $ret = DllStructGetData($t_chars, "myval");
    unset($t_chars); //; free object
    Return $ret;
}

As you can see its actually quite similar and converting a function you made from AutoIt or making new ones isn't as hard as it may seem and yet you get additional stuff like Classes and Dynamic code (This means it can unload functions/classes anything from Sputnik and reload it again from source code without having to restart your program) etc although in Sputnik its more recommended you add the DLLImports at the top of the script or in an Init function rather than recreating it for every call.. For example:

//; Import the DLL function into the Script so next time we call it its super fast
//; Avoids the need to recompile the function each time we call it
DLLImport("msvcrt.dll", "_strrev", "int", "t", "Ansi:cdecl");
Function StringReverse($s_String)
{
    my $i_len = StrLen($s_String);
    If($i_len < 1) Return null;
    my $t_chars = DllStructCreate("char myval [{++$i_len}];"); //; Do the +1 in the string actual   
    DllStructSetData($t_chars, 'myval', $s_String); 
    my $a_rev = _strrev($t_chars); //; As a benefit it takes on its name (we can alias it if we want)
    if($a_rev == @PtrZero || $a_rev == null) { unset($t_chars); return null; } //; Free object
    my $ret = DllStructGetData($t_chars, "myval");
    unset($t_chars); // free object
    Return $ret;
}
MsgBox( StringReverse("Hello World") );

This is the fastest way if you are going to be calling this function millions of times why recompile it ever time.

Edited by UberFoX
Link to comment
Share on other sites

Has anybody tested Sputty yet? Some feedback would be helpful espeically any bugs lol.

I made a lot of improvements recently and will release a new version soon (I added proper pointer (signed and unsigned) data types for $variables more practical than using int32/int64 all time and a bunch of other fixes such as not needing DLLStructGetPtr() when adding it to an argument and added many new functions including the a ton of IndexOf functions Classes use slightly less ram which is always a good thing and of course any bugs I did find along the way.....)

Edited by UberFoX
Link to comment
Share on other sites

To be honest, I'm not going install and run such a software from a person that turned up a week ago and posted it up.

I'd struggle to find a reason why someone would go to such lengths for malicious purposes, but there you have it, It's how I think.

Please do not mistake this as negativity, it is not.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

To be honest, I'm not going install and run such a software from a person that turned up a week ago and posted it up.

I'd struggle to find a reason why someone would go to such lengths for malicious purposes, but there you have it, It's how I think.

Please do not mistake this as negativity, it is not.

 

Fair enough however if you check the wiki you will see I've been adding stuff for a very long time there are detailed history of every edit I ever did... I'm not sure anybody would go to such lengths when it's 10x times easier to just to just send *Money/Resource/YouNameIt hack* for malicious purpose.

Also you could just try it in a virtual PC such as VirtualBox and see exactly what it does.

You can even use Redgate Reflector to look inside Sputnik.exe and see how it ticks and how it works and look for malicious code that way (Reflector can convert assembles almost back to source code).

Ultimately all I can do is is point to wiki and all edits and history it has and anybody who has tested Sputnik can tell you it does exactly what it claims it does.

Oh and I didn't release it earlier since I wanted to make sure it was good/stable/useable before inviting people to see.

All the best :).

Edited by UberFoX
Link to comment
Share on other sites

Some people have asked what is classes, what use are they, how do I use them? Instead of sending same e-mail I will post an explanation here.

Here is a relatively simple class that allows a person to define a new data type to and how it should operate.

This class is called Double and it creates a new data type that mimics the default *double* data type.

Obviously it lacks full features but it has enough to demonstrate its use.

Of course you could create large complex structures and even 128-bit double classes if you wanted to... But this example will stay simple.

//; Example class that acts the same as a normal Double variable
//; but it is allocated on the heap and written/read directly by
//; pointers
//; It is basic but it shows the benefit of Classes and overloading
Class Double
{
    my $Data;
    my $Disposed;
    //; Constructor is called when an instance of this class is made
    Function __Construct($val)
    {
        $Disposed = false;
        $Data = Alloc(8); //; Allocate 8 bytes (size of a double)
        SetValue($val); //; Set its value
    }
    //; Destructor is called when an instance of this class is destroted using unset()
    //; Note - ONLY Unset() will cause an object to be destroyed
    Function __Destruct($val)
    {
        if($Disposed) return; //; No need to run this function again
        $Disposed = true;
        free($Data); //; Free the memory that was allocated
    }
    //; Set the value of the double in this class
    Function SetValue($val)
    {
        PTRWrite($Data, 'd', 0, $val); //; Write a double to pointer
    }
    //; Get the value of the double in this class
    Function GetValue()
    {
        return PTRRead($Data, 'd', 0); //; Read a double from pointer
    }
    //; Overload casting to string (works on anything that requests a string of this object)
    Operator "string"
    {
        return GetValue();
    }
    //; Overload casting to double (obviously)
    //; we can continue and overload every cast possible if we wanted to
    Operator "double"
    {
        return GetValue();
    }
    //; Over the += operator
    //; we could overload every operator *= etc whatever
    Operator "+=" ($x)
    {
        If ($x ~~ Double) //; Its another class same as us
            SetValue(GetValue() + $x->GetValue()); //; Get its value and add
        else
            SetValue(GetValue() + (double)$x); //; Its any random variable just cast it as double and the value
    }
};

$a = new Double(777);
println("Value is: " . $a); //; Prints 777
$b = new Double(1221);
$a += $b;
println("Value is: " . $a); //; Prints 1998
$a += 7.4;
println("Value is: " . $a); //; 2005.40000009537
unset($a); //; Destrots the object fully and completely
println("Value is: " . $a); //; <blank nothing is printed>

If you don't see much use to that since hey it only contains one variable and its easy to pass one variable around all time right?

Well yea it is but what if you want to pass 3 around all time? $X $Y $Z easy right? You just make  callfunction( $x, $y, $z ) ? but it starts to get real sloppy when you make many of them with different names then what if you want to add two of them together? addvec($x, $y, $z, $x1, $y1, $z1) ? Looks a bit painful.

Where as with a class you can do addition as simple as $a += $b; no need for complex lengthy functions and keeping track of 3 variables all time (or more ..... try 30).

Here is a Vector3 class made in Sputnik that handles Vector3s as easy as you would expect in C++.

//; Vector3 Class ported to Sputnik by UberFoX
//; 
//; Function Key:
//; ! = Returns no return value
//; * = Returns a new Vector3
//; % = Returns a numeric value
//; " = Returns a string
//; @ = Returns an array
//; : = Returns numeric where higher than 0 is true
//; 
//; Function Argument Key:
//; * = Requires Vector3
//; % = Requires numeric value
//; 
//; Static Functions //; To be called from anywhere like: vec3::FunctionName()
//;     * CrossProduct(*, *) //; Determine the cross product of two Vectors
//;     % DotProduct(*, *) //; Determine the dot product of two Vectors
//;     % MixedProduct(*, *, *) //; Determine the mixed product of three Vectors
//;     * Normalize(*) //; Get the normalized vector of a vector
//;     % Multiply(*, *) //;  Returns the dot product: vector1.X * vector2.X + vector1.Y*vector2.Y 
//;     % Determinant(*, *) //; Returns the determinant det(vector1, vector2)
//;     * SumComponentSqrs(*) //; The sum of a Vector3's squared components
//;     * SqrComponents(*) //; A Vector3's components squared
//;     % SumComponents(*) //; The sum of a Vector3's components
//;     % Distance(*, *) //; Find the distance between two Vectors
//;     % Angle(*, *) //; Find the angle between two Vectors
//;  % AngleBetween(*, *) //; The angle in degrees between 2 vectors
//;     * Max(*, *) //; Compares the magnitude of two Vectors and returns the greater Vector3
//;     * Min(*, *) //; Compares the magnitude of two Vectors and returns the lesser Vector3
//;     ! Yaw(*, %) //; Rotates a Vector3 around the Y axis
//;     ! Pitch(*, %) //; Rotates a Vector3 around the X axis
//;     ! Roll(*, %) //; Rotates a Vector3 around the Z axis
//;     % Abs(*) //; Find the absolute value of a Vector3
//;     * PowComponents(*, %) //; The individual multiplication to a power of a Vector3's components
//;     : IsBackFace(*, *) //; Checks if a face normal vector represents back face
//;     : IsUnitVector(*) //; Checks if a vector is a unit vector
//;     : IsPerpendicular(*, *) //; Checks if two Vectors are perpendicular
//;  * MinValue() //; Retuns the smallest vector possible (based on the double precision floating point structure) for you to use
//;  * MaxValue() //; Retuns the largest vector possible (based on the double precision floating point structure) for you to use
//;  * Zero() //; Retuns an empty Vector3 (0, 0, 0) object for you to use
//; 
//; Internal Functions //; To be called from a new vector3 object like: $Vec1->FunctionName()
//;     @ GetArray() //; Return a 3 element array of this Vector3
//;     % Magnitude() //; Magnitude (aka. length or absolute value) of the Vector3
//;     % Length() //; Magnitude (aka. length or absolute value) of the Vector3
//;     % LengthSquared() //; The squared length of this Vector
//;     * CrossProduct(*) //; Determine the cross product of this Vector3 and another
//;     % DotProduct(*) //; Determine the dot product of this Vector3 and another
//;     % MixedProduct() //; Determine the mixed product of this and 2 other Vectors
//;     ! Normalize() //; Get the normalized vector
//;     * SumComponentSqrs() //; The sum of this Vector3's squared components
//;     * SqrComponents() //; The individual square root of this Vector3's components
//;     % SumComponents() //; The sum of this Vector3's components
//;     % Distance(*) //; Find the distance between this vector and another
//;     " toString() //; Return a string of all the vectors variables to print or so
//;     % Angle(*) //; Find the angle between this Vector3 and another
//;  % AngleBetween(*) //; The angle in degrees between this and another vector
//;     * Max(*) //; Compares the magnitude of this and another and returns the greater Vector3
//;     * Min(*) //; Compares the magnitude of this and another and returns the lesser Vector3
//;     ! Yaw(%) //; Rotates this Vector3 around the Y axis
//;     ! Pitch(%) //; Rotates this Vector3 around the X axis
//;     ! Roll(%) //; Rotates this Vector3 around the Z axis
//;     % Abs() //; Find the absolute value of this Vector3
//;     * PowComponents(%) //; The individual multiplication to a power of this Vector3's components
//;     : IsBackFace(*) //; Checks if a face normal vector represents back face
//;     : IsUnitVector() //; Checks if this vector is a unit vector
//;     : IsPerpendicular(*) //; Checks this and another Vector are perpendicular
//;     
//; Overloaded Operators //; To be called like: $vec1 += $vec2
//;         Supported (If the operator aint on this list then its not supported so dont use it)
//;         +
//;         -
//;         *
//;         /
//;         **
//;         %
//;         +=
//;         -=
//;         *=
//;         /=
//;         **=
//;         %=
//;         ==
//;         !=
//;         <
//;         >
//;         <=
//;         >=
//;         <>
Class Vec3
{
    my $x = 0;
    my $y = 0;
    my $z = 0;
    //; The constructor can either clone a Vector3 or create a new one example
    //; $v2 = new Vec3( $v1 ) //; Will clone a vector $v1 but only if theres only 1 param
    //; If theres more than 1 param it will simply create a new vector using whatever variables it can find or use defaults
    Function __construct($x = 0, $y = 0, $z = 0)
    {
        If( Count(@args) == 1 && isVarClass($x, 'vec3' ) )
        {
            $this->$x = $x->$x;
            $this->$y = $x->$y;
            $this->$z = $x->$z;
        }
        else
        {
            $this->$x = (double)$x;
            $this->$y = (double)$y;
            $this->$z = (double)$z;
        }
    }
    //; Return a string of all the vectors variables to print or so
    Function toString()
    {
        return "($x, $y, $z)";
    }
    //; Return a 3 element array of this Vector3
    Function GetArray()
    {
        return array($x, $y, $z);
    }
    //; Magnitude (aka. length or absolute value) of the Vector3
    Function Magnitude()
    {
        return Sqrt ( SumComponentSqrs() );
    }
    //; The length of this Vector  
    Function Length()
    {
        return Sqrt($x * $x + $y * $y);
    }
    //; The squared length of this Vector  
    Function LengthSquared()
    {
        return ($x * $x + $y * $y);
    }
    //; Find the distance between two Vectors
    //; Pythagoras theorem on two Vectors
    Static Function Distance(Vec3 $v1, Vec3 $v2)
    {
        return Sqrt
        (
            ($v1->$x - $v2->$x) * ($v1->$x - $v2->$x) +
            ($v1->$y - $v2->$y) * ($v1->$y - $v2->$y) + 
            ($v1->$z - $v2->$z) * ($v1->$z - $v2->$z) 
        );
    }
    //; Find the distance between this vector and another
    Function Distance(Vec3 $other)
    {
        return self::Distance($this, $other);
    }
    //; Determine the cross product of two Vectors
    //; Determine the vector product
    //; Determine the normal vector (Vector3 90° to the plane)
    Static Function CrossProduct(Vec3 $v1, Vec3 $v2)
    {
        return new Vec3( $v1->$y * $v2->$z - $v1->$z * $v2->$y,
                         $v1->$z * $v2->$x - $v1->$x * $v2->$z,
                         $v1->$x * $v2->$y - $v1->$y * $v2->$x);
    }
    //; Determine the cross product of this Vector3 and another
    Function CrossProduct(Vec3 $other)
    {
        return self::CrossProduct($this, $other);
    }
    //; Determine the dot product of two Vectors
    Static Function DotProduct(Vec3 $v1, Vec3 $v2)
    {
        return ( $v1->$x * $v2->$x + $v1->$y * $v2->$y + $v1->$z * $v2->$z );
    }
    //; Determine the dot product of this Vector3 and another
    Function DotProduct(Vec3 $other)
    {
        return self::DotProduct($this, $other);
    }
    //; Determine the mixed product of three Vectors
    Static Function MixedProduct(Vec3 $v1, Vec3 $v2, Vec3 $v3)
    {
        return DotProduct(CrossProduct($v1, $v2), $v3);
    }
    //; Determine the mixed product of this and 2 other Vectors
    Function MixedProduct(Vec3 $other_v1, Vec3 $other_v2)
    {
        return self::DotProduct(self::CrossProduct($this, $other_v1), $other_v2);
    }
    //; The individual multiplication to a power of a Vector3's components
    Static Function PowComponents(Vec3 $v1, $power)
    {
        return
        (
            new Vec3
                (
                    Pow($v1->$X, $power),
                    Pow($v1->$Y, $power),
                    Pow($v1->$Z, $power)
                )
        );
    }
    //; The individual multiplication to a power of this Vector3's components
    Function PowComponents($power)
    {
        my $v1 = self::PowComponents($this, $power);
        $x = $v1->$x;
        $y = $v1->$y;
        $z = $v1->$z;
        unset($v1);
    }
    //; Get the normalized vector of a vector
    //; Get the unit vector
    //; Scale a Vector3 so that the magnitude is 1
    Static Function Normalize(Vec3 $v1)
    {
        //; Check for divide by zero errors
        if ( $v1->Magnitude() == 0 ) 
        {
            throw new exception("DivideByZeroException @ _Normalize");
        }
        else
        {
            //; find the inverse of the vectors magnitude
            $inverse = 1 / $v1->Magnitude();
            return new Vec3($v1->$x * $inverse, $v1->$y * $inverse, $v1->$z * $inverse);
        }
    }
    //; Get the normalized vector
    Function Normalize()
    {
        my $v1 = self::Normalize($this);
        $x = $v1->$x;
        $y = $v1->$y;
        $z = $v1->$z;
        unset($v1);
    }
    //; Multiply - Returns the dot product: vector1.X*vector2.X + vector1.Y*vector2.Y  
    Static Function Multiply(Vec3 $vector1, Vec3 $vector2)
    {
        return $vector1->$x * $vector2->$x + $vector1->$y * $vector2->$y;
    }
    //; Determinant - Returns the determinant det(vector1, vector2) 
    Static Function Determinant(Vec3 $vector1, Vec3 $vector2)
    {
        return $vector1->$x * $vector2->$y - $vector1->$y * $vector2->$x;
    }
    //; The sum of a Vector3's squared components
    Static Function SumComponentSqrs(Vec3 $v1)
    {
        return self::SqrComponents($v1)->SumComponents();
    }
    //; The sum of this Vector3's squared components
    Function SumComponentSqrs()
    {
        return self::SumComponentSqrs($this);
    }
    //; A Vector3's components squared
    Static Function SqrComponents(Vec3 $v1)
    {
        return new Vec3($v1->$x * $v1->$x, $v1->$y * $v1->$y, $v1->$z * $v1->$z);
    }
    //; The individual square root of this Vector3's components
    Function SqrComponents()
    {
        my $v1 = self::SqrComponents($this);
        $x = $v1->$x;
        $y = $v1->$y;
        $z = $v1->$z;
        unset($v1);
    }
    //; The sum of a Vector3's components
    Static Function SumComponents(Vec3 $v1)
    {
        return ($v1->$x + $v1->$y + $v1->$z);
    }
    //; The sum of this Vector3's components
    Function SumComponents()
    {
        return self::SumComponents($this);
    }
    //; The angle in degrees between 2 vectors
    Static Function AngleBetween(Vec3 $vector1, Vec3 $vector2)
    {
        my $sin = $vector1->$x * $vector2->$y - $vector2->$x * $vector1->$y;
        my $cos = $vector1->$x * $vector2->$x + $vector1->$y * $vector2->$y;
        return Atan($sin, $cos) * (180 / @PI);
    }
    //; The angle in degrees between this and another vector
    Function AngleBetween(Vec3 $vector1)
    {
        my $sin = $x * $vector1->$y - $vector1->$x * $y;
        my $cos = $x * $vector1->$x + $y * $vector1->$y;
        return Atan($sin, $cos) * (180 / @PI);
    }
    //; Find the angle between two Vectors
    Static Function Angle(Vec3 $v1, Vec3 $v2)
    {
        return Acos(self::Normalize($v1)->DotProduct(self::Normalize($v2)));
    }
    //; Find the angle between this Vector3 and another
    Function Angle(Vec3 $other)
    {
        return self::Angle($this, $other);
    }
    //; Rotates a Vector3 around the Y axis
    Static Function Yaw(Vec3 $v1, $degree)
    {
        return new Vec3
        (
            ($v1->$z * Sin($degree)) + ($v1->$x * Cos($degree)),
            $v1->$y,
            ($v1->$z * Cos($degree)) - ($v1->$x * Sin($degree))
        );
    }
    //; Rotates this Vector3 around the Y axis
    Function Yaw($degree)
    {
        my $v1 = self::Yaw($this, $degree);
        $x = $v1->$x;
        $y = $v1->$y;
        $z = $v1->$z;
        unset($v1);
    }
    //; Rotates a Vector3 around the X axis
    Static Function Pitch(Vec3 $v1, $degree)
    {
        return new Vec3
        (
            $v1->$x,
            ($v1->$y * Cos($degree)) - ($v1->$z * Sin($degree)),
            ($v1->$y * Sin($degree)) + ($v1->$z * Cos($degree))
        );
    }
    //; Rotates this Vector3 around the X axis
    Function Pitch($degree)
    {
        my $v1 = self::Pitch($this, $degree);
        $x = $v1->$x;
        $y = $v1->$y;
        $z = $v1->$z;
        unset($v1);
    }
    //; Rotates a Vector3 around the Z axis
    Static Function Roll(Vec3 $v1, $degree)
    {
        return new Vec3
        (
            ($v1->$x * Cos($degree)) - ($v1->$y * Sin($degree)),
            ($v1->$x * Sin($degree)) + ($v1->$y * Cos($degree)),
            $v1->$z
        );
    }
    //; Rotates this Vector3 around the Z axis
    Function Roll($degree)
    {
        my $v1 = self::Roll($this, $degree);
        $x = $v1->$x;
        $y = $v1->$y;
        $z = $v1->$z;
        unset($v1);
    }
    //; Compares the magnitude of two Vectors and returns the greater Vector3
    Static Function Max(Vec3 $v1, Vec3 $v2)
    {
        if ($v1 >= $v2){return $v1;}
        return $v2;
    }
    //; Compares the magnitude of this and another and returns the greater Vector3
    Function Max(Vec3 $other)
    {
        return self::Max($this, $other);
    }
    //; Compares the magnitude of two Vectors and returns the lesser Vector3
    Static Function Min(Vec3 $v1, Vec3 $v2)
    {
        if ($v1 <= $v2){return $v1;}
        return $v2;
    }
    //; Compares the magnitude of this and another and returns the lesser Vector3
    Function Min(Vec3 $other)
    {
        return self::Min($this, $other);
    }
    //; Find the absolute value of a Vector3
    Static Function Abs(Vec3 $v1)
    {
        return $v1->Magnitude();
    }
    //; Find the absolute value of this Vector3
    Function Abs()
    {
        return $this->Magnitude();
    }
    //;/ Checks if a vector is a unit vector
    Static Function IsUnitVector(Vec3 $v1)
    {
        return Abs($v1->Magnitude() -1) <= @Double_Epsilon;
    }
    //;/ Checks if this vector is a unit vector
    Function IsUnitVector()
    {
        return Abs($this->Magnitude() -1) <= @Double_Epsilon;
    }
    //;/ Checks if two Vectors are perpendicular
    //;/ Checks if two Vectors are orthogonal
    //;/ Checks if one Vector3 is the Normal of the other
    Static Function IsPerpendicular(Vec3 $v1, Vec3 $v2)
    {
        return $v1->DotProduct($v2) == 0;
    }
    //;/ Checks this Vector and another are perpendicular
    //;/ Checks this Vector and another  are orthogonal
    //;/ Checks this Vector is the Normal of the other
    Function IsPerpendicular(Vec3 $other)
    {
        return self::IsPerpendicular($this, $other);
    }
    //;/ Checks if a face normal vector represents back face
    //;/ Checks if a face is visible, given the line of sight
    Static Function IsBackFace(Vec3 $normal, Vec3 $lineOfSight)
    {
        return $normal->DotProduct($lineOfSight) < 0;
    }
    //;/ Checks if a face normal vector represents back face
    //;/ Checks if a face is visible, given the line of sight
    Function IsBackFace(Vec3 $lineOfSight)
    {
        return self::IsBackFace($this, $lineOfSight);
    }
    //; Creates a look vector (Heading) of a given Yaw and Pitch
    Static Function GetLookVector($Yaw, $Pitch)
    {
        return new Vec3(-Sin($Yaw) * Cos($Pitch), Sin($Pitch), -Cos($Yaw) * Cos($Pitch));
    }
    //;/ Retuns the smallest vector possible (based on the double precision floating point structure) for you to use
    Static Function MinValue()
    {
        return new Vec3(@Double_Min, @Double_Min, @Double_Min);
    }
    //;/ Retuns the largest vector possible (based on the double precision floating point structure) for you to use
    Static Function MaxValue()
    {
        return new Vec3(@Double_Max, @Double_Max, @Double_Max);
    }
    //;/ Retuns an empty Vector3 object for you to use
    Static Function Zero()
    {
        return new Vec3(0.0, 0.0, 0.0);
    }
    Operator "+" ($vec)
    {
        If ( isVarClass($vec, "vec3") )
        { $this->$x += $vec->$x; $this->$y += $vec->$y; $this->$z += $vec->$z; }
        else
        { $this->$x += $vec; $this->$y += $vec; $this->$z += $vec; }
    }
    Operator "+=" ($vec)
    {
        If ( isVarClass($vec, "vec3") )
        { $this->$x += $vec->$x; $this->$y += $vec->$y; $this->$z += $vec->$z; }
        else
        { $this->$x += $vec; $this->$y += $vec; $this->$z += $vec; }
    }
    Operator "*" ($vec)
    {
        If ( isVarClass($vec, "vec3") )
        { $this->$x *= $vec->$x; $this->$y *= $vec->$y; $this->$z *= $vec->$z; }
        else
        { $this->$x *= $vec; $this->$y *= $vec; $this->$z *= $vec; }
    }
    Operator "*=" ($vec)
    {
        If ( isVarClass($vec, "vec3") )
        { $this->$x *= $vec->$x; $this->$y *= $vec->$y; $this->$z *= $vec->$z; }
        else
        { $this->$x *= $vec; $this->$y *= $vec; $this->$z *= $vec; }
    }
    Operator "/" (Vec3 $vec)
    {
        If ( isVarClass($vec, "vec3") )
        { $this->$x /= $vec->$x; $this->$y /= $vec->$y; $this->$z /= $vec->$z; }
        else
        { $this->$x /= $vec; $this->$y /= $vec; $this->$z /= $vec; }
    }
    Operator "/=" (Vec3 $vec)
    {
        If ( isVarClass($vec, "vec3") )
        { $this->$x /= $vec->$x; $this->$y /= $vec->$y; $this->$z /= $vec->$z; }
        else
        { $this->$x /= $vec; $this->$y /= $vec; $this->$z /= $vec; }
    }
    Operator "-" (Vec3 $vec)
    {
        If ( isVarClass($vec, "vec3") )
        { $this->$x -= $vec->$x; $this->$y -= $vec->$y; $this->$z -= $vec->$z; }
        else
        { $this->$x -= $vec; $this->$y -= $vec; $this->$z -= $vec; }
    }
    Operator "-=" (Vec3 $vec)
    {
        If ( isVarClass($vec, "vec3") )
        { $this->$x -= $vec->$x; $this->$y -= $vec->$y; $this->$z -= $vec->$z; }
        else
        { $this->$x -= $vec; $this->$y -= $vec; $this->$z -= $vec; }
    }
    Operator "**" (Vec3 $vec)
    {
        If ( isVarClass($vec, "vec3") )
        { $this->$x **= $vec->$x; $this->$y **= $vec->$y; $this->$z **= $vec->$z; }
        else
        { $this->$x **= $vec; $this->$y **= $vec; $this->$z **= $vec; }
    }
    Operator "**=" (Vec3 $vec)
    {
        If ( isVarClass($vec, "vec3") )
        { $this->$x **= $vec->$x; $this->$y **= $vec->$y; $this->$z **= $vec->$z; }
        else
        { $this->$x **= $vec; $this->$y **= $vec; $this->$z **= $vec; }
    }
    Operator "%" (Vec3 $vec)
    {
        If ( isVarClass($vec, "vec3") )
        { $this->$x %= $vec->$x; $this->$y %= $vec->$y; $this->$z %= $vec->$z; }
        else
        { $this->$x %= $vec; $this->$y %= $vec; $this->$z %= $vec; }
    }
    Operator "%=" (Vec3 $vec)
    {
        If ( isVarClass($vec, "vec3") )
        { $this->$x %= $vec->$x; $this->$y %= $vec->$y; $this->$z %= $vec->$z; }
        else
        { $this->$x %= $vec; $this->$y %= $vec; $this->$z %= $vec; }
    }
    //; Compare two Vectors for equality.
    Operator "==" (Vec3 $vec)
    {
        return
        (
            Abs($this->$x - $vec->$x) <= @Double_Epsilon &&
            Abs($this->$y - $vec->$y) <= @Double_Epsilon &&
            Abs($this->$z - $vec->$z) <= @Double_Epsilon
        );
    }
    //; Compare two Vectors for not equality.
    Operator "!=" (Vec3 $vec)
    {
        return !($this == $vec);
    }
    //; Compare the magnitude of two Vectors (less than)
    Operator "<" (Vec3 $vec)
    {
        return $this->SumComponentSqrs() < $vec->SumComponentSqrs();
    }
    //; Compare the magnitude of two Vectors (greater than)
    Operator ">" (Vec3 $vec)
    {
        return $this->SumComponentSqrs() > $vec->SumComponentSqrs();
    }
    //; Compare the magnitude of two Vectors (less than or equal to)
    Operator "<=" (Vec3 $vec)
    {
        return $this->SumComponentSqrs() <= $vec->SumComponentSqrs();
    }
    //; Compare the magnitude of two Vectors (greater than or equal to)
    Operator ">=" (Vec3 $vec)
    {
        return $this->SumComponentSqrs() >= $vec->SumComponentSqrs();
    }
    //; Compare the magnitude of two Vectors (greater than or lower than)
    Operator "<>" (Vec3 $vec)
    {
        return $this < $vec || $this > $vec;
    }
};
Edited by UberFoX
Link to comment
Share on other sites

The next interesting things in classes are Access Modifiers, and in my point of view the most interesting thing is Inheritance.

 

Yea Sputnik supports Inheritance and multiple Inheritance as well as Extender classes that add features to a base class.

I saw no need to add *public, private* stuff to Sputnik classes (although it could be added very easily) since right now its not even important in any way but I suppose if people want to make huge classes and give them to others it maybe useful to hide all stuff they don't need to worry about..

I did add Static functions/variables into classes though (a static can be used by name).

Here is some basic inheritance examples using variables works the same as using functions (see vec3 example for how classes operate fully).

Single inheritance

Class Car //; base car class
{
    Function __Construct()
    {
        println("made car");
    }
    Function doSomethingForCarClass()
    {
        println("Hello");
    }
};

Class BetterCar extends Car //; a class that inherits Car class
{
    Function __Construct()
    {
        parent::__construct(); //; Run constructor for base class
        println("made better car");
    }
    Function doSomethingBetter()
    {
        println("better");
        parent::doSomethingForCarClass(); //; Run function from base class
    }
};

$a = new BetterCar();
$a->doSomethingBetter();
// Prints
// made car
// made better car
// better
// Hello

Multiple inheritance

Class Car //; base car class
{
    Function __Construct()
    {
        println("made car");
    }
    Function doSomethingForCarClass()
    {
        println("Hello car");
    }
};

Class Tank //; base tank class
{
    Function __Construct()
    {
        println("made tank");
    }
    Function doSomethingForTankClass()
    {
        println("Hello tank");
    }
};

Class BetterMachine extends Car, Tank //; a class that inherits Car and Tank class
{
    Function __Construct()
    {
        parent::Car::__construct(); // Run constructor for base Car class
        parent::Tank::__construct(); // Run constructor for base Tank class
        println("made better machine");
    }
    Function doSomethingBetter()
    {
        println("doing better machine");
        parent::Car::doSomethingForCarClass(); // Run function from base Car class
        parent::Tank::doSomethingForTankClass(); // Run function from base Tank class
    }
};

$a = new BetterMachine();
$a->doSomethingBetter();
//; Prints
//; made car
//; made tank
//; made better machine
//; doing better machine
//; Hello car
//; Hello tank

Here is a simple Extender class that adds NEW features to an existing base class

Class Car //; base car class
{
    Function __Construct()
    {
        println("made car");
    }
    Function doSomethingForCarClass()
    {
        println("Hello car");
    }
};

Class extends Car //; a class that will add features to another class
{
    Function doSomethingSPECIALForCarClass()
    {
        println("Hello car special");
    }
};

$a = new Car();
$a->doSomethingForCarClass();
$a->doSomethingSPECIALForCarClass();
//; Prints
//; made car
//; Hello car
//; Hello car special
Edited by UberFoX
Link to comment
Share on other sites

Having access modifiers are necessary (My opinion), Public, Private and Protected.

And yes, I know about static members.

I remember you said Sputnik is on C#, and as I know C# does not support multiple Inheritance (However could be almost solved via Interfaces), good to hear that about Sputnik.

Still moving to Sputnik is not as easy as it have to be.

An IDE or at-least an editor is missing.

Link to comment
Share on other sites

Having access modifiers are necessary (My opinion), Public, Private and Protected.

And yes, I know about static members.

I remember you said Sputnik is on C#, and as I know C# does not support multiple Inheritance (However could be almost solved via Interfaces), good to hear that about Sputnik.

Still moving to Sputnik is not as easy as it have to be.

An IDE or at-least an editor is missing.

 

When an IDE is more ready/suitable I would definitely add private/public etc so that they don't clog up the intelisense auto complete.

Well I'm just one person I cant do everything at once lol.

Coding Sputnik alone requires huge amounts of work and leaves to no time to make stuff like intellisense autocomplete text editor.

I did post the GUI builder I was working on which is a good start (made in Sputnik) a few posts back.

As for the text editor I still recommend Notepad++ with PHP syntax highlight enabled.

Eventually if nobody else wants to help I will make an Sputnik source editor with intellisense, syntax highlight, autocomplete and code snippets myself.

Here is Notepad++

http://notepad-plus-plus.org/

http://en.wikipedia.org/wiki/Notepad%2B%2B

Once installed it becomes the best text editor on windows.

To make it work with Sputnik is very simple:

1. Open Notepad++.

2. Go to settings an Style Configurator

3. Select PHP in the Language: section on the left

4. Under User Ext. : at the bottom left enter spk for Sputnik files

5. Save it

7. Now when you open a Sputnik spk file in Notepad++ it look much better with almost everything syntax coloured.

To make sure your script gets coloured you must add <? and ?> to it example:

<?
//; see the <? at top of file?
Msgbox("Hello World");
//; and ? > at bottom of file
//; this makes it sure that notepad++
//; views it as php code
?>

It's the only solution right now until a better text editor is made (Similar to AutoIts)

<?
Msgbox("Hello World"); //; your code goes in between the top and bottom
?>
Edited by UberFoX
Link to comment
Share on other sites

wonderfull but still many questions

 

Regarding IDE/Editor maybe the author of this can quickly jump in to support the SPK compiler to

Why is the .NET library below? Is it really needed. I allways liked the small < 1 megabyte size of the Autoit executable. 

Link to comment
Share on other sites

wonderfull but still many questions

 

Regarding IDE/Editor maybe the author of this can quickly jump in to support the SPK compiler to

Why is the .NET library below? Is it really needed. I allways liked the small < 1 megabyte size of the Autoit executable. 

 

As I have stated previously Sputnik is a work in progress and not complete as such COM object support are not yet added a LOT of things are added but also a lot of things aren't the language/function reference pages show what is complete so far.

COM Objects will get supported fully eventually.

ISN AutoIt Studio looks very nice he clearly had  a lot of time available to do that unfortunately I don't (yet) I did make a basic GUI Builder however but that is far from complete.

As for an editor I also don't have the time to do that either personally I use Notepad++ using php syntax colouring and find it works just fine.

As for .NET Sputnik exe is only the size is it since it includes a crap ton of stuff in the core (such as a full SQL client) where as AutoIt tends to use external Libraries for most things.

I made it in .NET because I actually wanted something small and simple but it grew beyond what I expected and C# is handling it just fine and there isn't really many PCs that don't have .NET now a days.

Sputnik could have been C++ instead but overall it wouldn't have made that much difference C# is a very fast language with a very good library of optimized stuff.

Link to comment
Share on other sites

ok. Here an example to start including SCITE as the IDE

download http://sourceforge.net/projects/scintilla/

extract the zip to scite folder below sputnik folder

add attached property files in the scite folder

Go / F5 will run sputnik.exe

Alt + F5 will run sputnikw.exe

Lots of things to be edited and changed but at least its a starting point (based on au3 property files)

 

sputnikscite.zip

Link to comment
Share on other sites

ok. Here an example to start including SCITE as the IDE

download http://sourceforge.net/projects/scintilla/

extract the zip to scite folder below sputnik folder

add attached property files in the scite folder

Go / F5 will run sputnik.exe

Alt + F5 will run sputnikw.exe

Lots of things to be edited and changed but at least its a starting point (based on au3 property files)

 

Good work :) although auto-completion on languages like Sputnik is no trivial task making auto complete for AutoIt would seem like a dream in comparison to doing it in languages like Sputnik, PHP.

I can give you the Sputnik grammar file used on the wiki to Syntax colour the whole thing if you want.

Since you never know what the return might be for example how would you handle this?

Function Test( $test )
{
    if($test == null)
        return new carClass();
    else
        return new somethingTotallyDifferentClass();
}

$a = Test();
$a->  //; now the IDE is confused and wonders wtf

The only think I can think of to fix that is to add return values to Sputnik function for example

carClass Function Test( $test )  // HAS to return a carClass object or else it will throw exception
Int32 Function Test( $test )  // HAS to return a 32-bit integer or else it will throw exception
Link to comment
Share on other sites

I don't think you should throw exceptions as there are situations where it can be handy to get different object types returned

If you don't know the type of a variable its hard to do code completion (or CPU / resource intensive)

I leave this up to the researchers http://lambda-the-ultimate.org/node/4493

a. no code completion (as most IDE's do when type is unknown)

b. scan the code for all returntypes of a function and join the possible class functions

c. show a messagebox to the developer that he probably is building code that is hard to follow

d. have the developer to put a typecast or preprocessor hint on the same source code line

I was thinking on a reallife example like

function getMSApp($iMSApp)
{
            if($IMSApp)=$cWordApp then return new "Word.application"
            if($IMSApp)=$cExcelApp then return new "Excel.application"
}

$myApp=getMSApp($cWordapp)
consolewrite($myApp.Name)

I have written a long time ago something for powerpoint or visio depending on whats on the computer system of the enduser.
Preferred was visio but if not fallback to powerpoint to draw as simple flowchart. In that case I worked with the object(s) where type was not allways known

Link to comment
Share on other sites

Well I have received some PM's from the AutoIt staff and they have informed me that although I'm not breaking any rules by being here they do feel that I should rather have my own forum than to promote/track/update etc the status of Sputnik on this forum.

Which is perfectly understandable considering many languages have their own forums such as PHP, QuickMacros, AutoHotKey and what not.

I do wish to thank the staff at AutoIt for being kind and supportive of my project.

If people wish to continue talking about Sputnik I'm afraid you will need to do it at my forum the link is here:

http://uberfox.no-ip.org/forum

It is an old forum I had years ago I used it for my mods and other projects however I recently just deleted everything on it and did a general reset to get rid of all spam and put Sputnik on it well it should still work despite how old it is.

Edit;

If you are having issues posting make sure to read the new member post:

http://uberfox.no-ip.org/forum/showthread.php?31307-Welcome-new-Members!

I will instantly promote anybody to full member who requests it.

Edited by UberFoX
Link to comment
Share on other sites

Is it a secret forum?

 

Nope if it was secret you wouldn't even know it existed... If making an account is too hard for you (even though it does not need any e-mail verification) I could make it fully visible as a guest if you want.

Edit: I have fixed it so even somebody without an account can see everything.

Edited by UberFoX
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...