• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM [SOLVED]Strange INI error

Z

zendraw

Guest
so for some reason it gives me this error
Code:
___________________________________________
############################################################################################
ERROR in
action number 2
of Key Press Event for F6 Key
for object o_ctrl:

Trying to read from undefined INI file
 at gml_Script_scr_loadmap (line 42) -             j.sprite_index=ini_read_real('i', 's'+string(i), 0);
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_scr_loadmap (line 42)
called from - gml_Object_o_ctrl_KeyPressed_F6_2 (line 1) - scr_loadmap();
i checked when it closes the ini file and it closes it after everything is done. i have no idea why its doing this.
it does this only for loading instances, otherwise it loads the grid just fine.
 
Z

zendraw

Guest
Code:
    i=0;
    repeat (1000)
    {
        oo=ini_read_real('i', 'o'+string(i), 0);
        if (oo)
        {
            xx=ini_read_real('i', 'x'+string(i), 0);
            yy=ini_read_real('i', 'y'+string(i), 0);
            j=instance_create(xx, yy, oo);
            j.sprite_index=ini_read_real('i', 's'+string(i), 0);
        }
        i++;
    }
 
Z

zendraw

Guest
yes, before this code it loads a grid, and it loads it fine, only this part where it loads instances causes this error for some reason.
 
M

Monsi

Guest
Code:
Trying to read from undefined INI file
The first place I'd look is what you're putting in ini_open(). I've never seen this error before, but it suggests the parameter you're using is <undefined>

Perhaps putting
Code:
show_debug_message(file);
before will shed some light.
 
Z

zendraw

Guest
well it simply returns the name of the file in the compiler -> ELENAXena.sav

btw this is how it saves the instances, culd the issue come from there?

Code:
var j=0;
i=0;
repeat (instance_count)
{
    j=instance_id[i];
    
    if (j.object_index<o_ctrl)
    {
        ini_write_real('i', 'o'+string(i), j.object_index);
        ini_write_real('i', 's'+string(i), j.sprite_index);
        ini_write_real('i', 'x'+string(i), j.xstart);
        ini_write_real('i', 'y'+string(i), j.ystart);
    }
    
    i++;
}
 
I notice in your repeat loop you are calling instance_create().

Does the instance you are creating also open and close an ini file? Because you can only have one ini file open at a time. This would cause conflicts with the ini file you are reading in the repeat loop.

I did a very quick search for the error message and found someone else had the same problem here: Undefined ini file

You would have to close and re-open the ini file inside the loop each time you read to solve this problem if you are also reading an ini file from inside of the instance you are creating.
 
Z

zendraw

Guest
oooh, well that makes sense, yes in the player create event theres an ini open/close. i will look it up later on, but im pretty sure this wuld be the issue. thanks

Edit: yup that totaly nailed it!
 
Last edited:
Top