• 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!

[Solved] Saving to an ini

E

Edeyz

Guest
I'm trying to save my data to an .ini but It gives me the error

___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Other Event: User Defined 0
for object obj_mapGenerationControllPartB:

ini_write_string argument 2 incorrect type (0) expecting a String (YYGS)
at gml_Script_scr_save (line 27) - ini_write_string(data[0,0], 0, data[0,0]);
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_scr_save (line 27)
called from - gml_Object_obj_mapGenerationControllPartB_UserEvent0_1 (line 30) - script_execute(scr_save);



"name" is something like "TN9q18J8818N"

Here is my code:

//Saves the game
var data
//Sets up data
with(obj_mapStar)
{
//For star
data[0,0] = name;
data[0,1] = x;
data[0,2] = y;
data[0,3] = colour;
data[0,4] = starSize;
data[0,5] = starsInSystem;
data[0,6] = factionControlling;
data[0,7] = planetsInSystem;
//For planets
for (i = 1; i <= planetsInSystem; i++)
{
data[i,0] = plantets[i,0];
data[i,1] = plantets[i,1];
data[i,2] = plantets[i,2];
data[i,3] = plantets[i,3];
}

//Writes the save file
show_message(string(data[0,0]));
ini_open(global.saveFileName);
ini_write_string(data[0,0], 0, data[0,0]); <<<<<<< trouble
ini_write_real(data[0,0], 1, data[0,1]);
ini_write_real(data[0,0], 2, data[0,2]);
ini_write_string(data[0,0], 3, data[0,3]);
ini_write_real(data[0,0], 4, data[0,4]);
ini_write_real(data[0,0], 5, data[0,5]);
ini_write_real(data[0,0], 6, data[0,6]);
ini_write_real(data[0,0], 7, data[0,7]);

for (i = 1; i <= planetsInSystem; i++)
{
ini_write_real(data[0,0], 0, data[i,0]);
ini_write_real(data[0,0], 1, data[i,1]);
ini_write_real(data[0,0], 2, data[i,2]);
ini_write_real(data[0,0], 3, data[i,3]);
}
}
ini_close();

I cant work out why its doing this as name (and thus data[0,0]) is a string.

Thank you for your help
Edeyz
 

obscene

Member
name is apparently not a string. Maybe you need to use object_get_name(name) to covert that to a string? or you can use ini_write_real if you need the index instead of the string name.
 
E

Edeyz

Guest
Sorry I just solved it, It was the the second argument, (like it says in the error) so now it's:
ini_write_string(data[0,0], "0", data[0,0]);

I feel a bit stupid now.
Thanks for your help anyway
 

obscene

Member
Sorry I just solved it, It was the the second argument, (like it says in the error) so now it's:
ini_write_string(data[0,0], "0", data[0,0]);

I feel a bit stupid now.
Thanks for your help anyway
I'm on 3 hours sleep lol best to ignore me today. I missed that by a mile.
 
Top