This repository was archived by the owner on Jan 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
FSLoader API
robot9706 edited this page Jul 27, 2017
·
10 revisions
This page contains methods and classes provided by FSLoader.
| Class | Description |
|---|---|
| FSHooks | This is the main mod loader class. |
| FSPaths | Contains useful paths. |
| LocalizationManager | Used to add custom texts to the game. |
| Mod | The mod class. |
| Logger | A basic class for logging. |
| ConfigSection | A JSON config section. |
| FileConfig | A custom JSON based config. |
| Field/Method | Description |
|---|---|
| static void AttachInstanceHooks(Mod owner, object instance) | Register hooked methods in a non mod object instance. |
| static void AttachObjectHooks(Mod owner, Type type) | Register hooked methods in a non mod object. |
| static CallContext DoEvent(object source, string sig, object[] parameters) | Broadcast an event, this method will call hooked methods based on the signature ("sig"). "source" is the value of "This" in the CallContext. The returned CallContext is the result of the event. Custom event signatures start with "FSLOADER". |
| static string GameVersion | Returns the current version of the game. |
| static GamePlatform Platform | Returns the current game platform. |
| static T GetLoadedMod() where T : Mod | Returns a loaded mod with the type T. |
| Field/Method | Description |
|---|---|
| DataFolder | Path to the "FalloutShelter_Data" folder. |
| ModsFolder | Path to the "FalloutShelter_Data/Mods" folder |
| Field/Method | Description |
|---|---|
| static void Register(string term, string value) | Register custom terms. Can be used to register names of custom items. |
| Field/Method | Description |
|---|---|
| bool IsEnabled | True if the mod is enabled in the config. |
| ModInfoAttribute Info | Contains the mod info defined in the ModInfo attribute. |
| public ConfigSection GetModConfig() | Returns a ConfigSection for the mod. This is located in the config file (in the "mod_configs" section). |
| virtual void OnInit() | Called after the mod is loaded. |
| Field/Method | Description |
|---|---|
| Logger(string fileName) / ctor | Create a new log file in the "Mods" folder with the defined file name. |
| void WriteLine(string line) | Log a line into the file with a leading time formatted as "yyyy/MM/dd HH:mm:s". |
| void Close() | Closes the log, also called by the "Dispose" method. |
TODO: Config is pretty confusing, need a better way to do this.
| Field/Method | Description |
|---|---|
| void SaveConfig() | Saves the owner file of this section. |
| ConfigSection GetSection(string name) | Get a sub section, if it's not present in the file an empty section will be created. |
| T GetValue(string name) where T : struct | Get a primitive value from the section. If it's not present the default value of T will be returned and added to the section. |
| string GetString(string name) | Get a string from the section, if it's not present the default value will be returned and added to the section. |
| string GetString(string name, string defaultValue) | Same as "string GetString(string name)" but with a custom default value. |
| ConfigArray GetSectionArray(string name) | Returns an array, if it's not present a new array will be made. |
| Field/Method | Description |
|---|---|
| [int index] | Access an element of the array. |
| void Add(ConfigSection section) | Add a new element to the end of the array. |
| void RemoveAt(int index) | Remove an element at an index. |
| int Length | Returns the length of the array. |
| Field/Method | Description |
|---|---|
| FileConfig(string fileName) / ctor | Creates a new JSON based config file. |
All the other methods are the same as the methods of the "ConfigSection" class.