Configuration

The Ares config tutorials explain all about how configuration files are set up and how to change them to set up your game. But how does that all translate into code? Let’s find out.

Go to the Admin -> Setup menu in the Web Portal and edit the tinker.yml config file. You should see a single option named “example” with a value of “%xb”. We’re going to use that in our code.

Try It!

Change the tinker handle method as shown below:

def handle
  color = Global.read_config("tinker", "example")
  client.emit "Here is some #{color}colored%xn text."
end

This tells the code to read the color from the option named “example” in the tinker configuration section.

Save the code and run the tinker command. Notice that the color is blue, the color in our configuration setting.

Change the configuration file to use a different color code (like “%xg” for green) and run the command again. Notice how the color changed without you needing to touch the code.

This article is part of the Code Quickstart tutorial.