状態
Revision as of 06:09, 1 January 2008 by Asuka Neely (talk | contribs)
LSL ポータル | 関数 | イベント | 型 | 演算子 | 定数 | 実行制御 | スクリプトライブラリ | カテゴリ別スクリプトライブラリ | チュートリアル |
LSLでは、ほとんどのスクリプトは何らかの入力を受け取るか、環境で何らかの変化を検出するまで、アイドル状態にあります。どの瞬間も、スクリプトは何らかのstateにあり、プログラマーによって定義された多くのスキームと一致したイベント、あるいはインプットに反応するでしょう。しかしながら、スクリプトは二つ以上の異なるstateを包含することができ、状態によってイベントやインプットに対して異なる反応をします。
中心的なstateはdefault stateです。スクリプトはコンパイルされた時、リセットもしくはリロードされた時、defaultのstateから入ります。default stateの定義の後に、スクリプトでイベントが処理されることを、どのようにそしてどの変更で使用するのか定義しているstateを、続けて追加することができます。
state target { events }
• label | target | – | state名です。 | |
• event | events | – | 一つ以上の イベントです。 |
target state の定義です。
|- |
state target;
• label | target | – | 実行するstate名です。 |
state target;が実行時にぶつかったとき、現在 のstate と target state が異なる場合
- 現在のstate内でstate_exitが実行する場合、現在のstateは終了し、イベントキューは消去されます。
- Change state to target, any listens are unregistered.
- Trigger state_entry in the target state if it exists.
If target state is the same as the current state, no state change occurs nor do any of the side effects.
Caveats
- On state change:
- All listens are released.
- The event queue is cleared
- The default state must be defined before all others.
- States cannot have user functions or variables inside their immediate scope, only event definitions may be inside a states scope.
Examples
default { touch_start(integer a) { state hello; } } state hello { state_entry() { llOwnerSay("Hello"); state default; } state_exit() { llOwnerSay("Goodbye"); } }
See Also