Fangames > Programming Questions

Weird DeathTime Error

(1/1)

RandomFangamer:
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)var f,i,tem;
f = file_bin_open("DeathTime",1);
for(i = 1; i <= 3; i += 1){
 
  tem = global.death;
  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;
  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;
  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);


LoadDeathTime:
(click to show/hide)
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);
    file_bin_write_byte(f,global.death);
    file_bin_write_byte(f,global.death);
    file_bin_write_byte(f,global.death);
   
    file_bin_write_byte(f,global.time);
    file_bin_write_byte(f,global.time);
    file_bin_write_byte(f,global.time);
    file_bin_write_byte(f,global.time);
   
    file_bin_write_byte(f,global.microtime);
    file_bin_write_byte(f,global.microtime);
    file_bin_write_byte(f,global.microtime);
    file_bin_write_byte(f,global.microtime);
  }
  file_bin_close(f);
}else{
  f = file_bin_open("DeathTime",0);
  for(i = 1; i <= 3; i += 1){
   
    global.death = file_bin_read_byte(f)*1000000;
    global.death += file_bin_read_byte(f)*10000;
    global.death += file_bin_read_byte(f)*100;
    global.death += file_bin_read_byte(f);
   
    global.time = file_bin_read_byte(f)*1000000;
    global.time += file_bin_read_byte(f)*10000;
    global.time += file_bin_read_byte(f)*100;
    global.time += file_bin_read_byte(f);
   
    global.microtime = file_bin_read_byte(f)*1000000;
    global.microtime += file_bin_read_byte(f)*10000;
    global.microtime += file_bin_read_byte(f)*100;
    global.microtime += 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);
}

WetWookie:
It looks like the array indexing got removed from both.
Try these


--- Code: ---//�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);

--- End code ---


--- Code: ---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);
}

--- End code ---

Navigation

[0] Message Index

Go to full version