GameMaker Ini file is not being read.

chasepeck

Member
Hello! This is my first post on GMC, and I need some help.

I am creating an RPG, and I want different enemies to have different music tracks. Since I will have quite a few enemies in my game, I decided to put the enemy data into a .ini file. One of the keys is the music asset name. What I tried to do was read the key, use asset_get_index, and play the music on loop, but it is not working. I used a debug message to check if the section Testman exists but for some reason it says that it doesn't. Am I doing something wrong?

I made an object that handles the audio:
Create Event:
Code:
if(room==rm_battle){
    ini_open(working_directory+"data_enemies.ini");
    show_debug_message(ini_section_exists("Testman"));
    audio_play_sound(asset_get_index(ini_read_string("Testman","music","snd_error")),0,true);
    ini_close();
}
The enemy file, data_enemies.ini:
Code:
;Test enemy
[Testman]
name=Testman
bgsprite=spr_bg_pinklines
bgeffect=1
bgspeed=0.1
bgwavelength=32
sprite=spr_enemy_InsecureGarlic
music=mus_bat_conventionalBattle
hp=100
sp=100
off=5
def=5
speed=5
react=5
crit=5
miss=5
The music key is the key I am trying to read.

This is my output:
Code:
**********************************.
Entering main loop.
**********************************.
Texture #3 2048,2048
Audio group 1 -> Loading...
Audio_WAVs()
Audio group 2 -> Loading...
Audio_WAVs()
Audio group 1 -> Loaded
Audio group 2 -> Loaded
0
The zero on the bottom line there is the debug message saying that it thinks the Testman section does not exist.



I apologize if I'm being stupid, I'm not the best with GameMaker.

Edit: btw, I am using IDE v2.2.5.481, and Runtime v2.2.5.378
 
Last edited:

ricardo1996

Member
i haven't parsed a ini file in ages, but is this header suppose to be there? ";Test enemy". Also as Nidoking mention try removing windows_directory from both ends writing and reading if you haven't done so. The doc does mention it may not work as intended.
 

chasepeck

Member
i haven't parsed a ini file in ages, but is this header suppose to be there? ";Test enemy". Also as Nidoking mention try removing windows_directory from both ends writing and reading if you haven't done so. The doc does mention it may not work as intended.
The semicolon is a comment I believe. You can use semicolons as comments in ini files. And yes, I have tried removing the working_directory. I suppose you're right, it may just not be working as it should. That's okay, there are alternatives to this method. Thanks :)
 
Top