I Wanna Community

Fangames => Game Design => Programming Questions => Topic started by: RandomFangamer on June 27, 2015, 03:17:36 PM

Title: Weird DeathTime Error
Post by: RandomFangamer on June 27, 2015, 03:17:36 PM
Hello
I am working on a game using the lemon engine, but for some reason whenever it is played it always works the first time then breaks the second.YoSniper discovered that the problem was with the DeathTime file, but I can't find anything wrong with it. If someone could help me with this error, I would really appreciate it. :IceFairy:

SaveDeathTime:
Note: R) = R ) (noSpace)
(click to show/hide)


LoadDeathTime:
(click to show/hide)

Title: Re: Weird DeathTime Error
Post by: WetWookie on June 27, 2015, 03:59:58 PM
It looks like the array indexing got removed from both.
Try these

Code: [Select]
//�o�C�i���`���Ž��S�”‚Œo�Ž��‚�‘�
var f,i,tem;
f = file_bin_open("DeathTime",1);
for(i = 1; i <= 3; i += 1){
 
  tem = global.death[i];
  file_bin_write_byte(f,floor(tem/1000000));
  tem -= floor(tem/1000000)*1000000;
  file_bin_write_byte(f,floor(tem/10000));
  tem -= floor(tem/10000)*10000;
  file_bin_write_byte(f,floor(tem/100));
  tem -= floor(tem/100)*100;
  file_bin_write_byte(f,tem);
 
  tem = global.time[i];
  file_bin_write_byte(f,floor(tem/1000000));
  tem -= floor(tem/1000000)*1000000;
  file_bin_write_byte(f,floor(tem/10000));
  tem -= floor(tem/10000)*10000;
  file_bin_write_byte(f,floor(tem/100));
  tem -= floor(tem/100)*100;
  file_bin_write_byte(f,tem);
 
  tem = global.microtime[i];
  file_bin_write_byte(f,floor(tem/1000000));
  tem -= floor(tem/1000000)*1000000;
  file_bin_write_byte(f,floor(tem/10000));
  tem -= floor(tem/10000)*10000;
  file_bin_write_byte(f,floor(tem/100));
  tem -= floor(tem/100)*100;
  file_bin_write_byte(f,tem);
}
file_bin_write_byte(f,global.L);
file_bin_write_byte(f,global.R);
file_bin_write_byte(f,global.stopMusic);
file_bin_close(f);

Code: [Select]
var f,i;
if(file_exists("DeathTime") == false){
  f = file_bin_open("DeathTime",1);
  for(i = 1; i <= 3; i += 1){
   
    file_bin_write_byte(f,global.death[i]);
    file_bin_write_byte(f,global.death[i]);
    file_bin_write_byte(f,global.death[i]);
    file_bin_write_byte(f,global.death[i]);
   
    file_bin_write_byte(f,global.time[i]);
    file_bin_write_byte(f,global.time[i]);
    file_bin_write_byte(f,global.time[i]);
    file_bin_write_byte(f,global.time[i]);
   
    file_bin_write_byte(f,global.microtime[i]);
    file_bin_write_byte(f,global.microtime[i]);
    file_bin_write_byte(f,global.microtime[i]);
    file_bin_write_byte(f,global.microtime[i]);
  }
  file_bin_close(f);
}else{
  f = file_bin_open("DeathTime",0);
  for(i = 1; i <= 3; i += 1){
   
    global.death[i] = file_bin_read_byte(f)*1000000;
    global.death[i] += file_bin_read_byte(f)*10000;
    global.death[i] += file_bin_read_byte(f)*100;
    global.death[i] += file_bin_read_byte(f);
   
    global.time[i] = file_bin_read_byte(f)*1000000;
    global.time[i] += file_bin_read_byte(f)*10000;
    global.time[i] += file_bin_read_byte(f)*100;
    global.time[i] += file_bin_read_byte(f);
   
    global.microtime[i] = file_bin_read_byte(f)*1000000;
    global.microtime[i] += file_bin_read_byte(f)*10000;
    global.microtime[i] += file_bin_read_byte(f)*100;
    global.microtime[i] += file_bin_read_byte(f);
  }
global.L = file_bin_read_byte(f);
global.R = file_bin_read_byte(f);
global.music = file_bin_read_byte(f);
  file_bin_close(f);
}