scripting:other_language_features
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| scripting:other_language_features [2012/03/26 00:12] – mit | scripting:other_language_features [2025/05/28 16:34] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 21: | Line 21: | ||
| </ | </ | ||
| Keeping related code separated like this can make it easier to share script across worlds - e.g. You could add your crow tournament feature to another world by copying the '' | Keeping related code separated like this can make it easier to share script across worlds - e.g. You could add your crow tournament feature to another world by copying the '' | ||
| + | |||
| + | ===== Timers ===== | ||
| + | |||
| + | When you want to trigger an event at a certain time, you can add a timer using the script system function '' | ||
| + | |||
| ===== Sleep command ===== | ===== Sleep command ===== | ||
| - | TBD | + | Calling the '' |
| + | // | ||
| + | < | ||
| + | Event( " | ||
| + | { | ||
| + | $loop = 0 | ||
| + | while ( $loop < 10 ) | ||
| + | { | ||
| + | // Trigger effect | ||
| + | *playereffect 6 $gPlayerID $gPlayerID 1 | ||
| + | // Wait one second | ||
| + | Sleep(10) | ||
| + | $loop += 1 | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===== Functions ===== | ||
| + | |||
| + | Functions are defined in your script as shown in this example: | ||
| + | |||
| + | < | ||
| + | Function IsItemASword( $itemNum ) | ||
| + | { | ||
| + | if ( $itemNum = 112 ) // Sword | ||
| + | { | ||
| + | return( 1 ) | ||
| + | } | ||
| + | else if ( $itemNum = 113 ) // Sword 2 | ||
| + | { | ||
| + | return( 1 ) | ||
| + | } | ||
| + | return( 0 ) | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | This example function would be called from another part of your script like this: | ||
| + | < | ||
| + | $isSword = IsItemASword( $gTaskItem1 ) | ||
| + | </ | ||
| + | |||
| + | Functions can have any number of parameters, and always return a value. | ||
| + | <note important> | ||
| + | The ' | ||
| + | </ | ||
| + | |||
| + | ===== Custom Events ===== | ||
| + | You can add your own custom events, and then trigger them from a command. (And hence, you can trigger custom events from within other events). When you trigger a custom event in your script, the new event is executed immediately and the main event waits until it completes or when the new event sleeps. | ||
| + | |||
| + | A custom event is defined as shown: | ||
| + | |||
| + | < | ||
| + | | ||
| + | { | ||
| + | *say My Custom Event has been triggered for %PLAYER% | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | This custom event can be triggered using the command '' | ||
| + | < | ||
| + | | ||
| + | </ | ||
| + | would display '' | ||
| + | |||
| + | <note important> | ||
| + | Be very careful with events calling other events, particularly when using '' | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
scripting/other_language_features.1332720724.txt.gz · Last modified: (external edit)
