User Tools

Site Tools


scripting

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 [2020/01/29 07:51] – [Introduction to World Scripting] mitscripting [2023/05/15 02:07] (current) – [Custom Events] mit
Line 19: Line 19:
  
 ===== Event Scripting ===== ===== Event Scripting =====
-'Events' are triggered on the server when certain things happen on your world. For example, a certain event is triggered when someone builds a new building. In most circumstances, the server itself handles the normal processes involved in the event - i.e. When someone builds a new building, the server automatically handles the adding of the new building to the map, replication of the new building out to other players, etc etc - then the script is called so you can do extra custom things. +'Events' are triggered on the server when certain things happen on your world. For example, a certain event is triggered when someone builds a new building. In most circumstances, the server itself handles the normal processes involved in the event - i.e. When someone builds a new building, the server automatically handles the adding of the new building to the map, replication of the new building out to other players, initialisation of the contents of the new building, etc etc - then the script is called so you can do extra custom things. 
  
 As an initial example - perhaps you want to have a special building that when built, awards your players with a special item. The simple script to do this might look something like.. As an initial example - perhaps you want to have a special building that when built, awards your players with a special item. The simple script to do this might look something like..
Line 26: Line 26:
 Event( "NewBuilding", "3" Event( "NewBuilding", "3"
  
-  *say %PLAYER% built building 3  +  *say %PLAYER% built building type 3  
-  *grantitem %PLAYER% Special Item+  *grantitem %PLAYER% Special Item
  
 </code> </code>
-If you've already been playing around with owner features on your world, then the *commands might already be familiar - Just about anything you can do using the commands on the server you can do through the scripting system - which leads to lots of possible clever features done in script.+If you've already been playing around with owner features on your world, then the *commands might already be familiar - Just about anything you can do using the commands on the server you can do through the scripting system - which gives the script system all the power you get as a world admin.
  
 For details on the range of events supported see the [[scripting:introduction_to_events|Event Scripting Overview]] and for a full list of the *commands see the [[Reference|reference section]]. For details on the range of events supported see the [[scripting:introduction_to_events|Event Scripting Overview]] and for a full list of the *commands see the [[Reference|reference section]].
  
 ===== Script Files ===== ===== Script Files =====
-The primary 'script' a server runs is stored in a file called ''Data\Scripts\ServerScript.mit'' - this is a text file that can contain commands and scripted events ( You can include other files (see [[scripting:other_language_features|#include]] docs) ). To change your script file, modify it in a text editor (or in the in-game editor when its finished) and then tell the server to reload it bt pressing F11 (or using the command ***reloadscript**). +The primary 'script' a server runs is stored in a file called ''Data\Scripts\ServerScript.mit'' - this is a text file that can contain commands and scripted events ( You can include other files (see [[scripting:other_language_features|#include]] docs) ). To change your script file, modify it in a text editor (or in the in-game editor when its finished) and then tell the server to reload it by pressing F11 (or using the command ***reloadscript**). 
  
 For a quick Hello World example.. Connect to your world, copy the code block below into your serverscript.mit, press f11 then type **&test** For a quick Hello World example.. Connect to your world, copy the code block below into your serverscript.mit, press f11 then type **&test**
Line 45: Line 45:
 } }
 </code> </code>
 +
 +===== Editing your script files =====
 +If you get heavily into scripting, you may find that using an IDE such as Microsoft Visual Studio helps make managing your script files a bit easier. A quick guide to setting that up can be found [[scripting:Setting Up Visual Studio|here]].
 +
 +The intention is that eventually the Script Editor in the F10 World Editor screens would provide that functionality however that is a long way from being complete or usable.
 +
 +===== Custom Events =====
 +Custom Events are a special type of event that is triggered from a command and can include custom parameters. 
 +e.g. ''*event [Name] TestEvent|MyParam''
 +
 +will trigger an event specified in your script code like:
 +
 +<code>Event( "Custom", "TestEvent" )
 +{
 +   $text = $gTextParam[1]
 +   *say Your Parameter was $text
 +}</code>
 +
 +Custom events can be triggered for groups of players - e.g. for everyone online ('EventAllOnline'), or for everyone standing in a particular zone on the map.
 +
  
scripting.1580305880.txt.gz · Last modified: 2020/01/29 07:51 by mit

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki