A Hat in Time Guide

Writing to an .Ini file for Configs for A Hat in Time

Writing to an .Ini file for Configs

Overview

This Guide will help teach you how to add configuration settings to an a hat in time mod file

What is the Ini file

The Ini file, called Modinfo.ini, is a file that is automatically created when you make a new mod, It stores basic info about the mod, The name, The Creator “Usually stated as me”, and the description.

This file can be opened using any kind of text editor.

[Info]
States what the info of the mod is
name
Refers to the mod name
author
Who made it
description
Mod description
version
What version is the mod and how many updates have been released for it
is_cheat
false(Not exactly sure what this one does but i belive it refers to the Death wishes and being able to use the dev console, it automaticly sets to false)
icon
Refers to the name of the icon file, usually larger than 100*100 and needs to be a square
modclass
Refers to what file is the file that extends GameMod, and does whatever the player has defined the class to do

All these files are automatically added and don’t need to be messed with alot

Editing the Ini file

Now that we know WHAT the ini file is and what it does we need to know how to edit this,
THE EDITOR MUST BE CLOSED , The file(Ini) must be open and the editor must not be opened. If the editor is for some reason, the open file will not save and you will need to rewrite the ini file again.
There are many options on what we can do in this file,

Tags

Tags are what appear in the workshop. They tell the user what the mod contains, some examples below:

[Tags]
What they do (If 1 then true, if 0 then false)
HasHat
Does the player attain a hat
AutoGiveItems
Does it gave the player the items on mod loaded
HasSkin
Does it add a dye or material skin
HasBadge
Does the player get a badge
MapType
This one is different from the rest, It explains how many time peices are in the map and what kind of map it is (Purple rift, Blue rift, Multi time peice level)

If a tag is = 0 then that means that it doesnt have that tag, if it is one then that means that the tag is true.

These tags are auto set so there is no need to edit them.

Configs

Configs can do a variety of things but they require user input.
Here is an example of one from my playable conductor mod,

[Configs]
THIS IS ONLY NEEDED ONCE The [] (Square Brackets)Simply imply that the user is defining a config here
+Config=playerSet(Playerset can be anything, Just make sure you define it correctly later)
(This is important, I’ll explain later on)
Name=”Costume Switch”
(This is the name that appears in the mod config in the game)
Description=”Toggle between Conductor Costume and in-game costumes!”
(Description of the Config)
Default=0
(What it sets the config to when nothing is selected, this can be a tad bit buggy, I’ll try to go into more detail it a later update)
Option[0]=”Hat Kid Clothes”
v—– These refer to the name of the options. There can be as many as you need
Option[1]=”Conductor Clothes”
<—/

So now you have the config set up here, but its not doing anything!
You need to define this variable again in the mod file,

Making the Config do something

This is Somewhat complex, so i will be using Playable Conductor as an example,

So before we added,

+Config=playerSet

This in itself does nothing
We need to define the variable in the GameMod class
Note: If you want to change the name to something other than playerSet go ahead just make sure to edit that in the rest of your code, being consistant is key!

Make sure to have

Config(Mods);

under the Gamemod or else nothng will work!

So make sure this gets changed we want to make a new event in our GameMod Class

This says that when something is changed, update this file,
We need an initial

If(ConfigName == ‘playerSet’){ }

Be sure to keep capitalization consistant
This checks to make sure its updating the correct config and nothing else
inside of that because we allready defined our variable,
We can use that to check the configuration, so we need 2 or more if statements here

I only had 2 Configuration statements so Mine is somewhat small.

You can do this for as many configs you need, just make sure you have that many in your ini file.

So a final product should(or could) look something like,

If(ConfigName == ‘playerSet’){ if(playerSet == 0){ /*(Example)*/ Hat_PlayerController(GetALocalPlayerController()).GetLoadout().AddBackpack(class’Hat_Loadout’.static.MakeLoadoutItem(class’Hat_Ability_Help’), false); //adds the class item } else if(playerSet == 1){ /*(Example)*/ Hat_PlayerController(GetALocalPlayerController()).GetLoadout().RemoveBackpack(class’Hat_Loadout’.static.MakeLoadoutItem(class’Hat_Ability_Help’, class’Hat_CosmeticItemQualityInfo_SearchAny’)); //removes the class item } }

This would Give you the help hat if config is = to 0, and remove it if its = to 1

Big thanks and links to other Modding guides

If theres anything i forgot to add Please tell me in the comments and I will add it as quick as possible, And give you credit!

Other modding guides: Credit to the respective owners (Weegee, and Heavy)
[link]
[link]
[link]
[link]
[link]

SteamSolo.com