atwiki-logo
  • 新規作成
    • 新規ページ作成
    • 新規ページ作成(その他)
      • このページをコピーして新規ページ作成
      • このウィキ内の別ページをコピーして新規ページ作成
      • このページの子ページを作成
    • 新規ウィキ作成
  • 編集
    • ページ編集
    • ページ編集(簡易版)
    • ページ名変更
    • メニュー非表示でページ編集
    • ページの閲覧/編集権限変更
    • ページの編集モード変更
    • このページにファイルをアップロード
    • メニューを編集
    • 右メニューを編集
  • バージョン管理
    • 最新版変更点(差分)
    • 編集履歴(バックアップ)
    • アップロードファイル履歴
    • ページ操作履歴
  • ページ一覧
    • ページ一覧
    • このウィキのタグ一覧
    • このウィキのタグ(更新順)
    • このページの全コメント一覧
    • このウィキの全コメント一覧
    • おまかせページ移動
  • RSS
    • このウィキの更新情報RSS
    • このウィキ新着ページRSS
  • ヘルプ
    • ご利用ガイド
    • Wiki初心者向けガイド(基本操作)
    • このウィキの管理者に連絡
    • 運営会社に連絡(不具合、障害など)
ページ検索 メニュー
CoD Mod Tools 日本 Community Wiki
  • ウィキ募集バナー
  • 目安箱バナー
  • 操作ガイド
  • 新規作成
  • 編集する
  • 全ページ一覧
  • 登録/ログイン
ページ一覧
CoD Mod Tools 日本 Community Wiki
  • ウィキ募集バナー
  • 目安箱バナー
  • 操作ガイド
  • 新規作成
  • 編集する
  • 全ページ一覧
  • 登録/ログイン
ページ一覧
CoD Mod Tools 日本 Community Wiki
ページ検索 メニュー
  • 新規作成
  • 編集する
  • 登録/ログイン
  • 管理メニュー
管理メニュー
  • 新規作成
    • 新規ページ作成
    • 新規ページ作成(その他)
      • このページをコピーして新規ページ作成
      • このウィキ内の別ページをコピーして新規ページ作成
      • このページの子ページを作成
    • 新規ウィキ作成
  • 編集
    • ページ編集
    • ページ編集(簡易版)
    • ページ名変更
    • メニュー非表示でページ編集
    • ページの閲覧/編集権限変更
    • ページの編集モード変更
    • このページにファイルをアップロード
    • メニューを編集
    • 右メニューを編集
  • バージョン管理
    • 最新版変更点(差分)
    • 編集履歴(バックアップ)
    • アップロードファイル履歴
    • ページ操作履歴
  • ページ一覧
    • このウィキの全ページ一覧
    • このウィキのタグ一覧
    • このウィキのタグ一覧(更新順)
    • このページの全コメント一覧
    • このウィキの全コメント一覧
    • おまかせページ移動
  • RSS
    • このwikiの更新情報RSS
    • このwikiの新着ページRSS
  • ヘルプ
    • ご利用ガイド
    • Wiki初心者向けガイド(基本操作)
    • このウィキの管理者に連絡
    • 運営会社に連絡する(不具合、障害など)
  • atwiki
  • CoD Mod Tools 日本 Community Wiki
  • Treyarch
  • Scripting Syntax And Grammar

CoD Mod Tools 日本 Community Wiki

Scripting Syntax And Grammar

最終更新:2008年11月22日 10:28

cod4mod

- view
だれでも歓迎! 編集

What Is GSC?

GSC is the CoD4 engine's custom scripting language. It is very quickly compiled at runtime by the game executable during the level load stage. Conveniently, it is also reloaded and recompiled during a "map_restart", which only takes a second or two, allowing for very quick iteration. It also supports an in-game script debugger which functions relatively similarly to debugging in DevStudio, including such features as step by step debugging, watch window, and breakpoints.

GSCは、CoD4エンジンのカスタムメイドのスクリプト言語です。
それは、レベル・ロード・ステージの間、実行可能なゲームによって実行時に非常に速くコンパイルされます。
うまい具合に、それは「map_restart」の間、再ロードされもして、再コンパイルされもします。そして、それに1、2秒がかかるだけです。そして、非常に速い繰り返しのために許します。
それもDevStudioでデバッギングに比較的同様に機能するゲームのスクリプト・デバッガーをサポートします。そして、段階的にデバッギング、監視ウインドウ、そして、ブレークポイントのように、そのような特徴を含みます。


Where Do GSC Files Reside?

GSC files are found in the \raw\maps folder and subfolders. In broad terms there are two types of gsc files, which are separates primarily by filenaming and organizational conventions.

GSCファイルは、\raw\mapsフォルダとサブフォルダで見つかります。
大まかな項に、2種類のgscファイルがあります。そして、それは主にファイル名をつけることによる分別と組織的慣例です。

The first are the utility modules, whose filenames are prefixed by an '_'. Some, like the _ambientpackage.gsc, are designed to be a nearly autonomous module which can run on its own following one or more lines of initialization. Others, such as the aptly named _utility.gsc, are more of a convenience, housing lots of commonly used functions that are implemented in script.

第1は、ファイル名が『_』によって接頭辞を付けられるユーティリティ・モジュールです。
いくつかは、_ambientpackage.gscのように、初期化の一つ以上の行の後で単独で実行することができるほとんど自主的なモジュールであるようになっています。
他(例えば適切に名をつけられた_utility.gsc)は、一層スクリプトで実装される、便利な、覆いたくさんの一般的に用いられる機能よりです。

The second is the level module, which may be made up of one or more files prefixed by the name of the level they are associated with. levelname.gsc is expected by the game to exist and to contain a function called main(). Depending how the level script has been organized, there may be other level files referenced by levelname.gsc. For example, levelname_amb.gsc is the convention which denotes the ambient sound scripting for a given level. This allows the sound department to setup their ambient scripts without interfering with the level scripter, and vice versa. For example, the main function for a map named amb_pkg_test which tests the _ambientpackage might look like this:

第2は、レベル・モジュールです。そして、それは彼らが関係しているレベルという名で前に置かれる一つ以上のファイルから成り立つかもしれません。levelname.gscは、ゲームによって存在して、main()と呼ばれている機能を含むことになっています。
レベル・スクリプトがどのように組織されたかについて次第で、levelname.gsc.によってリファレンスをつけられる他のレベル・ファイルが、あるかもしれません
たとえば、levelname_amb.gscは所定のレベルのために環境サウンド・スクリプトを意味する慣例です。
これは、レベル・スクリプタに干渉することなく、それらの環境スクリプトをセットアップへのサウンド部に与えます、逆もまた真です。

#include maps\_utility;
main()
{
	maps\scriptgen\amb_pkg_test_scriptgen::main();
	level thread maps\amb_pkg_test_amb::main();
}

Notice the second line. The first token, "level", declares the thing which will be acted upon, the second, "thread", declares that a new thread is desired (threads will be discussed in more detail later on), and the third token acts as input, telling the script the name of the function to be used as the basis of the new thread. This third token is in fact made up of two pieces separated by the pair of colons. The first, "maps\amb_pkg_test_amb", tells which file to look in relative to the raw directory, and the second, "main()", identifies the name of the function to be found within that file. If we wished to reference a function in the same file, we would not need the pathing declaration, or the double colons.

第二行に気がついてください。
最初のトークン(レベル)は、行動されることを宣言します、第2(「スレッド」)は、新しいスレッドが要求される(スレッドは、後ほど更に詳細に議論されます)と宣言します、そして、第3のトークンは入力の働きをします。そして、スクリプトに新しいスレッドの基礎として使われる機能の名前を示します。この第3のトークンは、コロンの一組によって切り離される2つの部分から、実際成り立ちます。最初、「maps\amb_pkg_test_amb」どちらがrawディレクトリと比較してのぞくためにファイルするかについて示します、そして、第2("main()")はそのファイルの範囲内で見つかるために、関数の名前を特定します。我々が同じファイルで関数を参照したいならば、我々は行っている宣言または二重のコロンを必要としないでしょう。


Comments

A comment is one or more lines of a script file that are not compiled into the script at run time. They allow us to put notes or explanations about the script into the script file without affecting the script:

コメントは、実行された時刻にスクリプトにコンパイルされないスクリプト・ファイルの一つ以上の行です。
それらは、我々がスクリプトに影響を及ぼすことなくスクリプト・ファイルにスクリプトについてメモまたは説明を置くのを許します:

// this is a single line comment
/* this
   is a multi line
   comment
*/
x = 10; // this is a single line comment placed after a statement which will execute

The "//" declares that script should ignore any text (including it) on the remainder of the line it is found on. As we can see above, that means that such a comment can even be placed following a statement that is meant to be executed at runtime. The other comment type is the multi line comment, which is opened with "/*" and is closed with "*/". Anything in between those special characters will be ignored.

「//」は、スクリプトがそれが見つかる行の残りの上でどんなテキスト(それを含む)でも無視しなければならないと宣言します。
我々が上記を見ることができるように、それはそのようなコメントが実行時で実行されるはずであるステートメントの後でさえ置かれることができることを意味します。
他のコメント・タイプは複数行コメントです。そして、それは「/*」で開けられて、「*/」で閉じられます。
それらの特殊文字の間に何でも、無視されます。


Variables, Arrays and Structs

Variables are not formally declared, instead, you simply name a new variable and assign a value to it:

変数は形式的に宣言されません、その代わりに、あなたは単に新しい変数に名をつけて、値をそれに割り当てます:

var_int = 7; // declare an integer variable
var_float = 4.2; // declare a float variable
var_string = "test_string"; // declare a string variable

GSC is loosely typed, i.e. a variable receives a type (int, float, bool, string, etc.) when it is created based on the value or variable assigned to it. Functions, particularly builtin functions (functions defined in code instead of other script files), will sometimes perform validation on input parameters to ensure that the expected data type is being passed in.

GSCは柔軟に型を検査されます、すなわち、それがそれに割り当てられる値または変数に基づいてつくられるとき、変数はタイプ(int, float, bool, string, その他)を受け入れます。関数(特に組み込まれた関数(他のスクリプト・ファイルの代わりにコードで定められる関数))は、時々、期待されるデータ型が渡されていることを確実とするために、入力パラメータで確認を実行します。

There are some types which can be silently interchanged, for example:

黙ってやりとりされることができる若干の型があります、例えば:

// set the variable to var_int concatenated as a string onto the end of var_string
var_compound_string = var_string + var_int;

// the == operator signifies the value of var_compound_string must be the same as "test_string7"
if ( var_compound_string == "test_string7" )
    return true;

In the above example var_int is automatically treated as a string for the scope of the expression, simplifying the creation of compound strings.

上記の例に、var_intは表現の範囲の文字列と自動的にみなされます。そして、複合文字列の作成を単純化します。

Finally, there is a special "undefined" data type, which is returned by variables that do not yet exist or haven't been initialized. This case can be tested for through the "isDefined" function:

最後に、特別な「未定義」データ型があります。そして、それはまだ存在しないか、初期化されなかった変数によって返されます。
このケースは、"isDefined"関数によって見つけるため検査されることができます:

// the ! operator inverts the value of a boolean statement, ie. true becomes false, and false becomes true
if ( !isDefined( var_does_not_exist ) )
{
    var_does_not_exist = false;
}

// see whether var_does_not_exist is a variable that exists
if ( isDefined( var_does_not_exist ) )
{
    return var_does_not_exist;
}

The above example returns the value that varDoesNotExist has been set to, false, because it doesn't previously exist, causing it to be initialized, at which point it is found to be defined, allowing the return statement to be executed.

上記の例はそれが以前存在しないので、誤って、varDoesNotExistがセットされた値を返します。そして、それが初期化される原因になります。その位置では、それが定められるとわかります。そして、実行されるステートメントをリターンに与えます。


Arrays

Arrays are initialized by assigning "[]". Arrays are zero-indexed and automatically have a "size" member which can be accessed through the dot operator:

配列は、「[]「を割り当てることによって初期化されます。
配列はzero-indexedされて、自動的に、ドット演算子を通してアクセスされることができる"size"メンバーを持っています:

level._ambient_packages[package].elements = []; // declare this variable to be an array
index = level._ambient_packages[package].elements.size; //store the count of elements in the index variable
level._ambient_packages[package].elements[index] = spawnStruct(); // add a struct to the end of the array
level._ambient_packages[package].elements[index].alias = alias; // a new variable w/ the value alias

Here we have created an array in the variable "level._ambient_packages[package].elements", retrieved its size, 0, to determine which index to append our new data to, and finally used the bracket operator on it to assign our new data. If we were to repeat the last three lines, size would have automatically been updated to 1, reflecting the previously added element, and we would be adding elements at the 1th index.

我々が変数で配列をつくってここで、「level._ambient_packages[package].elementsは、どのインデックスに我々の新しいデータを追加するべきかについて決定するために、そのサイズ(0)を取り戻して、我々の新しいデータを割り当てるために、それの上でついにブラケット演算子を使いました。
我々が最後の3行を繰り返すことになっているならば、サイズは1(前に更なる要素を反映すること)まで自動的に更新されたでしょう、そして、我々は第1のインデックスで要素を加えています。

Arrays can also be indexed by strings:

配列は、文字列によってインデックスを付けられることもできます:

level._ambient_packages["outdoors"] = "outdoor_package"; //index into the array by string instead of number
level._ambient_packages["indoors"] = "indoor_package";
level._ambient_packages["both"] = "all";
packageArray = getArrayKeys( level._ambient_packages ); // get an array of the strings used to index
for ( i = 0; i < packageArray.size; i++ )
{
    if ( level._ambient_packages[packageArray[i]] == "indoor_package" )
    {
        return i;
    }
}

The above will return 1 as the value of i.

上記は、i.の値として、1を返します。


Structs

There is one other variable type of note, the struct, which allows for combing multiple pieces of related data together into one variable:

重要な1つの他の可変的な型(struct)があります。そして、それは可変的な1つに一緒にコーミングのために関連したデータの部分を並列に与えます:

timer = spawnStruct(); // declare a struct
timer.start = 10; // add the variable start to it, with the value 10
timer.current = timer.start; // add the variable current to it and set its value to that of start
timer.end = 150; // add the variable end to it, with the value 150

In the example we have declared a timer struct using the spawnStruct() function. Once we have a struct, we can declare new variables as members of it using the dot operator, including variables that contain arrays, or even other structs. Not only is it convenient to group related data together like this, but it also simplifies passing this data around to other functions, or as well see later, using it as input to a thread. For example:

例に、我々はspawnStruct()関数を使用しているタイマーstructを宣言しました。
一旦我々にはstructがあるならば、我々はドット演算子を用いたそれのメンバーとして変数を新しいと宣言することができます、
配列または他のstructさえ含む変数を含むこと。
それはこのように関連したデータを集める便利ならであるだけでなくて、それもまわりのこのデータがスレッドへの入力としてそれを用いて後で他の関数に、または、同様に見る通過を単純化する。

// declare a new function named "is_timer_finished"
// which takes 1 variable as input, which will be referred in the function as timer
is_timer_finished( timer )
{
    if ( timer.current < timer.end ) // if current time is less than end time
    {
        return false;
    }
    else // otherwise end time must be greater than or equal to current time
    {
        return true;
    }
}


Functions

Functions allow you to write script once, and then reference multiple times, possibly changing its results by using different input. The syntax for a function is very simple:

関数によってスクリプトに一度、それから、参照複数回を書くことができます。そして、おそらく異なる入力を用いてその結果を変えます。関数のための構文は、非常に単純です:

foo_bar( param_1, param_2, optional_param ) // decalre the function foo_bar, with 3 inputs
{
    opt_var = 0; // intialize opt_var to 0
    if ( isDefined( optional_param ) )
    {
        opt_var = optional_param; // only set opt_var to optional_param if optional_param was passed in
    }

    return param_1 * param_2 + opt_var; // multiply param_1 by param_2, then add opt_var to the result
}

foo_bar( 2, 6, 5 ) // results equal 17
foo_bar( 2, 6 )    // results equal 12
maps\this_file_name::foo_bar( 2, 6, 3 ) // results equal 15

Here we have created a new function, which tests to see if a value was passed into optional_param, and then performs arithmetic on those values which were passed in. We can also see that by simply defining the function once here, we have a number of different ways to reference it. If it were defined in a different file, we could reference it through the double colon syntax, as seen in the last line. Otherwise, we can simply call the function and supply the parameters as needed. Note that calling a function with not enough parameters will generally result in a script error about using an undefined variable.

ここでは、我々は新しい関数を作成しました。そして、それは値がoptional_paramに通過されて、それから、渡されたそれらの値の上で算数を実行するかどうか見るために試験します。我々は、単にかつて関数をここで定めることによって、我々にはそれを参照文に引用するいくつかの異なる方法があるのを見ることもできます。
それが異なるファイルで定められるならば、最後の行で会われるように、我々は倍のコロン構文を通してそれを参照文に引用することができます。
さもなければ、我々は単に関数を呼ぶことができて、必要に応じてパラメータを供給することができます。
十分なパラメータで関数を呼ばないことが通常、未定義変数を使うことについてスクリプトエラーに終わることに注意すべきです。


Execution Flow

There are numerous methods for directing the flow of execution in script, which will be covered briefly here. Threads are complicated enough to warrant their own section, and thus will be discussed later on.

スクリプトで実行の流れを指示する多数の方法があります。そして、それは短くここでカバーされます。
スレッドは、それらの自身のセクションを正当化するのに十分複雑で、このように後ほど議論されます。


wait

GSC runs once every server frame, and there are 20 server frames per second. Script can not run indefinitely each server frame and still maintain a solid 60FPS, so the wait command is offered to force execution of a given thread to cease for 1 or more frames. The wait command takes a float value as a parameter representing the number of seconds to wait:

GSCはかつてのあらゆるサーバー・フレームを実行します、そして、秒当たりの20のサーバー・フレームがあります。
スクリプトは無期限に各々のサーバー・フレームを実行することができなくて、まだ確実な60fpsを維持することができないので、wait命令は所定のスレッドの実行に1つ以上のフレームのために終わることを強いるために提供されます。
wait命令は、秒数が待つと述べているパラメータとして、フロート値をします:

wait 0.05; // waits 1/20th of a second, or 1 server frame
wait 0.5;  // waits half a second, or 10 server frames
wait 1;    // waits 1 second, or 20 server frames

Of special note is the script error "script runtime warning: potential infinite loop in script", which occurs when the game determines that a thread has run for too long during a single thread. This occurs either when script tries to do too many operations all at once, which can be fixed by inserting wait statements to break up the tasks across multiple frames, or when an infinite for or while loop (discussed later) run without hitting a wait statement, and again the solution is to add a wait statement.

特別の、メモはスクリプトエラー「スクリプトのスクリプト実行時警告:潜在的無限のループ」です。そして、ゲームがスレッドがシングル・スレッドの間、あまりにも長い間実行したと確定するとき、それは起こります。
スクリプトが一度(それは複数のフレーム全体でタスクをバラバラにするためにウエイト・ステートメントを付け加えることによって修正されることができます)ですべてをあまりに多くの活動にしようとするとき、これが思いつきもして、あるいは、ウエイト・ステートメントと再び解決を打つための無限またはそれのないwhileループ(後で議論される)走力は、ウエイト・ステートメントを加えることです。


if

If statements are used to execute statements based on one or more conditions:

Ifステートメントは、一つ以上の条件に基づくステートメントを実行するのに用いられます:

if ( a < b ) // if the value of a is less than the value of b
{
    c = b - a;
}
else if ( a > b ) // otherwise, if the value of a is greater than the value of b
{
    c = a - b;
}
else // otherwise, the value of a must be equal to the value of b
{
    c = 0;
}

Here we see the setting of c to the absolute value of the difference of a and b. The first expression within the parentheses that evaluates to true will cause the statements in the braces below to be executed, and no further checking of other "else if" statements in the chain will occur. Any number of "else if" statements are optional, as well as the optional trailing else statement. Furthermore the expression in the parentheses can be compounded to test multiple things:

我々が違いの絶対値にcのセッティングがわかってここでの、そして、b。
実行されるために下記の大括弧で本当の意志原因にステートメントを評価する括弧とチェーンで他の"else if"ステートメントをさらにチェックしないこと最初の発現は、起こります。
他にステートメントをオプションに追跡するだけでなく、多くの"else if"ステートメントはオプションです。
さらに、括弧の表現は、複数のものをテストするために組み合わせられることができます:

if ( !isDefined( a ) || !isDefined( b ) ) // if either a or b has yet to be declared
{
    c = 0;
}

The "||" operator represents the concept of or. So in the above example if either a is not defined or b is not defined, then the statment becomes true. An interesting note is that if a is not defined, then whter b is defined will not be checked, as the expression is already known to be true. The expression could be equivalently written using the and operator "&&":

「||」演算子は、あるいはの概念を意味します。
上記の例もしもでもそう定められないでまたはbです定めます、それから、statmentは真実になります。
面白いメモは、それですbがそうである定義済み、当時のwhterでないのが、定義済みの意志です表現が真実であることをすでに知られているように、チェックされません。
表現は、同等に書かれることができます、AND演算子「&&」:

// again, if either a or b has yet to be declared, this time using a slightly different logic
if ( !( isDefined( a ) && isDefined( b ) ) )
{
    c = 0;
}

All expressions in an and operation must be true for the entire expression to be true, thus similarly to the or operator, if a is determined to not be defined, whether b is defined will not be checked as the expression is already known to be false.

すべての表現、そして、作動は、このように同様にオア演算子に、真実の全式にとって真実でなければなりません意志が強いです定められません、表現が間違っていることをすでに知られているように、bが定められるかどうかはチェックされません。


switch

The switch statement allows for a more compact script when you want to have multiple execution paths based on numerous possible values for a single variable:

あなたが複数の実行経路をシングル変数のために多数の可能性がある値に基礎をおいておきたいとき、スイッチ文はより簡潔なスクリプトを考慮に入れます:

switch ( level.gametype ) // check the value of level.gametype
{
    case "sab": // if the value of level.gametype is "sab"
        setDvar( "ui_gametype_text", "@MP_SABOTAGE" );
        break;

    case "sd": // if the value of level.gametype is "sd"
        setDvar( "ui_gametype_text", "@MP_SEARCH_AND_DESTROY" );
        break;

    case "dom": // if the value of level.gametype is "dom"
        setDvar( "ui_gametype_text", "@MP_DOMINATION" );
        break;

    case "war": // if the value of level.gametype is "war"
    default: // if the value of level.gametype is none of the values listed above
        setDvar( "ui_gametype_text", "@MP_WAR" );
        break;
}

Rather than use a long series of if-else-if statements, the switch statement will skip to the case statement whose value matches the value of the variable in parentheses (numerals may also be used as the parameter to the case statements), and if no matching case statement is found, execution skips to "default:". Multiple case statements can be stacked together, as seen above where default and case"war" are together, allowing multiple values to result in the same code execution. It's important to add the break statement after your list of desired statments, otherwise execution would continue on past the next case statement and execute the code there as well.

長い一連のif-else-ifステートメントを使うよりはむしろ、スイッチ文は値が括弧(数字が、ケース・ステートメントへのパラメータとしても使われるかもしれません)で変数の値に匹敵するケース・ステートメントにスキップします、そして、あっているケース・ステートメントが見つからないならば、実行は「デフォルトにスキップします:」。
そこでデフォルトとcase"warを越えるのを見られるように、複数のケース・ステートメントは一緒に積み重なることができます」、同じコード実行に終わるために値を並列に与えて、一緒にそうです。
要求されたstatmentsのあなたのリストの後、ブレーク・ステートメントを加えることは重要です、さもなければ、実行は次のケース・ステートメントを過ぎて続いて、同様にコードをそこで実行します。


for

The for loop is typically used to perform the same set of statements on a series of items. it takes three expressions as input separated by semicolons (all 3 of which are optional, though the semicolons are not), the initialization (to intialize variables as needed), the continuation check (an expression which if true will cause the script within the for loop's braces to execute again, otherwise the for loop will be left, and execution will continue on past it), and the post execution step (the opportunity to perform variable incrementing or other such loop maintenance just after the loop has been executed, but just before the continuation check occurs):

forループは一連のアイテムの上でステートメントの同じセットを実行するのに典型的に用いられます。それはセミコロン(セミコロンがそうではないけれども、それのうちの全3つはオプションです)で区切られる入力、初期化(必要に応じて変数をintializeするために)、継続チェック(表現、そしてそれは、本当の意志が再び実行するforループの大括弧の中でスクリプトを引き起こすならば、さもなければforループは残されます、そして、実行はそれを過ぎて続きます)とポスト実行ステップ(たった今継続チェックが起こる前に、増加している変数を実行する機会またはループの直後にそのようなループ・メンテナンスがそうであった他が、実行しました)3つの表現を周知のことと見なします:

// starting off with idx equal to 0, and iterating as long as it is less than the number of elements
// in the weaponslist array, increasing idx by 1 on each iteration
for( idx = 0; idx < weaponsList.size; idx++ )
{
    weapon = weaponsList[idx];
    if ( weapon == "none" )
        continue; // skip the remainder of this for loop, but continue iterating
    if ( weapon == "claymore" )
        continue; // skip the remainder of this for loop, but continue iterating
    if ( weapon == "claymore_detonator" )
        continue; // skip the remainder of this for loop, but continue iterating
					
    self switchToWeapon( weapon ); 
    break; // leave the for loop
}

This for loop will start by setting idx to 0, check if that value is less than the size of the weaponsList and if so run the code in the braces, then increase the value of idx by 1 and check against the size again, repeating this entire process (with the exception of the initializing of idx to 0, which only occurs once) until the continuation check is false.

ループのためのこれはidxに0をつけることから始めて、その値がweaponsListのサイズより少ないかどうか調べて、大括弧でもしそうならばコードを実行します、そして、idxの値を1増やして、サイズに対してもう一度確認してください。継続チェックまでこの全プロセス(0(かつて起こるだけの)までidxを初期化することを除いて)を繰り返すことは間違っています。

We also see two additional keywords that may be used in a for loop. The break statement immediately leaves the for loop and execution goes on past it. The continue statement skips the remainder of execution within the loop, moving directly to the post execution step.

我々も、forループで使われるかもしれないさらに2つのキーワードを見ます。
ブレーク・ステートメントはすぐにforループを去ります、そして、実行はそれを過ぎて続きます。
continue文は環状線の中で実行の残りをスキップします。そして、直接ポスト実行ステップへ移ります。


while

A while loop is functionally very similar to a for loop, in fact a for loop can be made functionally equivalent to a while loop by omitting the initialization and post execution step. A while loop simply tests a single expression and as long as that expression is true, the body of the while loop will execute, and this will repeat until that expression is false:

forループが初期化を省略することによって機能的にwhileループに等しくされることができて、実行ステップを掲示することができるという事実では、whileループはforループと機能的に非常に類似しています。
whileループは単にシングル表現をテストして、その表現の長さの真実です、whileループの量は実行して、そして、これはその表現まで間違っていると繰り返す:

index = 3;
while ( index ) // as long as index is true, which is as long as it is not zero
{
    iprintlnbold( "index is currently " + index ); // prints the given string to the screen
    index--; // decrease the value of index by 1
}

iprintlnbold( "done" ); // prints the given string to the screen

// results:
// index is currently 3
// index is currently 2
// index is currently 1
// done

Also note that the continue and break statements are valid for the while loop and function the same way as in a for loop.

また、それに注意します∥続けます、そして、ブレーク・ステートメントはwhileループにあてはまって、forループの場合のように同じ方法で機能します。


Threads

Threads allow mutiple paths of execution to run in the same server frame, and they can wait until a certain event occurs, do some processing, and then either end themselves, or wait again for the next event they care about. They are very simple to create, you simply define a function as you normally would, and then launch the thread using the name of that function:

特定のイベントが起こるまで、同じサーバー・フレームで実行する実行のスレッドallow mutiple通り道とそれらは待つことができて、いくらかの処理をして、それから、彼ら自身を終えるか、再び、それらが気にかける次のイベントを待ちます。
それらは非常につくりシンプルです、あなたは単に関数をあなたが通常そうするだろうと、定義します、それから、その関数の名前を使用しているスレッドを発射してください:

// declare the function foo that is intended for use as a thread
foo()
{
    for ( ; ; ) // this for loop continues forever
    {
        do_stuff();
        wait 5;
    }
}

thread foo(); // start up a thread, using the function foo as the basis of the thread

In this example the thread foo will call the do_stuff() function every 5 seconds for the remainder of the level.

この例では、スレッドfooはdo_stuffを呼びます()、レベルの残りのために5秒おきに機能してください。


self

When a thread is run on a particular variable, say the player, a trigger, or perhaps a struct, that variable can be referenced from within the thread using the self variable:

スレッドが特定の変数の上で実行されるとき ― プレーヤー、トリガーまたはおそらくstructでは、なっている ― その変数は、自身変数を使っているスレッド内からリファレンスをつけられることができます:

// declare the function foo_self that is intended for use as a thread that runs on a specific object
foo_self()
{
    for ( ; ; ) // this for loop continues forever
    {
        self moveto(self.origin + (0, 0, 5), .05); // self is the object the thread is run on
        wait 0.05;
    }
}

// start up a thread, using the function foo_self as the basis of the thread, and run it on elevator
elevator thread foo_self();

Here, we have run the foo_self() thread on an entity named elevator, and the thread causes it to smoothly rise 5 units every server frame by referencing it through the self variable

ここで、我々がfoo_self()を実行して、エンティティ名をつけられたエレベーターとスレッドの上のスレッドが、それが自身変数を通してそれを参照文に引用することによって滑らかに5つの単位あらゆるサーバー・フレームを上げる原因になります


notifies, waittills And endOns

While a thread can be made to execute until completion and then end, the most typical use of a thread is for processing that you want to occur repeatedly throughout the level or until some event occurs. In the examples we've seen so far, the threads use an infinite for loop and run until the level is complete. Now we'll see how we can use Waittills and EndOns to control when threads execute and stop. Each of these statements take a string as their parameter, are run on some variable (be it level, player, an entity, or a struct), and are triggered by a corresponding call to notify run on that same variable with the same string as its parameter. Let's see how we could use these statements to cause an elevator to rise 100 units at the player's command:

スレッドが完成とその時まで終わりを実行させられることができる間、スレッドで最も典型的使用はあなたがレベル中至る所で繰り返し起こることを望む処理のためであるか、若干のイベントまで起こります。
我々がここまで見た例に、レベルが完了するまで、スレッドはループに賛成で、実行される無限を使います。
直ちに、我々はスレッドが実行して、止めるとき、我々がどのように支配にWaittillsとEndOnsを使うことができるかについて見ます。
これらのステートメントの各々は、それらのパラメータ文字列を周知のことと見なして、若干の変数(一直線にそれ、プレーヤー、エンティティまたはstructであってください)の上で実行されて、そのパラメータと同じ文字列でその同じ変数の上で実行されて通知する対応する呼び出しによって引き起こされます。
我々がどのようにエレベーターがプレーヤーの命令で100の単位を上げる原因になるためにこれらのステートメントを使うことができたかについて見ましょう:

rise()
{
    // declare that this thread should end if the notify "death" is sent on self
    self endOn( "death" );

    for ( ; ; )
    {
        self waittill( "rise" ); // wait until the notify "rise is sent on self
        for ( count = 20; count; count-- )
        {
            self moveto(self.origin + (0, 0, 5), .05);
            wait 0.05;
        }
        self notify( "rise done" ); // send the notify "rise done" on self
    }
}

elevator thread rise();

// later on the player presses the up button:
elevator notify( "rise" );
elevator waittill( "rise done" );

This rise() thread waits until something notifies the elevator it was attached to, causing it to wake up and start executing. Once it has completed moving the elevator, it sends a notify back through the elevator that it is done. The thread begins with an endOn("death") statement, which will cause the thread to cease if the elevator is ever destroyed.

何かがそれが付随されたとエレベーターに通知するまで、このrise() threadは待ちます。そして、それが起きて、実行することを始める原因になります。
一旦それがエレベーターを動かすことを完了するならば、それは送りますそれがされることをエレベーターによる背中に通知します。
スレッドはendOn("death")ステートメントから始めます。そして、エレベーターが破壊されるならば、それはスレッドが止む原因になります。


(Original:"http://wiki.treyarch.com/wiki/Scripting_Syntax_And_Grammar")

すべて読む

タグ:

+ タグ編集
  • タグ:
タグの更新に失敗しました
エラーが発生しました。ページを更新してください。
ページを更新
「Scripting Syntax And Grammar」をウィキ内検索
LINE
シェア
Tweet
CoD Mod Tools 日本 Community Wiki
記事メニュー

IW navigation

  • Main Page
  • All Categories
  • Mod Tools Category
  • Maya Category
  • Radiant Category
  • Latest Articles
  • Forum


Treyarch navigation

  • Main Page
  • Scripting
  • Modding
  • Radiant
  • AI
  • Multiplayer Design
  • Mission Design
  • Forum


information

  • サンドボックス
  • @wiki利用ガイド


- , - , -
記事メニュー2

recent changes

取得中です。

最近更新されたページ
  • 4914日前

    out of memory error
  • 4914日前

    Direct Light
  • 4914日前

    Cod4 Compile Tools について
  • 5042日前

    Category/Mod Tools Comments
  • 5311日前

    Treyarch/Main Page Comments
  • 5614日前

    Treyarch/Category/Scripting
  • 5614日前

    Treyarch/Main Page
  • 5724日前

    Category/Localize Comments
  • 5807日前

    Main Page Comments
  • 5825日前

    トップページ
もっと見る
最近更新されたページ
  • 4914日前

    out of memory error
  • 4914日前

    Direct Light
  • 4914日前

    Cod4 Compile Tools について
  • 5042日前

    Category/Mod Tools Comments
  • 5311日前

    Treyarch/Main Page Comments
  • 5614日前

    Treyarch/Category/Scripting
  • 5614日前

    Treyarch/Main Page
  • 5724日前

    Category/Localize Comments
  • 5807日前

    Main Page Comments
  • 5825日前

    トップページ
もっと見る
ウィキ募集バナー
急上昇Wikiランキング

急上昇中のWikiランキングです。今注目を集めている話題をチェックしてみよう!

  1. 機動戦士ガンダム バトルオペレーション2攻略Wiki 3rd Season
  2. ワールドトリガー@wiki
  3. 提督たちの憂鬱 支援SSほか@ まとめウィキ
  4. オレカバトル アプリ版 @ ウィキ
  5. ファイアーエムブレム用語辞典
  6. アメコミ@ wiki
  7. ときめきメモリアル大辞典
  8. テレビ番組スポンサー表 @ wiki
  9. GUNDAM WAR Wiki
  10. 固めまとめWiki
もっと見る
人気Wikiランキング

atwikiでよく見られているWikiのランキングです。新しい情報を発見してみよう!

  1. アニヲタWiki(仮)
  2. ストグラ まとめ @ウィキ
  3. ゲームカタログ@Wiki ~名作からクソゲーまで~
  4. 初音ミク Wiki
  5. 機動戦士ガンダム バトルオペレーション2攻略Wiki 3rd Season
  6. 発車メロディーwiki
  7. 検索してはいけない言葉 @ ウィキ
  8. 機動戦士ガンダム EXTREME VS.2 INFINITEBOOST wiki
  9. オレカバトル アプリ版 @ ウィキ
  10. Grand Theft Auto V(グランドセフトオート5)GTA5 & GTAオンライン 情報・攻略wiki
もっと見る
新規Wikiランキング

最近作成されたWikiのアクセスランキングです。見るだけでなく加筆してみよう!

  1. まどドラ攻略wiki
  2. MadTown GTA (Beta) まとめウィキ
  3. シュガードール情報まとめウィキ
  4. SurrounDead 攻略 (非公式wiki)
  5. R.E.P.O. 日本語解説Wiki
  6. Dark War Survival攻略
  7. ちいぽけ攻略
  8. シミュグラ2Wiki(Simulation Of Grand2)GTARP
  9. カツドンチャンネル @ Wiki
  10. AviUtl2のWiki
もっと見る
全体ページランキング

最近アクセスの多かったページランキングです。話題のページを見に行こう!

  1. 参加者一覧 - ストグラ まとめ @ウィキ
  2. サーヴァント/一覧/クラス別 - Fate/Grand Order @wiki 【FGO】
  3. スターリーワールド(星のカービィ ディスカバリー) - アニヲタWiki(仮)
  4. 魔獣トゲイラ - バトルロイヤルR+α ファンフィクション(二次創作など)総合wiki
  5. 大長編 タローマン 万博大爆発 - アニヲタWiki(仮)
  6. 稼ぎ - 地球防衛軍6 @ ウィキ
  7. ミッション攻略 - 地球防衛軍6 @ ウィキ
  8. トールギスⅢ - 機動戦士ガンダム バトルオペレーション2攻略Wiki 3rd Season
  9. 少女 浴室 - 検索してはいけない言葉 @ ウィキ
  10. 赤いガンダム - 機動戦士ガンダム EXTREME VS.2 INFINITEBOOST wiki
もっと見る

  • このWikiのTOPへ
  • 全ページ一覧
  • アットウィキTOP
  • 利用規約
  • プライバシーポリシー

2019 AtWiki, Inc.