Skip to content

Part 2. Client side Settings

rvIceBreaker edited this page Dec 9, 2021 · 8 revisions

In this guide we'll cover how to deal with editable settings. Please read Part 1 if you haven't already.

Sending an Editable Setting

We'll start off by adding a boolean setting to our Mod Controller from part 1.

  1. Open your mod controller object
  2. Add a boolean variable, give it any name you want
  3. Open the GetModSettings function
  4. Add a Add Setting Boolean node and hook it up with a Mod Append Setting node as you did in part 1
  5. Enter a name into the Name field, and keep in mind we'll need this name later
  6. Plug in your variable from step 2 into the Value pin of our new Add Setting Boolean node

At this point, our mod controller will now send the value of our boolean value to every player that opens the ModConfig menu. Note that I wrote 'every player'.

This is because every setting appended to the Mod Object is inherently client-side by default, and client-side settings are always visible to users.

We'll cover the details of client-side vs server-side settings in a later guide.

Receiving setting changes

When a player changes a setting in the Mod Settings menu, they have the ability to apply that change.

When the change is applied, all changed settings are bundled up and sent to the mod controllers they are associated with. The Apply Mod Client Settings event is one the recipients of the changed data, and its how you capture incoming settings changes on the client.

Because our setting above is client-side, we'll be receiving it in the Apply Mod Client Settings event.

  1. Go to the Event Graph of your mod controller
  2. Add the Event Apply Mod Client Settings event
  3. Add a Verify Caller node and link the Calling Object pin
  4. Add a Setting Read Bool node
  5. Link the Settings Object pin to our Setting Read Bool node
  6. Enter your setting name from above into the Setting Name field
  7. Using the Value pin, set the value of your boolean variable you created earlier
  8. Use the Value Set output to set your variable

The Verify Caller node is very important! Read more about it here

The Setting Read ... nodes are helper methods for reading settings values in our Apply Mod ... Settings events.

The Settings Object returned from the Apply Mod ... Settings events contain a collection of the changed settings within them. Because of this design, each setting that you could possibly receive needs to be checked when the Apply Mod ... Settings events fire.

The straight-forward way to do this is to use a Sequence node, however you could code up some adapter to call Setting Read ... nodes in a loop if you have more complex requirements.

At this point, you're now sending out some variable stored in your mod controller, and you can store a new value in that variable when a user makes a change to it. Remember that this currently only applies on the client.

You can compile and test your mod now.

When you open the Mod Settings window, you should see your new setting. If you make a change to this and apply it, the window will close. Re-open the Mod Settings window to see the new value you applied.

note: The Mod Settings window requests new settings every time it is opened, meaning the values you see when the window is opened will be the currently set values for each mod.

Conclusion

In this guide we've covered how to publish a modifiable setting from GetModSettings.

The value of this setting is pulled from a variable stored in our mod controller, and when the user changes that setting we capture the new value and update our variable to the new value.

In the next part we'll talk about dealing with server-side settings, as well as some implications behind client-side vs server-side settings.

Clone this wiki locally