bordemstirs
Member
I have a file that is checked quite a few times a day, that never has anything removed from it, but has 2 elements added every day.
File type is int[string] and it's usually fine, but for some reason random elements will fail to load when nothing else has changed.
Usually it's just one element a day. Today I noticed that there were quite a few errors, and a rather generous debug log had formed itself.
I'm not really sure what is going wrong, any help would be appreciated.
Below, only two pieces of code that modify the file:
File type is int[string] and it's usually fine, but for some reason random elements will fail to load when nothing else has changed.
Usually it's just one element a day. Today I noticed that there were quite a few errors, and a rather generous debug log had formed itself.
I'm not really sure what is going wrong, any help would be appreciated.
Below, only two pieces of code that modify the file:
Code:
void checkLotto(){
int[string] books;
file_to_map("books.txt",books);
int event=0;
int time=minutesToRollover();
if (time<books["Event1"]) event=1;
if (time<books["Event2"]) event=2;
if (time<books["Event3"]) event=3;
if (event<1) return;
books["Event"+event.to_string()]=0;
books["nextLotto"]+=1;
books["thisLotto"]+=5;
boolean[string] inClan=who_clan();
remove inClan["Ominous Buffer"];
remove inClan["MesaChat"];
string[int] clannies;
foreach name in inClan clannies[count(clannies)]=name;
int num=count(clannies);
if (num<1){
map_to_file(books,"books.txt");
return;
}
float perc=1+(num/5)*0.4;
int d=ceil((100/perc)*num);
print("Event @ "+now_to_string("HH:mm")+" for "+books["thisLotto"].to_string());
print(num.to_string()+"players: Rolling D"+d.to_string());
chat_clan("Time for the Lotto! Right now it's for "+books["thisLotto"].to_string()+",000 meat! We have "+num.to_string()+(num!=1?" players":" player")+" now (d"+d.to_string()+"). Good luck!");
d=random(d);
print("Rolled: "+d.to_string());
waitq(20);
chat_clan("/em rolls a "+to_string(d+1)+".");
waitq(7);
if (d<num){
print("Winner:"+clannies[d]);
chat_clan("A winner!");
waitq(7);
file_to_map("userdata.txt",userdata);
for i from 5 downto 2 userdata["*"].buffpacks["winner"+i.to_string()]=userdata["*"].buffpacks["winner"+to_string(i-1)];
userdata["*"].buffpacks["winner1"]=clannies[d]+": "+books["thisLotto"].to_string()+",000";
string buf="account.php?action=Update&tab=profile&pwd="+my_hash()+"&actions[]=quote"e=Black Mesa Buffbot.";
buf+="\n\nCheck DC for casts remaining of limited use skills.\n\nLast Five Lotto Winners:";
for i from 1 to 5 if (userdata["*"].buffpacks["winner"+i.to_string()]!="") buf+="\n"+userdata["*"].buffpacks["winner"+i.to_string()];
visit_url(buf);
chat_clan(clannies[d]+" wins the lotto and takes home "+books["thisLotto"].to_string()+",000 meat! See you again soon!");
sendMeat(clannies[d],books["thisLotto"]);
books["thisLotto"]=books["nextLotto"]-1;
books["nextLotto"]=1;
}else{
print("No winner.");
chat_clan("Sorry, folks, no winners today. Better luck next time. See you again soon!");
}
map_to_file(books,"books.txt");
}
Code:
void handleMeat(){
cli_execute("use 0 warm subject gift certificate");
cli_execute("autosell 0 thin black candle, 0 heavy d, 0 original g, 0 disturbing fanfic, 0 furry fur, 0 awful poetry journal, 0 chaos butterfly, 0 plot hole, 0 probability potion, 0 procrastination potion, 0 angry farmer candy, 0 mick's icyvapohotness rub");
int tw=item_amount($item[twinkly wad]);
cli_execute("csend 0 wolf mask, 0 rave whistle, 0 giant needle, 0 twinkly nugget to smashbot || wads");
int totalDMS=floor(my_meat()/1000)-500;
if (totalDMS>0){
string exe="make "+to_string(totalDMS)+" dense meat stack";
cli_execute(exe);
cli_execute("/closet "+totalDMS.to_string()+" dense meat stack");
// put_closet(totalDMS,$item[dense meat stack]);
}
int[string] books;
file_to_map("books.txt",books);
books["Meat"+now_to_string("yDDD")]=totalDMS-18;
books["Wads"+now_to_string("yDDD")]=tw;
int eventTimeCap=minutesToRollover();
int event1=random(eventTimeCap-45)+35;
int event2=random(eventTimeCap-45)+35;
int event3=random(eventTimeCap-45)+35;
while ((event2-event1<60)&&(event1-event2<60))event2=random(eventTimeCap-45)+35;
while (((event3-event1<60)&&(event1-event3<60))||((event3-event2<60)&&(event2-event3<60)))event3=random(eventTimeCap-45)+35;
books["Event1"]=event1;
books["Event2"]=event2;
books["Event3"]=event3;
map_to_file(books,"books.txt");
}