Skip to content

Commit 806750c

Browse files
Add missing documentation in vscript
1 parent bf24798 commit 806750c

File tree

1 file changed

+76
-47
lines changed

1 file changed

+76
-47
lines changed

sp/src/vscript/vscript_squirrel.nut

Lines changed: 76 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,62 +7,78 @@ static char g_Script_vscript_squirrel[] = R"vscript(
77
88
Warning <- error;
99
10-
function clamp(val,min,max)
10+
function clamp( val, min, max )
1111
{
1212
if ( max < min )
1313
return max;
14-
else if( val < min )
14+
if ( val < min )
1515
return min;
16-
else if( val > max )
16+
if ( val > max )
1717
return max;
18-
else
19-
return val;
18+
return val;
2019
}
2120
22-
function max(a,b) return a > b ? a : b
21+
function max( a, b )
22+
{
23+
if ( a > b )
24+
return a;
25+
return b;
26+
}
2327
24-
function min(a,b) return a < b ? a : b
28+
function min( a, b )
29+
{
30+
if ( a < b )
31+
return a;
32+
return b;
33+
}
2534
26-
function RemapVal(val, A, B, C, D)
35+
function RemapVal( val, A, B, C, D )
2736
{
2837
if ( A == B )
29-
return val >= B ? D : C;
38+
{
39+
if ( val >= B )
40+
return D;
41+
return C;
42+
};
3043
return C + (D - C) * (val - A) / (B - A);
3144
}
3245
33-
function RemapValClamped(val, A, B, C, D)
46+
function RemapValClamped( val, A, B, C, D )
3447
{
3548
if ( A == B )
36-
return val >= B ? D : C;
49+
{
50+
if ( val >= B )
51+
return D;
52+
return C;
53+
};
3754
local cVal = (val - A) / (B - A);
38-
cVal = (cVal < 0.0) ? 0.0 : (1.0 < cVal) ? 1.0 : cVal;
55+
if ( cVal < 0.0 )
56+
cVal = 0.0;
57+
else if ( cVal > 1.0 )
58+
cVal = 1.0;;
3959
return C + (D - C) * cVal;
4060
}
4161
4262
function Approach( target, value, speed )
4363
{
44-
local delta = target - value
64+
local delta = target - value;
4565
46-
if( delta > speed )
47-
value += speed
48-
else if( delta < (-speed) )
49-
value -= speed
50-
else
51-
value = target
52-
53-
return value
66+
if ( delta > speed )
67+
return value + speed;
68+
if ( -speed > delta )
69+
return value - speed;
70+
return target;
5471
}
5572
5673
function AngleDistance( next, cur )
5774
{
5875
local delta = next - cur
5976
60-
if ( delta < (-180.0) )
61-
delta += 360.0
62-
else if ( delta > 180.0 )
63-
delta -= 360.0
64-
65-
return delta
77+
if ( delta > 180.0 )
78+
return delta - 360.0;
79+
if ( -180.0 > delta )
80+
return delta + 360.0;
81+
return delta;
6682
}
6783
6884
function FLerp( f1, f2, i1, i2, x )
@@ -83,7 +99,7 @@ function SimpleSpline( f )
8399
84100
function printl( text )
85101
{
86-
return ::print(text + "\n");
102+
return print(text + "\n");
87103
}
88104
89105
class CSimpleCallChainer
@@ -481,23 +497,36 @@ else
481497
}
482498
}
483499

484-
// Vector documentation
485-
__Documentation.RegisterClassHelp( "Vector", "", "Basic 3-float Vector class." );
486-
__Documentation.RegisterHelp( "Vector::Length", "float Vector::Length()", "Return the vector's length." );
487-
__Documentation.RegisterHelp( "Vector::LengthSqr", "float Vector::LengthSqr()", "Return the vector's squared length." );
488-
__Documentation.RegisterHelp( "Vector::Length2D", "float Vector::Length2D()", "Return the vector's 2D length." );
489-
__Documentation.RegisterHelp( "Vector::Length2DSqr", "float Vector::Length2DSqr()", "Return the vector's squared 2D length." );
490-
491-
__Documentation.RegisterHelp( "Vector::Normalized", "float Vector::Normalized()", "Return a normalized version of the vector." );
492-
__Documentation.RegisterHelp( "Vector::Norm", "void Vector::Norm()", "Normalize the vector in place." );
493-
__Documentation.RegisterHelp( "Vector::Scale", "vector Vector::Scale(float)", "Scale the vector's magnitude and return the result." );
494-
__Documentation.RegisterHelp( "Vector::Dot", "float Vector::Dot(vector)", "Return the dot/scalar product of two vectors." );
495-
__Documentation.RegisterHelp( "Vector::Cross", "float Vector::Cross(vector)", "Return the vector product of two vectors." );
496-
497-
__Documentation.RegisterHelp( "Vector::ToKVString", "string Vector::ToKVString()", "Return a vector as a string in KeyValue form, without separation commas." );
498-
499-
__Documentation.RegisterMemberHelp( "Vector.x", "float Vector.x", "The vector's X coordinate on the cartesian X axis." );
500-
__Documentation.RegisterMemberHelp( "Vector.y", "float Vector.y", "The vector's Y coordinate on the cartesian Y axis." );
501-
__Documentation.RegisterMemberHelp( "Vector.z", "float Vector.z", "The vector's Z coordinate on the cartesian Z axis." );
502-
500+
if (developer)
501+
{
502+
// Vector documentation
503+
__Documentation.RegisterClassHelp( "Vector", "", "Basic 3-float Vector class." );
504+
__Documentation.RegisterHelp( "Vector::Length", "float Vector::Length()", "Return the vector's length." );
505+
__Documentation.RegisterHelp( "Vector::LengthSqr", "float Vector::LengthSqr()", "Return the vector's squared length." );
506+
__Documentation.RegisterHelp( "Vector::Length2D", "float Vector::Length2D()", "Return the vector's 2D length." );
507+
__Documentation.RegisterHelp( "Vector::Length2DSqr", "float Vector::Length2DSqr()", "Return the vector's squared 2D length." );
508+
509+
__Documentation.RegisterHelp( "Vector::Normalized", "float Vector::Normalized()", "Return a normalized version of the vector." );
510+
__Documentation.RegisterHelp( "Vector::Norm", "void Vector::Norm()", "Normalize the vector in place." );
511+
__Documentation.RegisterHelp( "Vector::Scale", "vector Vector::Scale(float)", "Scale the vector's magnitude and return the result." );
512+
__Documentation.RegisterHelp( "Vector::Dot", "float Vector::Dot(vector)", "Return the dot/scalar product of two vectors." );
513+
__Documentation.RegisterHelp( "Vector::Cross", "float Vector::Cross(vector)", "Return the vector product of two vectors." );
514+
515+
__Documentation.RegisterHelp( "Vector::ToKVString", "string Vector::ToKVString()", "Return a vector as a string in KeyValue form, without separation commas." );
516+
517+
__Documentation.RegisterMemberHelp( "Vector.x", "float Vector.x", "The vector's X coordinate on the cartesian X axis." );
518+
__Documentation.RegisterMemberHelp( "Vector.y", "float Vector.y", "The vector's Y coordinate on the cartesian Y axis." );
519+
__Documentation.RegisterMemberHelp( "Vector.z", "float Vector.z", "The vector's Z coordinate on the cartesian Z axis." );
520+
521+
__Documentation.RegisterHelp( "clamp", "float clamp(float, float, float)", "" );
522+
__Documentation.RegisterHelp( "max", "float max(float, float)", "" );
523+
__Documentation.RegisterHelp( "min", "float min(float, float)", "" );
524+
__Documentation.RegisterHelp( "RemapVal", "float RemapVal(float, float, float, float, float)", "" );
525+
__Documentation.RegisterHelp( "RemapValClamped", "float RemapValClamped(float, float, float, float, float)", "" );
526+
__Documentation.RegisterHelp( "Approach", "float Approach(float, float, float)", "" );
527+
__Documentation.RegisterHelp( "AngleDistance", "float AngleDistance(float, float)", "" );
528+
__Documentation.RegisterHelp( "FLerp", "float FLerp(float, float, float, float, float)", "" );
529+
__Documentation.RegisterHelp( "Lerp", "float Lerp(float, float, float)", "" );
530+
__Documentation.RegisterHelp( "SimpleSpline", "float SimpleSpline(float)", "" );
531+
}
503532
)vscript";

0 commit comments

Comments
 (0)