Jump to content
Doom989

So I wrote this script..

Recommended Posts

Hello everyone.

I've wrote this here script to detect when I type, for example, 'rtd 1d4' it then rolls one 4 sided die then outputs the result. Probably doesn't look like it, but I put a lot of work into this lol.

I come to you to ask for suggestions.

Is there a shorter way to achieve this? Thanks :)

 

 var
x,y,i,b,v,f,g, //Integers
custom,       //Customized roll
RD,        //rtd 1d
RD2D,        //rtd 2d
D2,D3,D4,D5,D6,D7,D8,D9,
DD2,DD3,DD4,DD5,DD6,DD7,DD8,DD9 :integer; 


procedure Setup;
begin
custom := TSCARBitmap.Create('');  

RD := TSCARBitmap.Create(''); 

D2 := TSCARBitmap.Create('');    
D3 := TSCARBitmap.Create('');    
D4 := TSCARBitmap.Create('');    
D5 := TSCARBitmap.Create(''); 
D6 := TSCARBitmap.Create('');
D7 := TSCARBitmap.Create('');  
D8 := TSCARBitmap.Create('');   
D9 := TSCARBitmap.Create(''); 

RD2D := TSCARBitmap.Create('');

DD2 := TSCARBitmap.Create('');    
DD3 := TSCARBitmap.Create('');    
DD4 := TSCARBitmap.Create('');    
DD5 := TSCARBitmap.Create(''); 
DD6 := TSCARBitmap.Create('');
DD7 := TSCARBitmap.Create('');  
DD8 := TSCARBitmap.Create('');   
DD9 := TSCARBitmap.Create('');      
end;


procedure Customs;    
begin
if FindBitmap(x,y,custom,68,238,359,271) then    
begin  
 WriteLn('We rollin');
 wait(300);
 i := 1+Random(10);      
 b := 1+Random(10); 
 v := 1+Random(10);
 f := 1+Random(10); 
 g := 1+Random(10);  
 typetextEx('Roll 5d10 Result: '+inttostr(i),True,False);  
 typetextEx('+ '+inttostr(b),True,False); 
 typetextEx('+ '+inttostr(v),True,False); 
 typetextEx('+ '+inttostr(f),True,False); 
 typetextEx('+ '+inttostr(g),True,False); 
 typetextEx('  = '+inttostr(i+b+v+f+g),True,False); 
 PressVKey(VK_RETURN);
 wait(3000);
end;                                                    
end;


procedure Singles;     
begin
if FindBitmap(x,y,RD,68,238,359,271) then      
begin  
 if FindBitmap(x,y,D2,68,238,359,271) then   
  begin
   WriteLn('We rollin');
   wait(300);
   i := 1+Random(2);
   typetextEx('Roll 1d2 Result: '+inttostr(i),True,False);
   PressVKey(VK_RETURN); 
   wait(3000);    
  end;    

 if FindBitmap(x,y,D3,68,238,359,271) then
  begin
   WriteLn('We rollin');
   wait(300);
   i := 1+Random(3);
   typetextEx('Roll 1d3 Result: '+inttostr(i),True,False);
   PressVKey(VK_RETURN);
   wait(3000);     
  end;   

 if FindBitmap(x,y,D4,68,238,359,271) then
  begin
  WriteLn('We rollin');
  wait(300);
  i := 1+Random(4);
  typetextEx('Roll 1d4 Result: '+inttostr(i),True,False);
  PressVKey(VK_RETURN);
  wait(3000);    
  end;        

 if FindBitmap(x,y,D5,68,238,359,271) then
  begin
   WriteLn('We rollin');
   wait(300);
   i := 1+Random(5);
   typetextEx('Roll 1d5 Result: '+inttostr(i),True,False);
   PressVKey(VK_RETURN); 
   wait(3000); 
  end;      

 if FindBitmap(x,y,D6,68,238,359,271) then
  begin
   WriteLn('We rollin');
   wait(300);
   i := 1+Random(6);
   typetextEx('Roll 1d6 Result: '+inttostr(i),True,False);        
   PressVKey(VK_RETURN); 
   wait(3000);        
  end;     

 if FindBitmap(x,y,D7,68,238,359,271) then
  begin
   WriteLn('We rollin');
   wait(300);
   i := 1+Random(7);
   typetextEx('Roll 1d7 Result: '+inttostr(i),True,False);
   PressVKey(VK_RETURN); 
   wait(3000);    
  end;     

 if FindBitmap(x,y,D8,68,238,359,271) then
  begin
   WriteLn('We rollin');
   wait(300);
   i := 1+Random(8);
   typetextEx('Roll 1d8 Result: '+inttostr(i),True,False);
   PressVKey(VK_RETURN); 
   wait(3000);        
  end;    

 if FindBitmap(x,y,D9,68,238,359,271) then
  begin
   WriteLn('We rollin');
   wait(300);
   i := 1+Random(9);
   typetextEx('Roll 1d9 Result: '+inttostr(i),True,False);
   PressVKey(VK_RETURN); 
   wait(3000);       
  end;
end;        
end;

procedure Doubles;
begin
if FindBitmap(x,y,RD2D,68,238,359,271) then      
begin  
 if FindBitmap(x,y,DD2,68,238,359,271) then    
  begin
   WriteLn('We rollin');
   wait(300);
   i := 1+Random(2);
   b := 1+Random(2);
   typetextEx('Roll 2d2 Result: '+inttostr(i),True,False);
   typetextEx(' + '+inttostr(b),True,False); 
   typetextEx(' = '+inttostr(b+i),True,False);
   PressVKey(VK_RETURN); 
   wait(300);     
  end;           

 if FindBitmap(x,y,DD3,68,238,359,271) then    
  begin
   WriteLn('We rollin');
   wait(300);
   i := 1+Random(3);
   b := 1+Random(3);
   typetextEx('Roll 2d3 Result: '+inttostr(i),True,False);
   typetextEx(' + '+inttostr(b),True,False); 
   typetextEx(' = '+inttostr(b+i),True,False);
   PressVKey(VK_RETURN); 
   wait(300);     
  end;     

 if FindBitmap(x,y,DD4,68,238,359,271) then   
  begin
  WriteLn('We rollin');
  wait(300);
   i := 1+Random(4);
   b := 1+Random(4);
   typetextEx('Roll 2d4 Result: '+inttostr(i),True,False);
   typetextEx(' + '+inttostr(b),True,False); 
   typetextEx(' = '+inttostr(b+i),True,False);
   PressVKey(VK_RETURN); 
   wait(300);     
  end;      

 if FindBitmap(x,y,DD5,68,238,359,271) then    
  begin
   WriteLn('We rollin');
   wait(300);
   i := 1+Random(5);
   b := 1+Random(5);
   typetextEx('Roll 2d5 Result: '+inttostr(i),True,False);
   typetextEx(' + '+inttostr(b),True,False); 
   typetextEx(' = '+inttostr(b+i),True,False);
   PressVKey(VK_RETURN); 
   wait(300);     
  end;      

 if FindBitmap(x,y,DD6,68,238,359,271) then    
  begin
   WriteLn('We rollin');
   wait(300);
   i := 1+Random(6);
   b := 1+Random(6);
   typetextEx('Roll 2d6 Result: '+inttostr(i),True,False);
   typetextEx(' + '+inttostr(b),True,False); 
   typetextEx(' = '+inttostr(b+i),True,False);
   PressVKey(VK_RETURN); 
   wait(300);     
  end;      

 if FindBitmap(x,y,DD7,68,238,359,271) then    
  begin
   WriteLn('We rollin');
   wait(300);
   i := 1+Random(7);
   b := 1+Random(7);
   typetextEx('Roll 2d7 Result: '+inttostr(i),True,False);
   typetextEx(' + '+inttostr(b),True,False); 
   typetextEx(' = '+inttostr(b+i),True,False);
   PressVKey(VK_RETURN); 
   wait(300);     
  end;        

 if FindBitmap(x,y,DD8,68,238,359,271) then    
  begin
   WriteLn('We rollin');
   wait(300);
   i := 1+Random(8);
   b := 1+Random(8);
   typetextEx('Roll 2d8 Result: '+inttostr(i),True,False);
   typetextEx(' + '+inttostr(b),True,False); 
   typetextEx(' = '+inttostr(b+i),True,False);
   PressVKey(VK_RETURN); 
   wait(300);     
  end;     

 if FindBitmap(x,y,DD9,68,238,359,271) then    
  begin
   WriteLn('We rollin');
   wait(300);
   i := 1+Random(9);
   b := 1+Random(9);
   typetextEx('Roll 2d9 Result: '+inttostr(i),True,False);
   typetextEx(' + '+inttostr(b),True,False); 
   typetextEx(' = '+inttostr(b+i),True,False);
   PressVKey(VK_RETURN); 
   wait(300);     
  end;       
end;
end;


begin
Setup; 
Wait(1000);
repeat  
 wait(200);
 Doubles; 
 wait(200);
 Singles; 
 wait(200);
 Customs;       
until false;
end.

Edited by Doom989
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...