Guest User

Untitled

a guest
Nov 24th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.65 KB | None | 0 0
  1. SCRIPT_NAME = "fn";
  2. SCRIPT_DESC = "Show item number in forge";
  3. // Sort the forge first
  4.  
  5.  
  6. String old_mat = "";
  7. String output = "";
  8. int x  = 1;
  9.  
  10. void enableCount()  {
  11.     clientGUI.doCommand("/trigenable fn_count_mat");
  12.  
  13.     old_mat = "";
  14.     x = 1;
  15. }
  16.  
  17. void disableCount() {
  18.     clientGUI.doCommand("/trigdisable fn_count_mat");
  19. }
  20.  
  21. void count()    {
  22.  
  23. output = "";
  24.  
  25. String space = vars.get(3);
  26.  
  27. int[] arr = {1,4};
  28.  
  29. for(int y: arr ){
  30.     String s = vars.get(y);
  31.     if ( s != null ) {
  32.         if ( old_mat.equals("") || !s.equals(old_mat) ) {
  33.             x = 1;
  34.             output += s +" "+ x +" "+ vars.get(y+1);
  35.         } else if ( s.equals(old_mat) ) {
  36.             output += s +" "+ x +" "+ vars.get(y+1);
  37.         }
  38.     x++;
  39.    
  40.     // Add spaces to keep second column straight
  41.     if (x < 10 ) {
  42.         space += "  ";
  43.     } else if (x < 100 ) {
  44.         space += " ";
  45.     }
  46.    
  47.     // Add space after first material
  48.     if (y == 1) { output += space; }
  49.     old_mat = s;
  50.     }
  51. }
  52.     clientGUI.printText("general", " " + output +"\n");
  53. }
  54.  
  55. void bootup() {
  56.   triggerManager.newTrigger("fn_count_mat",
  57.     "^ ([a-z]+[ ]{0,1}[a-z]+) (\\[[^]]+\\])([ ]+)?([a-z]+[ ]{0,1}[a-z]+)? ?(\\[[^]]+\\])?[ ]+$",
  58.     "$"+SCRIPT_NAME+".count", true, false, false,
  59.     null, Font.PLAIN);
  60.  
  61. // disable by default
  62. clientGUI.doCommand("/trigdisable fn_count_mat");
  63.  
  64.   triggerManager.newTrigger("fn_begin_forge",
  65.     "^There are ([1-9]+) minerals in it:$",
  66.     "$"+SCRIPT_NAME+".enableCount", false, false, false,
  67.     null, Font.PLAIN);
  68.  
  69. // Amateur/pro/master forges are all extremely heavy?
  70.   triggerManager.newTrigger("fn_end_forge",
  71.     "^It looks EXTREMELY heavy.$",
  72.     "$"+SCRIPT_NAME+".disableCount", false, false, false,
  73.     null, Font.PLAIN);
  74. }
Advertisement
Add Comment
Please, Sign In to add comment