banovski

Numberer

Nov 25th, 2019 (edited)
1,431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 0.68 KB | None | 0 0
  1. if (input ==~ 'ni[0-9]+') {
  2.     int counter = 1
  3.     def maxNumber = input.replaceAll('[^0-9]', '');
  4.     if (maxNumber == null) {
  5.     return;
  6.     }
  7.     int intMaxNumber = maxNumber.toInteger();
  8.     if (intMaxNumber>=40) {
  9.     ui.informationMessage(ui.frame, "You've reached the limit!");
  10.     } else {
  11.     counter = 1
  12.     def firstChild = node.createChild();
  13.     firstChild.icons.add("full-" + counter);
  14.     c.select(firstChild);
  15.     while (counter++<intMaxNumber) {
  16.         def lastChild = node.createChild();
  17.         int decs = counter / 10;
  18.         int ones = counter % 10;
  19.         if (decs > 0) {
  20.         lastChild.icons.add("full-" + decs);
  21.         }
  22.         lastChild.icons.add("full-" + ones);    
  23.     }
  24.     }
  25. }
Add Comment
Please, Sign In to add comment