Legacy GM Importing Files Error

Hello everybody!
I'm making a game right now that has the ability to import level saves (because it has a level editor) and its working really well, but when I import the save it imports like this: "levelname.711.711" which I know why but I cant fix it for some reason, so here is my code, maybe you can help me. Thanks! =)

Import code:
Code:
tempfile = get_open_filename("711 file|*.711", "");
if tempfile != ""
   {
   name = string_copy(filename_name(tempfile),1,string_width(filename_name(tempfile))-4)
   newfile = working_directory+"\Saves\"+name+".711"
   file_copy(tempfile,newfile)
   sc_save_levels()
   room_goto(r_menu)
   room_goto(r_cm_choose)
   }
Save Code:
Code:
ini_open("LEVELS.SAVE")
levels += 1
ini_write_real("totals","levels",levels)
ini_write_string("lID",""+string(levels),""+string(name))
ini_close()
I've tried many other methods of changing the save name, but no matter what I do the save name always comes out as:
"levelname.711"
and the save file always comes out as:
"levelname.711.711"
 
W

Wraithious

Guest
I think you need to change string_width to string_length so you'd have:
Code:
tempfile = get_open_filename("711 file|*.711", "");
if tempfile != ""
   {
   name = string_copy(filename_name(tempfile),1,string_length(filename_name(tempfile))-4)
   newfile = working_directory+"\Saves\"+name+".711"
   file_copy(tempfile,newfile)
   sc_save_levels()
   room_goto(r_menu)
   room_goto(r_cm_choose)
   }
Save Code:
 
I think you need to change string_width to string_length so you'd have:
Code:
tempfile = get_open_filename("711 file|*.711", "");
if tempfile != ""
   {
   name = string_copy(filename_name(tempfile),1,string_length(filename_name(tempfile))-4)
   newfile = working_directory+"\Saves\"+name+".711"
   file_copy(tempfile,newfile)
   sc_save_levels()
   room_goto(r_menu)
   room_goto(r_cm_choose)
   }
Save Code:
This worked perfect! Thanks!
 
Top