A
Anton Provid
Guest
Hi, i got the problem when loading game:
and here is the scrLoad():
Can someone help me with this?
Thank you in advance.
Code:
instance_create argument 2 incorrect type (undefined) expecting a Number (YYGF)
at gml_Script_scrLoad (line 17) - var Inst = instance_create(SaveGrid[# a, 1],SaveGrid[# a, 2],SaveGrid[# a, 0]); //Create Instance at X/Y
############################################################################################
Code:
///scrLoad();
ini_open('Save.ini'); //Open save ini
var InstNum = ini_read_real( 'Save', '0', 0); //Load number of instances
//Create grid
globalvar SaveGrid; //Create global variable for grid
SaveGrid = ds_grid_create(InstNum, 9); //Create grid as wide as building number
//Write saved grid to new grid
ds_grid_read(SaveGrid, ini_read_string('Save', '1', "")); //Populate grid with x/y/etc.
ini_close(); //Close ini
for(var a = 0; a <= InstNum; a ++){
var Inst = instance_create(SaveGrid[# a, 1],SaveGrid[# a, 2],SaveGrid[# a, 0]); //Create Instance at X/Y
Inst.Cost = SaveGrid[# a, 3]; //Building cost
Inst.Occupants = SaveGrid[# a, 4]; //Number of occupants
Inst.Name = SaveGrid[# a, 5]; //Little Human name variable
Inst.HP = SaveGrid[# a, 6]; //Little human hp
Inst.Money = SaveGrid[# a, 7]; //Little human money;
Inst.image_index = SaveGrid[# a, 8]; //House sprite;
Inst.Placed = 1; //Flag inst placed
Inst.depth = -y; //Set depth of inst
}
Thank you in advance.