Skip to content

Commit

Permalink
Update example files
Browse files Browse the repository at this point in the history
  • Loading branch information
positively-charged committed Dec 9, 2016
1 parent f154a5a commit c3cf1b6
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 56 deletions.
16 changes: 8 additions & 8 deletions test/bigint.bcs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ typeaware blockscoping namespace BigInt {
// ==========================================================================

str Add( str a, str b ) {
return StrParam( msgbuild: {
return StrParam( msgbuild: ( function msgbuild {
// Calculate sum.
str sum = StrParam( msgbuild: {
str sum = StrParam( msgbuild: ( function msgbuild {
int i_a = a.length() - 1;
int i_b = b.length() - 1;
int carry = 0;
Expand All @@ -43,18 +43,18 @@ str Add( str a, str b ) {
--i_b;
}
append( c: carry * '1' );
} );
} ) );
// Output sum.
int i = sum.length() - 1;
while ( i >= 0 ) {
append( c: sum[ i ] );
--i;
}
} );
} ) );
}

str Sub( str a, str b ) {
return StrParam( msgbuild: {
return StrParam( msgbuild: ( function msgbuild {
// Negative.
if ( Lt( a, b ) ) {
append( c: '-' );
Expand All @@ -63,7 +63,7 @@ str Sub( str a, str b ) {
b = temp_a;
}
// Calculate difference.
str diff = StrParam( msgbuild: {
str diff = StrParam( msgbuild: ( function msgbuild {
int i_a = a.length() - 1;
int i_b = b.length() - 1;
int borrow = 0;
Expand All @@ -76,7 +76,7 @@ str Sub( str a, str b ) {
--i_a;
--i_b;
}
} );
} ) );
// Output difference.
int i = diff.length() - 1;
while ( i >= 1 && diff[ i ] == '0' ) {
Expand All @@ -86,7 +86,7 @@ str Sub( str a, str b ) {
append( c: diff[ i ] );
--i;
}
} );
} ) );
}

bool Lt( str a, str b ) {
Expand Down
16 changes: 8 additions & 8 deletions test/functions.bcs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int StriCmp( str a, str b, int length = -1 ) {

// Get substring.
str StrMid( str string, int start, int length ) {
return StrParam( msgbuild: {
return StrParam( msgbuild: ( function msgbuild {
if ( start < 0 ) {
start = 0;
}
Expand All @@ -47,7 +47,7 @@ str StrMid( str string, int start, int length ) {
append( c: c );
++i;
}
} );
} ) );
}

// Get substring, starting at offset 0.
Expand All @@ -62,7 +62,7 @@ str StrRight( str string, int length ) {

// Get string as uppercase. Character encoding assumed to be ASCII.
str StrToUpper( str string ) {
return StrParam( msgbuild: {
return StrParam( msgbuild: ( function msgbuild {
foreach ( auto ch; string ) {
if ( ch >= 97 && ch <= 122 ) {
append( c: ch - 32 );
Expand All @@ -71,12 +71,12 @@ str StrToUpper( str string ) {
append( c: ch );
}
}
} );
} ) );
}

// Get string as lowercase.
str StrToLower( str string ) {
return StrParam( msgbuild: {
return StrParam( msgbuild: ( function msgbuild {
foreach ( auto ch; string ) {
if ( ch >= 65 && ch <= 90 ) {
append( c: ch + 32 );
Expand All @@ -85,14 +85,14 @@ str StrToLower( str string ) {
append( c: ch );
}
}
} );
} ) );
}

// Supports up to 10 arguments, integer or string.
void Printf( str format, raw arg1 = 0, raw arg2 = 0, raw arg3 = 0,
raw arg4 = 0, raw arg5 = 0, raw arg6 = 0, raw arg7 = 0, raw arg8 = 0,
raw arg9 = 0, raw arg10 = 0 ) {
Print( msgbuild: {
Print( msgbuild: ( function msgbuild {
int num = 0;
int pos = 0;
while ( num < 10 ) {
Expand Down Expand Up @@ -140,7 +140,7 @@ void Printf( str format, raw arg1 = 0, raw arg2 = 0, raw arg3 = 0,
++num;
}
done:
} );
} ) );
}

}
33 changes: 16 additions & 17 deletions test/jm.bcs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ script 980 enter {

private function void Show() {
SetFont( "SMALLFONT" );
HudMessage( msgbuild: {
HudMessage( msgbuild: ( function msgbuild {
append(
s: "\cf", s: gName, s: " - ",
s: "MAP", s: Jm.Utility.ZeroPad( gNumber ),
Expand All @@ -437,20 +437,19 @@ private function void Show() {
s: SoloRanker.GetHsAuthorName()
);
}
}; HUDMSG_FADEOUT | HUDMSG_LOG, 412, 0, 1.5, 0.3, DISPLAY_TIME,
1.0 );
} ); HUDMSG_FADEOUT | HUDMSG_LOG, 412, 0, 1.5, 0.3, DISPLAY_TIME, 1.0 );
}

// Removes the whitespace found in the par time, so it looks nicer when shown
// in the map message.
private function void SetPar( str par ) {
gPar = StrParam( msgbuild: {
gPar = StrParam( msgbuild: ( function msgbuild {
foreach ( int ch; par ) {
if ( ch != ' ' ) {
append( c: ch );
}
}
} );
} ) );
}

}
Expand Down Expand Up @@ -1136,7 +1135,7 @@ script "SoloRanker.ClientQuit" ( int player ) disconnect {

private function void ShowTable() {
SetFont( "SMALLFONT" );
HudMessageBold( msgbuild: {
HudMessageBold( msgbuild: ( function msgbuild {
if ( Hs.IsSet() ) {
DrawHsTime();
append( s: "\n" );
Expand All @@ -1163,7 +1162,7 @@ private function void ShowTable() {
s: ZeroPad( spot.centiseconds ), d: spot.centiseconds,
s: "\n\n" );
}
}; HUDMSG_PLAIN, TBL_LINEID, 0, TBL_X, TBL_Y, 0.0 );
} ); HUDMSG_PLAIN, TBL_LINEID, 0, TBL_X, TBL_Y, 0.0 );
}

private function void ClearTable() {
Expand All @@ -1172,7 +1171,7 @@ private function void ClearTable() {

private function void ShowIndividualTime( int tics ) {
SetFont( "SMALLFONT" );
HudMessage( msgbuild: {
HudMessage( msgbuild: ( function msgbuild {
for ( auto i = 0; i < RANK_LIMIT_MAX; ++i ) {
append( s: "\n" );
}
Expand All @@ -1183,7 +1182,7 @@ private function void ShowIndividualTime( int tics ) {
s: ZeroPad( minutes ), d: minutes, s: ":",
s: ZeroPad( seconds ), d: seconds, s: "\cu.",
s: ZeroPad( centiseconds ), d: centiseconds );
}; HUDMSG_PLAIN, INDI_TIME_LINEID, 0, TBL_X, TBL_Y , 0.0 );
} ); HUDMSG_PLAIN, INDI_TIME_LINEID, 0, TBL_X, TBL_Y , 0.0 );
}

private function void ClearIndividualTime() {
Expand Down Expand Up @@ -1422,7 +1421,7 @@ script 961 ( int player ) disconnect {

private function void ShowTable() {
SetFont( "SMALLFONT" );
HudMessageBold( msgbuild: {
HudMessageBold( msgbuild: ( function msgbuild {
if ( Hs.IsSet() ) {
DrawHsTime();
append( s: "\n\n" );
Expand All @@ -1442,7 +1441,7 @@ private function void ShowTable() {
d: gTable.spots[ i ].points );
}
}
}; HUDMSG_PLAIN, TBL_LINEID_OFFSET, 0, TBL_X, TBL_Y, 0.0 );
} ); HUDMSG_PLAIN, TBL_LINEID_OFFSET, 0, TBL_X, TBL_Y, 0.0 );
}

private function msgbuild void DrawTime() {
Expand All @@ -1460,7 +1459,7 @@ private function msgbuild void DrawTime() {

private function void ShowGoals() {
SetFont( "SMALLFONT" );
HudMessage( msgbuild: {
HudMessage( msgbuild: ( function msgbuild {
if ( gPointsLeft == 0 ) {
DrawTime();
}
Expand All @@ -1477,7 +1476,7 @@ private function void ShowGoals() {
// always one place taken in the score table, which will be the first.
d: gTable.spots[ 0 ].points, s: labelColor, s: " / ", s: totalColor,
d: gPointsTotal );
}; HUDMSG_PLAIN, TBL_LINEID_OFFSET, 0, TBL_X, TBL_Y, 0.0 );
} ); HUDMSG_PLAIN, TBL_LINEID_OFFSET, 0, TBL_X, TBL_Y, 0.0 );
}

function void ClearPointsTable() {
Expand Down Expand Up @@ -1620,7 +1619,7 @@ private function void AnnounceCheat() {
// Prints high score details table.
script "TeamRanker.ShowHs" ( raw showTime ) {
SetFont( "SMALLFONT" );
HudMessage( msgbuild: {
HudMessage( msgbuild: ( function msgbuild {
append( s: "\ciRecord details", s: "\n\n", s: "\ckDate Set:", s: "\n",
s: "\cc", s: Utility.GetMonthName( gHsMonth ), s: " ", d: gHsDay,
s: ", ", d: gHsYear, s: "\n\n", s: "\ckFinish Time:", s: "\n",
Expand All @@ -1635,7 +1634,7 @@ script "TeamRanker.ShowHs" ( raw showTime ) {
if ( gHsUnaccountedPoints > 0 ) {
append( s: "\cgUnaccounted \cd", d: gHsUnaccountedPoints );
}
}; HUDMSG_FADEOUT, HS_TBL_LINE, 0, HS_TBL_X, HS_TBL_Y, showTime, 1.0 );
} ); HUDMSG_FADEOUT, HS_TBL_LINE, 0, HS_TBL_X, HS_TBL_Y, showTime, 1.0 );
}

function void PrepareForSvmz() {
Expand Down Expand Up @@ -2313,7 +2312,7 @@ function void DisplayMinEscapeesFail() {

function void DisplayEscapeeStats() {
SetFont( "SMALLFONT" );
HudMessageBold( msgbuild: {
HudMessageBold( msgbuild: ( function msgbuild {
auto minEscapees = GetMinEscapees();
auto numEscapees = Escapee.GetCount();
// Change the color of the statistic to green to indicate success.
Expand All @@ -2325,7 +2324,7 @@ function void DisplayEscapeeStats() {
append( s: "\ccEscapees: \ck", d: numEscapees, s: "\cc / \ci",
d: minEscapees );
}
}; HUDMSG_PLAIN, LINE_STATS, 0, 1.5, 0.05, 0.0 );
} ); HUDMSG_PLAIN, LINE_STATS, 0, 1.5, 0.05, 0.0 );
}

private function int GetNumAlive() {
Expand Down
10 changes: 4 additions & 6 deletions test/jm_header/map_message.bcs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#if 1

#library "mapmsg"
Expand Down Expand Up @@ -71,7 +70,7 @@ script "MapMsg.Show" enter {

private void Show() {
SetFont( "SMALLFONT" );
HudMessage( msgbuild: {
HudMessage( msgbuild: ( function msgbuild {
append(
s: "\cf", s: gName, s: " - ",
s: "MAP", s: Jm.Utility.ZeroPad( gNumber ),
Expand All @@ -91,20 +90,19 @@ private void Show() {
s: SoloRanker.GetHsAuthorName()
);
}
}; HUDMSG_FADEOUT | HUDMSG_LOG, 412, 0, 1.5, 0.3, DISPLAY_TIME,
1.0 );
} ); HUDMSG_FADEOUT | HUDMSG_LOG, 412, 0, 1.5, 0.3, DISPLAY_TIME, 1.0 );
}

// Removes the whitespace found in the par time, so it looks nicer when shown
// in the map message.
private void SetPar( str par ) {
gPar = StrParam( msgbuild: {
gPar = StrParam( msgbuild: ( function msgbuild {
foreach ( int ch; par ) {
if ( ch != ' ' ) {
append( c: ch );
}
}
} );
} ) );
}

}
Expand Down
8 changes: 4 additions & 4 deletions test/jm_header/solo_ranker.bcs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ script "SoloRanker.ClientQuit" ( int player ) disconnect {

private void ShowTable() {
SetFont( "SMALLFONT" );
HudMessageBold( msgbuild: {
HudMessageBold( msgbuild: ( function msgbuild {
if ( Hs.IsSet() ) {
DrawHsTime();
append( s: "\n" );
Expand All @@ -183,7 +183,7 @@ private void ShowTable() {
s: ZeroPad( spot.centiseconds ), d: spot.centiseconds,
s: "\n\n" );
}
}; HUDMSG_PLAIN, TBL_LINEID, 0, TBL_X, TBL_Y, 0.0 );
} ); HUDMSG_PLAIN, TBL_LINEID, 0, TBL_X, TBL_Y, 0.0 );
}

private void ClearTable() {
Expand All @@ -192,7 +192,7 @@ private void ClearTable() {

private void ShowIndividualTime( int tics ) {
SetFont( "SMALLFONT" );
HudMessage( msgbuild: {
HudMessage( msgbuild: ( function msgbuild {
for ( auto i = 0; i < RANK_LIMIT_MAX; ++i ) {
append( s: "\n" );
}
Expand All @@ -203,7 +203,7 @@ private void ShowIndividualTime( int tics ) {
s: ZeroPad( minutes ), d: minutes, s: ":",
s: ZeroPad( seconds ), d: seconds, s: "\cu.",
s: ZeroPad( centiseconds ), d: centiseconds );
}; HUDMSG_PLAIN, INDITIME_LINEID, 0, TBL_X, TBL_Y , 0.0 );
} ); HUDMSG_PLAIN, INDITIME_LINEID, 0, TBL_X, TBL_Y , 0.0 );
}

private void ClearIndividualTime() {
Expand Down
10 changes: 5 additions & 5 deletions test/jm_header/svmz.bcs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ void DisplayMinEscapeesFail() {

void DisplayEscapeeStats() {
SetFont( "SMALLFONT" );
HudMessageBold( msgbuild: {
HudMessageBold( msgbuild: ( function msgbuild {
auto minEscapees = GetMinEscapees();
auto numEscapees = Escapee.GetCount();
// Change the color of the statistic to green to indicate success.
Expand All @@ -301,7 +301,7 @@ void DisplayEscapeeStats() {
append( s: "\ccEscapees: \ck", d: numEscapees, s: "\cc / \ci",
d: minEscapees );
}
}; HUDMSG_PLAIN, LINE_STATS, 0, 1.5, 0.05, 0.0 );
} ); HUDMSG_PLAIN, LINE_STATS, 0, 1.5, 0.05, 0.0 );
}

private int GetNumAlive() {
Expand All @@ -315,7 +315,7 @@ private int GetNumAlive() {
}

// ==========================================================================
namespace Jm.Svmz.Escapee {
typeaware blockscoping namespace Jm.Svmz.Escapee {
// ==========================================================================

using upmost;
Expand Down Expand Up @@ -350,7 +350,7 @@ int GetCount() {
}

// ==========================================================================
namespace Jm.Svmz.Timer {
typeaware blockscoping namespace Jm.Svmz.Timer {
// ==========================================================================

using upmost;
Expand Down Expand Up @@ -412,7 +412,7 @@ script 908 {
}

// ==========================================================================
namespace Jm.Svmz.Item {
typeaware blockscoping namespace Jm.Svmz.Item {
// ==========================================================================

using upmost;
Expand Down
Loading

0 comments on commit c3cf1b6

Please sign in to comment.