scripting:other_language_features
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| scripting:other_language_features [2012/03/25 18:34] – created mit | scripting:other_language_features [2025/05/28 16:34] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ===== Sleep command ===== | ||
| - | |||
| - | |||
| - | |||
| ===== Includes ===== | ===== Includes ===== | ||
| - | |||
| Rather than having all of your script code in the one ' | Rather than having all of your script code in the one ' | ||
| Line 12: | Line 7: | ||
| #include "< | #include "< | ||
| </ | </ | ||
| - | |||
| e.g. | e.g. | ||
| - | |||
| **ServerScript.mit** | **ServerScript.mit** | ||
| < | < | ||
| #include " | #include " | ||
| </ | </ | ||
| - | |||
| **CrowTournament.mit** | **CrowTournament.mit** | ||
| < | < | ||
| - | Event( " | + | Event( " |
| { | { | ||
| - | *setcrow 1 | + | *say Crow Tournament commencing |
| - | | + | |
| } | } | ||
| + | </ | ||
| + | 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 '' | ||
| - | Event( "Custom", "StartCrowTournament" ) | + | ===== Timers ===== |
| + | |||
| + | When you want to trigger an event at a certain time, you can add a timer using the script system function '' | ||
| + | |||
| + | |||
| + | ===== Sleep command ===== | ||
| + | |||
| + | Calling the '' | ||
| + | // | ||
| + | < | ||
| + | Event( "UseItem", "Potion" ) | ||
| { | { | ||
| - | | + | |
| - | *eao StartCrowTournamentUser | + | |
| + | { | ||
| + | // Trigger effect | ||
| + | | ||
| + | // 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 ) | ||
| } | } | ||
| </ | </ | ||
| - | Keeping related code separated | + | This example function would be called from another part of your script |
| + | < | ||
| + | $isSword = IsItemASword( $gTaskItem1 ) | ||
| + | </ | ||
| + | |||
| + | Functions | ||
| + | <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, | ||
| + | |||
| + | 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.1332700447.txt.gz · Last modified: (external edit)
