Ich habe folgendes Problem:
Ich möchte ein Öffnen- und Speichermenu in mein Spiel ein bauen:

Ich habe dazu ein Quelltext:
zum Speichern:
{
var fileid,fname;
if (global.running) exit;
fname = get_save_filename(ztp files(*.ztp)|*.ztp','');<-ZTP = nur ein Beispiel
if (fname == '') exit;
fileid = file_text_open_write(fname);
file_text_write_real(fileid,instance_number(block_normal));
with (block_normal)
{
file_text_write_real(fileid,x);
file_text_write_real(fileid,y);
}
file_text_close(fileid);
io_clear();
}
und zum öffnen:
{
var fileid,fname,xxx,yyy;
if (global.running) exit;
fname = get_open_filename('ztp files(*.ztp)|*.ztp','');
if (fname == '') exit;
if (!file_exists(fname)) exit;
fileid = file_text_open_read(fname);
with (block_normal) instance_destroy();
nnn = file_text_read_real(fileid);
for (i=0; i<nnn; i+=1)
{
xxx = file_text_read_real(fileid);
yyy = file_text_read_real(fileid);
instance_create(round(xxx),round(yyy),block_normal);
}
file_text_close(fileid);
io_clear();
}
Doch wenn ich auf speichern oder öffnen klicke, kommt eine Fehlermeldung:
Error in code at line 3:
if (global.running) exit;
at position 15: unknown variable running
Kann mir da einer helfen?
Ich möchte ein Öffnen- und Speichermenu in mein Spiel ein bauen:

Ich habe dazu ein Quelltext:
zum Speichern:
{
var fileid,fname;
if (global.running) exit;
fname = get_save_filename(ztp files(*.ztp)|*.ztp','');<-ZTP = nur ein Beispiel
if (fname == '') exit;
fileid = file_text_open_write(fname);
file_text_write_real(fileid,instance_number(block_normal));
with (block_normal)
{
file_text_write_real(fileid,x);
file_text_write_real(fileid,y);
}
file_text_close(fileid);
io_clear();
}
und zum öffnen:
{
var fileid,fname,xxx,yyy;
if (global.running) exit;
fname = get_open_filename('ztp files(*.ztp)|*.ztp','');
if (fname == '') exit;
if (!file_exists(fname)) exit;
fileid = file_text_open_read(fname);
with (block_normal) instance_destroy();
nnn = file_text_read_real(fileid);
for (i=0; i<nnn; i+=1)
{
xxx = file_text_read_real(fileid);
yyy = file_text_read_real(fileid);
instance_create(round(xxx),round(yyy),block_normal);
}
file_text_close(fileid);
io_clear();
}
Doch wenn ich auf speichern oder öffnen klicke, kommt eine Fehlermeldung:
Error in code at line 3:
if (global.running) exit;
at position 15: unknown variable running
Kann mir da einer helfen?
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von Tobi ()