SOLVED weird string error

EvanSki

King of Raccoons
its either an issue with the global.charsave or an issue with GMS2 being sandbox
if its with the global its probably not getting the correct value

if its with gms2 being sandboxed it doesnt know the location of the file to open

i use this to store the location of ini files
GML:
//find global.game_directory
ini_open("Path.get")
ini_write_real("a","b",0);
ini_close();
global.game_directory = (string(filename_path("Path.get")));

if file_exists((global.game_directory)+"Path.get")
{
    file_delete(string(global.game_directory)+"Path.get")
}
//show_message(global.game_directory);
I then use global.game_directory to get the file path to tell GMS2 where the file is located on the host machine
 

zendraw

Member
it worked fine before i added everything under the with (o_playerstart), basicly the dialogue global vars. really bizzare, and i didnt change anything around the global charsave
 

EvanSki

King of Raccoons
Oh youre not closing the ini file before you destroy the object, it might thing its still open in another process when you call it again
 

zendraw

Member
this is the code in the string, it is closed unless i dont get what you mean. i changed the global.charsave to a makro mk_savechar and it works the same when i comment out the dialogue code
GML:
    ini_open(mk_savechar);
   
    with (o_playerstart)
    {
        var xt=ini_read_real("WRD", "x", x);
        var yt=ini_read_real("WRD", "y", y);
        instance_create_depth(xt, yt, -yt, o_player);
        instance_destroy();
    }
   
    var rn=room_get_name(room);
    global.dialogueslot=scr_getdialoguelist(room);
   
    for (var i=0; i<array_length_1d(global.dialogueslot); i++)
    {
        global.dialogueslot[i]=ini_read_string("DLG", string(rn)+string(i), "");
    }

    var k=0;
    with (par_dialogue)
    {
        k=0;
        for (var i=0; i<array_length_1d(global.dialogueslot); i++)
        {
            if (dialogue==global.dialogueslot[i])
            {
                k=1;
                break;
            }
        }
        if (!k) {instance_destroy()};
    }
    ini_close();
 

EvanSki

King of Raccoons
GML:
 with (o_playerstart)
    {
        var xt=ini_read_real("WRD", "x", x);
        var yt=ini_read_real("WRD", "y", y);
        instance_create_depth(xt, yt, -yt, o_player);
        instance_destroy();
    }
add a ini_close(); before you destroy the object
 

zendraw

Member
weird, now there is no error.
GML:
    ini_open(mk_savechar);
    
    with (o_playerstart)
    {
        var xt=ini_read_real("WRD", "x", x);
        var yt=ini_read_real("WRD", "y", y);
        instance_create_depth(xt, yt, -yt, o_player);
        instance_destroy();
    }
    
    ini_close();
    
    ini_open(mk_savechar);
    var rn=room_get_name(room);
    global.dialogueslot=scr_getdialoguelist(room);
    
    for (var i=0; i<array_length_1d(global.dialogueslot); i++)
    {
        global.dialogueslot[i]=ini_read_string("DLG", string(rn)+string(i), "");
    }
    
    var k=0;
    with (par_dialogue)
    {
        k=0;
        for (var i=0; i<array_length_1d(global.dialogueslot); i++)
        {
            if (dialogue==global.dialogueslot[i])
            {
                k=1;
                break;
            }
        }
        if (!k) {instance_destroy()};
    }
    
    ini_close();
 

EvanSki

King of Raccoons
it sees that o_playerstart is looking in the file
then you destroyed it
but the ini file is still open

then in another object
then you call to open it again and read from it from it
 
Top