Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //From my Amnesia Rebirth Tutorial Series
- //Episode 46 Config Files
- //https://www.youtube.com/playlist?list=PL4KkjlmOwLwwMVqedCNpi6caUxhgyf8Qr
- //-----------------------------------------------------------
- //Config file is typically stored under the appropriate user settings file in the directory Documents\My Games\Amnesia Rebirth\Mods\MOD_NAME
- //Create a global variable to store the config file
- [volatile] cConfigFile@ mpConfig;
- //Load in the config and save it to @mpConfig
- @mpConfig = cLux_GetUserConfig();
- //Immediately apply any changes made to the games options (Ex. Video, Controls, etc.)
- cLux_ApplyUserConfig();
- //Save any updated or newly created variables not related to the games options.
- mpConfig.Save();
- //Print out a message in the debug output at the bottom left
- cLux_AddDebugMessage("Some String");
- //message (String)- The meesage you want to print in the debug output.
- //Changes our decimal number (our float) or our int into a string so that we can print it
- cString_ToString(1920);
- //floatNumber (float)- the number you wish to convert into a string
- //The next 2 values below are optional
- //decimalPlaces (int)- the number of decimal places you want to capture
- //removeZeros (bool)- should zeros be removed from the end of the number (true or false).
- //Get the value of an int from the config file
- mpConfig.GetInt("Screen", "Width", 0);
- //category (String)- the category your variable is in. (Ex. <Screen ...>)
- //variable (String)- the variable within the previous category you've specified. (Ex. <Screen Width=...>)
- //value (int)- the third variable in a get function is irrelavant. Put any value of the the same type here. (We are getting an int so we should put an int here, like Ex. 0)
- //Set the value of an int in the config file
- mpConfig.SetInt("Screen", "Width", 800);
- //category (String)- the category your variable is in. (Ex. <Screen ...>)
- //variable (String)- the variable within the previous category you've specified. (Ex. <Screen Width=...>)
- //value (int)- the value you want set for this category's variable.
- //Get the value of a bool from the config file
- mpConfig.GetBool("Input", "InvertMouse", true);
- //category (String)- the category your variable is in. (Ex. <Input ...>)
- //variable (String)- the variable within the previous category you've specified. (Ex. <Screen InvertMouse=...>)
- //value (int)- the third variable in a get function is irrelavant. Put any value of the the same type here. (We are getting a bool so we should put a bool here, like true or false)
- //Set the value of a bool in the config file
- mpConfig.SetBool("Input", "InvertMouse", true);
- //category (String)- the category your variable is in. (Ex. <Input ...>)
- //variable (String)- the variable within the previous category you've specified. (Ex. <Screen InvertMouse=...>)
- //value (bool)- the value you want set for this category's variable.
- //Get the value of a float from the config file
- mpConfig.GetFloat("Gameplay", "FOV", 0.0f);
- //category (String)- the category your variable is in. (Ex. <Gameplay ...>)
- //variable (String)- the variable within the previous category you've specified. (Ex. <Gameplay FOV=...>)
- //value (float)- the third variable in a get function is irrelavant. Put any value of the the same type here. (We are getting a float so we should put a float here, like Ex. 0.0f)
- //Set the value of a float in the config file
- mpConfig.SetFloat("Gameplay", "FOV", 99.0f);
- //category (String)- the category your variable is in. (Ex. <Gameplay ...>)
- //variable (String)- the variable within the previous category you've specified. (Ex. <Gameplay FOV=...>)
- //value (float)- the value you want set for this category's variable.
- //Get the value of a String from the config file
- mpConfig.GetString("Main", "Chapter", "")
- //category (String)- the category your variable is in. (Ex. <Main ...>)
- //variable (String)- the variable within the previous category you've specified. (Ex. <Main Chapter=...>)
- //value (String)- the third variable in a get function is irrelavant. Put any value of the the same type here. (We are getting a String so we should put a String here, like Ex. "")
- //Set the value of a String in the config file
- mpConfig.SetString("Main", "Chapter", "Chapter 1");
- //category (String)- the category your variable is in. (Ex. <Main ...>)
- //variable (String)- the variable within the previous category you've specified. (Ex. <Main Chapter=...>)
- //value (String)- the value you want set for this category's variable.
- /////////////////////////////////////////////////////
- //Below is some of the code we wrote in this episode
- /////////////////////////////////////////////////////
- //Basic examples
- cLux_AddDebugMessage(cString_ToString(mpConfig.GetInt("Screen", "Width", 0)));
- cLux_AddDebugMessage(cString_ToString(mpConfig.GetInt("Screen", "Height", 0)));
- //If and setint example
- if(mpConfig.GetInt("Screen", "Width", 0) == 1920 && mpConfig.GetInt("Screen", "Height", 0) == 1080){
- mpConfig.SetInt("Screen", "Width", 800);
- mpConfig.SetInt("Screen", "Height", 600);
- }
- //If and setbool example
- if(!mpConfig.GetBool("Input", "InvertMouse", true)){
- mpConfig.SetBool("Input", "InvertMouse", true);
- }
- //If and setfloat example
- if(mpConfig.GetFloat("Gameplay", "FOV", 0.0f) != 99.0f){
- mpConfig.SetFloat("Gameplay", "FOV", 99.0f);
- }
- //Set string example
- mpConfig.SetString("Main", "Chapter", "Chapter 1");
- mpConfig.Save();
- void OnGui(float afTimeStep)
- {
- ImGui_DoLabel(mpConfig.GetString("Main", "Chapter", ""), ImGui_NrmPos(0.75,0.3,10.0f), ImGui_NrmSize(1.0f,1.0f));
- }
- //If setter example
- if(mpConfig.GetString("Main", "Chapter", "") == ""){
- mpConfig.SetString("Main", "Chapter", "New Game");
- }
- //Add to starting room
- [volatile] cConfigFile@ mpConfig;
- @mpConfig = cLux_GetUserConfig();
- mpConfig.SetString("Main", "Chapter", "Chapter 1");
- mpConfig.Save();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement