Skip to content

Commit 17bc32c

Browse files
Add missing documentation in vscript
1 parent 405ba1d commit 17bc32c

File tree

1 file changed

+80
-47
lines changed

1 file changed

+80
-47
lines changed

sp/src/vscript/vscript_squirrel.nut

Lines changed: 80 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,62 +7,82 @@ 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+
};
54+
3755
local cVal = (val - A) / (B - A);
38-
cVal = (cVal < 0.0) ? 0.0 : (1.0 < cVal) ? 1.0 : cVal;
56+
57+
if ( cVal <= 0.0 )
58+
return C;
59+
60+
if ( cVal >= 1.0 )
61+
return D;
62+
3963
return C + (D - C) * cVal;
4064
}
4165
4266
function Approach( target, value, speed )
4367
{
44-
local delta = target - value
68+
local delta = target - value;
4569
46-
if( delta > speed )
47-
value += speed
48-
else if( delta < (-speed) )
49-
value -= speed
50-
else
51-
value = target
52-
53-
return value
70+
if ( delta > speed )
71+
return value + speed;
72+
if ( -speed > delta )
73+
return value - speed;
74+
return target;
5475
}
5576
5677
function AngleDistance( next, cur )
5778
{
5879
local delta = next - cur
5980
60-
if ( delta < (-180.0) )
61-
delta += 360.0
62-
else if ( delta > 180.0 )
63-
delta -= 360.0
64-
65-
return delta
81+
if ( delta > 180.0 )
82+
return delta - 360.0;
83+
if ( -180.0 > delta )
84+
return delta + 360.0;
85+
return delta;
6686
}
6787
6888
function FLerp( f1, f2, i1, i2, x )
@@ -83,7 +103,7 @@ function SimpleSpline( f )
83103
84104
function printl( text )
85105
{
86-
return ::print(text + "\n");
106+
return print(text + "\n");
87107
}
88108
89109
class CSimpleCallChainer
@@ -481,23 +501,36 @@ else
481501
}
482502
}
483503

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-
504+
if (developer)
505+
{
506+
// Vector documentation
507+
__Documentation.RegisterClassHelp( "Vector", "", "Basic 3-float Vector class." );
508+
__Documentation.RegisterHelp( "Vector::Length", "float Vector::Length()", "Return the vector's length." );
509+
__Documentation.RegisterHelp( "Vector::LengthSqr", "float Vector::LengthSqr()", "Return the vector's squared length." );
510+
__Documentation.RegisterHelp( "Vector::Length2D", "float Vector::Length2D()", "Return the vector's 2D length." );
511+
__Documentation.RegisterHelp( "Vector::Length2DSqr", "float Vector::Length2DSqr()", "Return the vector's squared 2D length." );
512+
513+
__Documentation.RegisterHelp( "Vector::Normalized", "float Vector::Normalized()", "Return a normalized version of the vector." );
514+
__Documentation.RegisterHelp( "Vector::Norm", "void Vector::Norm()", "Normalize the vector in place." );
515+
__Documentation.RegisterHelp( "Vector::Scale", "vector Vector::Scale(float)", "Scale the vector's magnitude and return the result." );
516+
__Documentation.RegisterHelp( "Vector::Dot", "float Vector::Dot(vector)", "Return the dot/scalar product of two vectors." );
517+
__Documentation.RegisterHelp( "Vector::Cross", "float Vector::Cross(vector)", "Return the vector product of two vectors." );
518+
519+
__Documentation.RegisterHelp( "Vector::ToKVString", "string Vector::ToKVString()", "Return a vector as a string in KeyValue form, without separation commas." );
520+
521+
__Documentation.RegisterMemberHelp( "Vector.x", "float Vector.x", "The vector's X coordinate on the cartesian X axis." );
522+
__Documentation.RegisterMemberHelp( "Vector.y", "float Vector.y", "The vector's Y coordinate on the cartesian Y axis." );
523+
__Documentation.RegisterMemberHelp( "Vector.z", "float Vector.z", "The vector's Z coordinate on the cartesian Z axis." );
524+
525+
__Documentation.RegisterHelp( "clamp", "float clamp(float, float, float)", "" );
526+
__Documentation.RegisterHelp( "max", "float max(float, float)", "" );
527+
__Documentation.RegisterHelp( "min", "float min(float, float)", "" );
528+
__Documentation.RegisterHelp( "RemapVal", "float RemapVal(float, float, float, float, float)", "" );
529+
__Documentation.RegisterHelp( "RemapValClamped", "float RemapValClamped(float, float, float, float, float)", "" );
530+
__Documentation.RegisterHelp( "Approach", "float Approach(float, float, float)", "" );
531+
__Documentation.RegisterHelp( "AngleDistance", "float AngleDistance(float, float)", "" );
532+
__Documentation.RegisterHelp( "FLerp", "float FLerp(float, float, float, float, float)", "" );
533+
__Documentation.RegisterHelp( "Lerp", "float Lerp(float, float, float)", "" );
534+
__Documentation.RegisterHelp( "SimpleSpline", "float SimpleSpline(float)", "" );
535+
}
503536
)vscript";

0 commit comments

Comments
 (0)