Documentation

Plugin settings

Plugins can save settings in the Openplanet settings file, which can then be edited from within Openplanet's settings window. To define a setting, all you have to do is create a global variable and add a Setting metadata line to it.

[Setting name="Something"]
bool Setting_Something;

Supported types

The following types are supported:

  • bool
  • int (including int8, int16, int32)
  • uint (including uint8, uint16, uint32)
  • float
  • string
  • vec2, vec3, vec4
  • Any enum

Default values

Settings can have default values. When they are not user-defined, the setting will be the default value, which is specified by the initial global variable value. The user can also choose to reset every setting back to its default value within Openplanet's settings dialog.

[Setting name="Amount"]
int Setting_Amount = 10;

Note that settings that are set to their default value will not be saved in the settings. That means that if you change your default value, people who were previously on that default value will now also have your changed value.

Attributes

The Setting metadata supports a number of attributes depending on which type your setting variable is. All attributes are optional, however. The following attributes are supported for every type:

Name Description
name The name displayed in the settings dialog.
description The description displayed in the settings dialog, as a little question mark icon next to the setting with a tooltip.
category The category for the setting. This will automatically create multiple tabs, where each category is its own tab.
hidden Takes no value. Marks the setting so it will not be displayed in the Openplanet settings dialog.

A few types allow a couple more attributes:

Types Name Description
int, uint, float min The minimum possible value. When combined with max, turns it into a slider.
int, uint, float max The maximum possible value. When combined with min, turns it into a slider.
int, uint, float, vec2, vec3, vec4 drag Whether to make this a draggable setting rather than where the user must type the value.
vec3, vec4 color Whether this is a color setting. Includes a color picker.
string max The maximum possible length of the string.
string multiline Takes no value. Marks this string as being a multiline input field.
string password Takes no value. Marks this string as being a password, masking the characters with asterisks in the settings dialog.

Hidden settings

Settings can be made hidden by using the hidden attribute. This will make them not appear on the Openplanet settings dialog, which is useful if you want to programatically store some settings manually. Don't put too much content into these, however!

[Setting hidden]
bool Setting_MyHiddenSetting;

Settings tabs

You can create your own scripted settings tabs in the Openplanet settings dialog. To do this, mark a global function with [SettingsTab], like this:

[SettingsTab]
void RenderSettings()
{
  if (UI::Button("Click me!")) {
    print("You clicked the button");
  }
}

By default, the tab will be named Script. You can change this by passing the name attribute, for example [SettingsTab name="Widgets"]. You can also use a different icon for this using the icon attribute, for example [SettingsTab name="Tags" icon="Tag"].


Page updated 24 days ago by Miss