openplanet Download 1.07 Login with ManiaPlanet

Tutorial: Writing scripts

Scripts in Openplanet are written in Angelscript. A quick overview of the Angelscript syntax can be be found here.

There are 2 locations where Openplanet will search for scripts:

  • [ManiaPlanet]/Openplanet/Scripts/
  • C:/Users/[Username]/Openplanet4/Scripts/

The first folder is installed by Openplanet and contains all the scripts that Openplanet ships with. You should not modify these scripts here or put other scripts here, because any Openplanet update will delete all the contents of this folder. Instead, you have to put your own scripts or script modifications in your user folder.

Tip: You can open your user folder via the Openplanet overlay as well:

Creating your plugin file

Go to your user scripts folder, and create a new file called Plugin_MyFirstScript.as. Note that only files prefixed with Plugin_ will be considered for loading by Openplanet. This way, you can have separate script files that you can #include in your plugins as "libraries".

Starting the plugin

A plugin can have some metadata associated with it:

  • Name
  • Author
  • Settings

These are set via precompiler options and field attributes. Let's start by setting the name and author of your first plugin. Place this at the top of your script:

#name "My first script"
#author "Miss"

We also need an entry point for the plugin, so put this just below:

void Main()
{
}

We'll leave the entry point empty for now. Next, in the Openplanet overlay, select Scripts -> Reload Scripts.

If you open the settings menu now (Openplanet -> Settings), you will see your new plugin under the "Plugins" tab.

If it does not show up, take a look at the log (Openplanet -> Log), which should tell you more about any errors.

Continue to the next page: Entry point execution