User Tools

Site Tools


scripting:introduction_to_events

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
scripting:introduction_to_events [2012/03/22 23:52] mitscripting:introduction_to_events [2025/05/28 16:34] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +~~NOTOC~~
 ===== Event Scripting Overview ===== ===== Event Scripting Overview =====
 +Events are triggered on your world server when various things happen - for instance, a 'UseItem' event is triggered when a player uses an item - and you add script for each event - for instance, adding a particle effect and changing a score whenever a particular item is used. You control events on your world server by script through the file ''Data/Script/ServerScript.mit''
  
-You can control events on your world server by script through the file "Data/Script/ServerScript.mit". This section, and the accompanying reference, describe the types of 'events' you can specify and how they are used. +===== Event Script Example =====
  
-=== Event Script Example === +Here's an example of an event script file.. 
  
-Heres an example of an event script file..  +<code>
- +
-<codedoc>+
  Event( "NewBuilding", "3"  Event( "NewBuilding", "3"
  
- *command=say  built building 3  + *say %PLAYER% built building 3  
- *command=grantcash  400 + *grantcash %PLAYER% 400 
  
  
- Event( "UseItem", "KudosItem1" ) + Event( "UseItem", "Bread" ) 
  
- *command=say  used the kudos item  + *say %PLAYER% used the kudos item  
- *command=grantkudos  1  + *grantkudos %PLAYER% 1  
- *command=resetpos  + *resetpos %PLAYER%
  
-</codedoc>+</code> 
 + 
 +This file defines 2 events. In the example above, whenever a player ('Bob' for instance) builds building type 3, the commands within { } braces are executed. i.e.  
 +<code> 
 + *say Bob built building 3  
 + *grantcash Bob 400  
 +</code> 
 +would be entered - the say message will appear in red for all players and 'Bob' will get an extra 40s. Similar procedure for the other event should someone use the 'Bread'  
 + 
 +As well as triggering server commands from script, you can add logic, store persistent (per-player and global) values that can be accessed from other script events, call functions and set timers for events to occur later. 
 +===== Events Reference Links =====
  
-This file defines 2 events. In the example above, whenever a player ('Mit' for instance) builds building type 3, the commands within { } braces are executed. i.e.  +For a full list of events, check the [[scripting:events_reference|event reference]]
-<codedoc> +
- *say Mit built building 3  +
- *grantcash Mit 400  +
-</codedoc> +
-would be entered - the say message will appear in red for all players and 'Mit' will get an extra 40s. Similar procedure for the other event should someone use the kudos item. Hopefully should be fairly straightforward to get.. +
  
-=== commands for scripting === +For a full list of all the '*' commands like **say** and **grantcash**, check the [[reference:server_commands:index|command reference]].
-Note : After making any changes to any of your script files you will need to use the command..  +
-<codedoc> +
- *reloadscript +
-</codedoc>+
  
-.. for the changes to take effect  +===== Next section ===== 
- +  * Go to [[scripting:basic_syntax|Scripting Language Basic Syntax]]
  
scripting/introduction_to_events.1332460373.txt.gz · Last modified: (external edit)