Configuration - roidrole/Roids-Tweaker GitHub Wiki

Allows to access other mods' config or create your own

ConfigReader

A class used to read a config file. It is recommended to save the file in a value if to be used again

importing class :

import mods.roidtweaker.config.Reader;

Methods

Only has a single method :

Method Description Return Type
getConfigFile(String path) gets or creates a config file, starting from the instance folder. If you want to target a file in the config folder, you must prepent config/. The file must end in .cfg IConfigFile
getConfig(String path) exactly the same, but a different name IConfigFile

Example

Gets the config file located in myPack/config/coolmod/type1.cfg

val file as IConfig = Reader.getConfigFile("config/coolmod/type1.cfg");

IConfigFile

The file in which the config is stored. It targets an actual file

Methods

All methods get a value from the config file. Example follow

Method Return Type Extra Optional Parameters
getBool bool none
getBoolean bool none
getString string none
getInt int min as int, max as int
getDouble double min as double, max as double
getLong long min as long, max as long
getBooleanArray bool[] isLengthFixed as bool, maxLength as int
getStringArray string[] isLengthFixed as bool, maxLength as int
getIntArray int[] min as int, max as int, isLengthFixed as bool, maxLength as int

Here are the base parameters, to which the above Extra Optional Parameters are appended :

file.getString(category as string, name as string, @Optional defaultvalue as [Insert Return Type], @Optional comment as string)

Here is what they mean :

Parameter Description
category The category of the config you are looking for. Separate subcategories by .
name The name of the config option
----- Starting here, the parameters are all optional and may not be allowed on all types. They are only used when creating a config value
defaultValue If there is no config option already, will set this one
comment When creating a config option, the comment to use
min Minimal value
max Maximal value
isLengthFixed Whether the array is required to be the default length
maxLength Max length of the array

Example Config File

nice_category{ 
    subcat1{
        #Useful Comment
        name="Value we want to see"
    }
    subcat2{
    }
}

To access the value, you must call file.getString("nice_category.subcat1", "name")

To create the value, you must call file.getString("nice_category.subcat1", "name", "Value we want to see", "Useful Comment")