.ini not saving index to variable

F

#Frogglets ;-;

Guest
hello,
What i'm trying to do (which is pretty self explanatory) is have a number save to a variable. It'll save all up until you reopen the game, which isn't very good. I've looked at all instances of the variable and none of which set the variable from one to zero again. My ini code is:
game start:

ini_open("saveData.ini")
global.stonebuy = ini_write_real("Variables","stonebuy",global.stonebuy);
ini_close();

game end:

ini_open("saveData.ini")
ini_write_real("Variables","stonebuy",global.stonebuy);
ini_close();

all instances:

oSaveExit-Step at line 24: ini_write_real("Variables","stonebuy",global.stonebuy);
oMoney-Create at line 5: global.stonebuy = 0;
oMoney-Game Start at line 18: global.stonebuy = ini_write_real("Variables","stonebuy",global.stonebuy);
oMoney-Game Start at line 18: global.stonebuy = ini_write_real("Variables","stonebuy",global.stonebuy);
oMoney-Game End at line 18: ini_write_real("Variables","stonebuy",global.stonebuy);
oMines-Create at line 5: if global.stonebuy = 1
oMines-Create at line 9: if global.stonebuy = 0
oStoneBuy-Step at line 4: global.stonebuy = 1;
oDbug-Draw at line 1: draw_text(10,10,string(global.stonebuy));

It definitely isn't the create code as I even set that to 5 for a try but it'll still reset to 0.
any help is greatly appreciated,
thanks in advance
 
F

#Frogglets ;-;

Guest
ever have one of those days? Literally just found out I forgot to replace write with read for the upon game start. Well, I goofed.
 
ini_write_real does not return any value.
If you want to read a value from an .ini file you have to use the ini_read_real() function.

Code:
// Load data
ini_open("saveData.ini");
global.stonebuy = ini_read_real("Variables", "stonebuy", 0);
ini_close();
Otherwise, if you want to store a value in the .ini file, you have to use ini_write_real() function.
Code:
// Save data
ini_open("saveData.ini");
ini_write_real("Variables", "stonebuy", global.stonebuy);
ini_close();
 
Top