Skip to content
laz edited this page Jul 6, 2026 · 2 revisions

Form

Forms are way to make UI in the game. Below you can find how to build and send each type of forms. Every form is sent with player.SendForm(form, formAction) and need to have action void void formAction(Player player, string response) that will get called when player submitted form.

CustomForm()

CustomForm example with all possible components. More information about components usage and features you can find in Form Components selection

var form = new CustomForm();
form.Title = "Form title";
form.Content.Add(new Label("label test"));
form.Content.Add(new Dropdown("dropdown test", new List<string>() { "option1", "option2" }, "option1"));
form.Content.Add(new Input("input test", "username", "steve11"));
form.Content.Add(new Slider("slider test", 0, 10, 2));
form.Content.Add(new StepSlider("step slider test", new List<string>() { "value1", "value2", "value3", "value4" }, "value2"));
form.Content.Add(new Toggle("toggle test", true));
player.SendForm(form, formAction);

customform

To access this form values you will need to deserialize received data that in this case is string[]; And now you can access every data field. Data field count is starting from first added component labels including. Example is showing how to access data from this custom form example.

private void formAction(Player player, string response)
{
    var data = JsonConvert.DeserializeObject<string[]>(response); //we need to convert data to string array

    Log.debug(data[0]); //first content added so this output is "label test"
    Log.debug(data[1]); //here we got "option1" or "option2" depens on what was choosen
    Log.debug(data[2]); //"steve11" or anything that was typed in
    Log.debug(data[3]); //"1" to "10" - slider value
    Log.debug(data[4]); // "value1" to "value4" - value where slider was set on
    Log.debug(data[5]); //"true" or "false"
}

ModalForm()

Modal form is simplest form type. It supports two buttons.

var form = new ModalForm();
form.Title = "Form title";
form.Content = "Form text";
form.Button1 = "yes";
form.Button2 = "no";
player.SendForm(form, formAction);

modalform

In action you will get button title that player clicked on.

private void formAction(Player player, string response)
{
    Log.debug(response); //this can be "yes" or "no"
}

SimpleForm()

Simple form can contain multiple buttons.

var form = new SimpleForm();
form.Title = "Form title";
form.Content = "Form text";
form.Buttons = new List<Button>() { new Button("simple button"), new Button("button with pic", "textures/items/apple"), new Button("button with external pic", "https://imagesiteabcd.aa/image.png") };
player.SendForm(form, formAction);

simpleform

In action you will get data that button title that player clicked on.

private void formAction(Player player, string response)
{
    Log.debug(response); //this can be "simple button", "button with pic" or button with external pic"
}

Form Buttons

Button(string, string(optional));

Form buttons are components that can be use only by SimpleForm() form type.

This example shows how to have button with texture from your resource pack. If you need picture for button this is recomended approach because loading picture from external link will take more time.

To load picture from external resources just use picture link like https://imagesiteabcd.aa/image.png instead of "textures/items/apple". And to have button without picture optional value is not needed.

new Button("button with pic", "textures/items/apple")

Form Components

Form components are components that can be used only by CustomForm() form type.

Dropdown(string, List, string(optional))

Dropdown is component which player can use to choose values from dropdown added to CustomForm. In this example dropdown title will be "dropdown test", dropdown options are stored in string list: "option1" and "option2" and "option1" is optional value that will show up as default selected value in dropdown.

new Dropdown("dropdown test", new List<string>() { "option1", "option2" }, "option1")

Input(string, string, string(optional))

Input is component that player can use to enter text. In this example "input test" is title for this component, "username" is placeholder and will appear before player click on input that is when input is inactive and "steve11" is optional value that will be already typed in this input field.

new Input("input test", "username", "steve11")

Label(string)

Label is simplest component, it's just text component. Simple text will appear in form with this component that is this case is "label test".

new Label("label test")

Slider(string, int, int, int(optional))

Slider is component that can be used to choose between numeric values using slider. In this example "slider test" is title for this component, "0" is slider minimum value, 10 in this case is maximum value and 2 is optional value that will set slide in specified default value.

new Slider("slider test", 0, 10, 2)

StepSlider(string, List, string(optional))

StepSlider is something between Slider and Dropdown. Instead of numeric values like with Slider you can choose between string values using StepSlider. In this example "step slider test" is title for this component, "value1", "value2", "value3", "value4" are values that player will be able to slide between and "value2" is optional value that will set slider in specified position.

new StepSlider("step slider test", new List<string>() { "value1", "value2", "value3", "value4" }, "value2")

Toggle(string, bool(optional))

Toggle is simple component that appears as switch in form UI. Player can choose between enable or disable that will be true and false in bool. In this case "toggle test" is title for this component and true is optional value for this toggle to set it enabled or disabled.

new Toggle("toggle test", true)

Clone this wiki locally