Legacy GM Q: Error message

Z

zendraw

Guest
so i recive this error when i load a script that generates a world throu ds_lists, i checked it with show_message but it simply shows the number of the object and i cant figure out whats the issue

FATAL ERROR in
action number 1
of Mouse Event for Glob Left Pressed
for object o_editor:


instance_create argument 2 incorrect type (5) expecting a Number (YYGF)
at gml_Script_scr_world_load (line 23) - instance_create(o_xpos, o_ypos, o_obj);
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_scr_world_load (line 23)
called from - gml_Object_o_editor_GlobalLeftButtonPressed_1 (line 8) - script_execute(scr_world_save+i)
 
A

Aura

Guest
Please post the entire code. The error message is saying that you're passing a value of data type undefined to instance_create() when it expects a real value. This might be the result of a nonexistent list entry, so make sure that o_ypos isn't getting set to one.
 
Z

zendraw

Guest
yes, i tested all 3 vars and y is set to undefined for some reason, i also check when i save if it saves all values and it does, only when it loads it reads y_pos as undefined.

save code:
Code:
var grid=ds_grid_create(2, instance_count);

var s=0, o_obj, o_xpos, o_ypos;

for (var i=0; i<instance_count; i++)
{
    o_obj=instance_id[i].object_index;
    if (o_obj<o_controll)
    {
        o_xpos=instance_id[i].x;
        o_ypos=instance_id[i].y;
        
        ds_grid_set(grid, 0, i-s, o_obj);
        ds_grid_set(grid, 1, i-s, o_xpos);
        ds_grid_set(grid, 2, i-s, o_ypos);
        show_message('obj:'+string(o_obj)+'/xpos:'+string(o_xpos)+'/ypos:'+string(o_ypos));
    } else {s++};
}

var grid_s=ds_grid_write(grid);

ds_grid_destroy(grid);

if (file_exists('wor.sav')) {file_delete('wor.sav')};

ini_open('wor.sav');

ini_write_string('data', 'world', grid_s);

ini_close();
load code:
Code:
if (instance_count>0) {with (all) {if (object_index<o_controll) {instance_destroy()}}};

if (file_exists('wor.sav')) {ini_open('wor.sav')} else {exit};

grid_s=ini_read_string('data', 'world', 0);

ini_close();

var grid=ds_grid_create(2, 1);

ds_grid_read(grid, grid_s, false);

var imax, o_obj, o_xpos, o_ypos;

imax=ds_grid_height(grid);

for (var i=1; i<imax; i++)
{
    o_obj=ds_grid_get(grid, 0, i);
    o_xpos=ds_grid_get(grid, 1, i);
    o_ypos=ds_grid_get(grid, 2, i);
    show_message('obj:'+string(o_obj)+'/xpos:'+string(o_xpos)+'/ypos:'+string(o_ypos));
    instance_create(o_xpos, o_ypos, o_obj);
}

ds_grid_destroy(grid);
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Please post the entire code. The error message is saying that you're passing a value of data type undefined to instance_create() when it expects a real value. This might be the result of a nonexistent list entry, so make sure that o_ypos isn't getting set to one.
For a correction, type 5 is not "undefined", it's when the variable is not set at all (yet).
 
Top