Hey guys, I wrote a small tutorial to help some people that might have had the some question as me about getting data from an external file.
Go to the blueprint in which you want the variable to be located (In this example it would be the Ankylo character blueprint)
Declare a variable that you want to get the information for from the initiation file. You can only get booleans, floats and integers from an initiation file. (In this example I have a float variable named
“AnkyloGrowTime”)
In this part we will set up the graph. First right-click and add a “SwitchHasAuthority” node (I have an “EventBeginPlay” event plugged into the node.)
Then you want to “right-click” and add a “GetGameMode” node.
From there pull off the game mode reference and cast it to “ShooterGameMode”.
Then plug the execution pin from the “Authority” section of the “SwitchHasAuthority” to the “CastToShooterGameMode” node. (The “Authority” option tells the game to get/send data from the server side and the “Remote” option would get/send data from the client side.
Next you would right-click and add a “GetOptionIni” node. (Either a “GetBoolOptionIni”, “GetFloatOptionIni” or “GetIntOptionIni”. In this example I will use a “GetFloatOptionIni” node).
In the “GetOptionIni” node you will now fill out the “Section” area with the name of the section you want your variable to be under in the ini file. Then you will fill out the “OptionName” area in the same node to assign a name that will appear to represent your variable in the ini file (For this example I have the “Section” set to “BabyDinosGrowTime” and the “OptionName” to AnkyloGrowTime.
After the “GetOptionIni” node you will now have to set your variable with the information from the ini file. To do this you can drag your variable into the graph and select set. Then plug in the execution pin and the return value pin into the set node.
Now you will have to go to the “GameUserSettings.ini” file which is located at this directory: Epic Games\ARKDevKit\Projects\ShooterGame\Saved\Config\Windows
From there open the “GameUserSetting.ini” file and scroll to the bottom. Now you will type in the information you put in the node in the graph. So first type [Section] (replace Section with the name you set). Then hit enter and type OptionName=0 (replace OptionName with the name you set in the node and replace the 0 with whatever value you want. Once done save the file.
Now if you have your editor still open close the editor and reopen it to reinitialize the initiation file. PLEASE NOTE WHEN YOU CHANGE VALUES IN THE INI FILE YOU HAVE TO RESTART THE EDITOR FOR THEM TO TAKE EFFECT. This is because the initiation file is only read on start up.
Also I found out that if there is nothing in the ini file it will set the variable to 0. So I set up a branch to check to see if there was a value in the ini file if not it used the default value I set in the variable.
Quick question: after I have the variable set how do I assign it to a blueprints value?
I.E. assign the ankylo grow time to the actual value that is the ankylo’s grow timer?
ah ok… my goal is to make items price change based on variables in the ini cause I’m making a “shop” and want the server host to be able to set his economy
I’m still needing help with this can anyone tell me how to pull a variable from ini and assign it to a value (ie base resource requirement) of a blueprint?
Creative, how exactly did you get it to check the ini file first? I’ve never done anything like this before, and your tutorial was incredibly helpful, but I don’t know how to figure out how to do that bit.
I’ve been using it it’s under events and it’s visual scripting you can read from the gameusersettings.ini file the way he said only for it to actually work I had to use a delay after event begin play. you just can’t do it from certain blueprints. I used it on a shop so that it would read from the file and set the sell prices
So in order to stop it setting stuff to “0” if there is no value in the INI file, i need to set a delay-- to I set that on the “cast to shootergame” or “flotoptionini” bit?
no the delay comes after “begin play” otherwise it doesn’t seem to execute… just a .2 sec is all it needs if you read from the ini and put nothing in it … the value returned is 0 and you deal with that the way you want. the floatoptionini part pulls 0 if the item isn’t in the ini file