変数

イベント変数

Event Variables are number or text values which are either global to the project or local to a range of events. They are modified using the Event Variable dialog. To add an event variable, right-click on an event, another variable, or an empty space in the event sheet, and select Add global variable or Add local variable. Variables at the root level of the event sheet (not indented beneath anything else) become global variables, whereas variables in groups or sub-events become local variables.

Event variables are modified with the system actions in the Global & local variables category. They can be retrieved by simply using their name in expressions.

イベント変数であるか、数値またはテキスト値であり、世界的なプロジェクトへのまたはローカルイベントの範囲に。これらは、使用して変更されているイベント変数ダイアログを。イベント変数を追加するには、右クリックイベント、別の変数、またはイベントシートの空きスペースに、選択したグローバル変数を追加したり、ローカル変数を追加します。グループまたはサブイベント内の変数はローカル変数になり、一方、イベントシートのルートレベル(何かの下にインデントされていない)での変数は、グローバル変数になります。

イベント変数はで修飾されているシステムアクションでグローバル&ローカル変数のカテゴリ。彼らは単にで自分の名前を使用して取得することができます表現。

グローバル変数

Global variables show a globe icon. They are always at the top level of an event sheet - they are not sub-events or inside any groups.

グローバル変数は、地球のアイコンが表示されます。彼らはで常にトップレベルのイベントシートの-そうでないサブイベント、または任意の内部グループ。

画像 A global variable.

Global variables store their values between layouts. Events in any layout can access any global variable, even if it was created in a different event sheet that is not included.

Global variables can be moved to another event sheet by cutting and pasting them. After being cut, references to the global variable will disappear because it has been removed; this is normal and nothing to worry about. When you paste the global variable, the references that disappeared will reappear again.

グローバル変数は、レイアウト間その値を格納します。任意のレイアウトのイベントは、それがされていない別のイベントシートで作成された場合でも、任意のグローバル変数にアクセスすることができます含ま。
機械翻訳が変だなあ:どうやら、別のイベントシートにあるグローバル変数にアクセスできる。

グローバル変数は、切断し、それらを貼り付けることにより、別のイベント・シートに移動させることができます。カットされた後、それが削除されているため、グローバル変数への参照が表示されなくなります。これは正常なと心配することは何もないです。あなたはグローバル変数を貼り付けると、姿を消した参照が再び再表示されます。

作成時にstaticという項目があるが選択できない。作成後見るとOn固定になっている。

ローカル変数

Local variables are variables placed nested under other events, or inside a group. They also show with a different icon to global variables.

ローカル変数はイベントやグループのネスト内に配置できる。グローバル変数への異なるアイコンで表示されます。


画像 A local variable.

sc2wiki0001.png

The main difference between global and local variables is local variables can only be accessed in their scope. A local variable's scope is its level of sub-events. All other events at the same level of indentation, or lower levels, can access the local variable. Events above it (less indented) cannot access the local variable.

For example, if an event variable is in a group of events, it becomes a local variable. Then, it will only appear as an option for a variable in events inside that group. In other groups or in other event sheets it does not appear at all and cannot be accessed. This makes the variable local to the scope in which it is placed.

Local variables convenient for temporarily holding variables over a short range of events, such as to calculate an average value (where a temporary 'sum' variable may be necessary). It also helps keep the project simple, since it prevents the need to create more global variables, which appear everywhere in the project even if they are not needed everywhere.

The scope of local variables is designed to mimic how the scope of variables works in real programming languages.

グローバルとローカル変数の間の主な違いは、ローカル変数はその範囲のみにアクセスすることができます。ローカル変数のスコープは、サブイベントのそのレベルです。同じレベルまたは低いレベルのすべてのイベントは、ローカル変数にアクセスすることができます。それより上のイベント(低いインデント)はローカル変数にアクセスできません。

イベント変数は、イベントの基である場合、例えば、それは、ローカル変数となります。そして、それだけで、そのグループ内のイベント内の変数のためのオプションとして表示されます。他のグループで、または他のイベントのシートにそれがすべてでは表示されず、アクセスすることはできません。これは変数になり、ローカルにスコープそれが置かれています。

一時的(一時的な「和」の変数が必要な場合があります)の平均値を計算するなどのイベントの短い範囲にわたる変数を保持するための便利なローカル変数。それはまたそれらがどこでも必要とされていない場合でも、プロジェクト内のどこにでも現れるより多くのグローバル変数を作成する必要がなくなりますので、単純なプロジェクトを保つことができます。

ローカル変数のスコープは、変数のスコープは、実際のプログラミング言語でどのように機能するかを模倣するように設計されています。

Static and constant variables

By default, local variables reset to their initial value whenever entering their scope (usually every tick), like local variables in programming languages. If the variable is marked static in the Event Variable dialog it will persist its value permanently, like a global variable.

Both global and local variables can be marked constant. This makes them read-only: they can be retrieved and compared, but not changed.

その範囲(通常は毎ティック)を入力するたびにデフォルトでは、ローカル変数は、プログラミング言語のローカル変数のように、それらの初期値にリセットされます。変数がマークされている場合、静的にイベント変数ダイアログには、グローバル変数のように、永久にその値を持続します。

グローバルとローカルの両方の変数はconstantにできます。これで読み取り専用になります:これらは取得や比較ができるが、変更はできない。

  • 最終更新:2016-09-25 18:51:08

このWIKIを編集するにはパスワード入力が必要です

認証パスワード