You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#[desc("Speed of operation (higher number increases group usage)")] speed: @number = DEFAULT_SPEED,
84
-
#[desc("Multiplyer for the value added")] factor: @number = 1,
82
+
#[desc("Multiplier for the value added")] factor: @number = 1,
85
83
#[desc("Macro to be called for each decrease of the counter. Takes one argument representing the number the counter is being decreased by (if speed = 1 this will always be 1)")] for_each: @macro = (n){}
86
84
) {
87
85
wait()
@@ -218,8 +216,6 @@ c.multiply(10)
218
216
wait()
219
217
temp.add_to([self.item], speed)
220
218
221
-
} else {
222
-
throw "Cannot multiply counter by " + factor.type as @string
223
219
}
224
220
},
225
221
@@ -332,11 +328,7 @@ c.divide(2, remainder = r)
332
328
333
329
334
330
335
-
} else {
336
-
throw "Cannot divide counter by " + divisor.type as @string
337
331
}
338
-
339
-
340
332
},
341
333
342
334
//will consume both numbers
@@ -472,10 +464,8 @@ c2 = c1 + 10
472
464
-> return new_counter
473
465
} else if other.type == @counter {
474
466
new_counter = self.clone()
475
-
other.clone().add_to([new_counter.item])
467
+
other.copy_to([new_counter.item], factor = 1)
476
468
-> return new_counter
477
-
} else {
478
-
throw "Cannot add counter with " + num.type as @string
479
469
}
480
470
},
481
471
@@ -489,8 +479,10 @@ c2 = c1 - 3
489
479
new_counter = self.clone()
490
480
new_counter.add(-other)
491
481
-> return new_counter
492
-
} else {
493
-
throw "Cannot subtract counter with " + num.type as @string
482
+
} else if other.type == @counter {
483
+
new_counter = self.clone()
484
+
other.copy_to([new_counter.item], factor = -1)
485
+
-> return new_counter
494
486
}
495
487
},
496
488
@@ -562,8 +554,6 @@ more = c > 10
562
554
other_clone = other.clone()
563
555
cmp = self_clone.compare(other_clone)
564
556
-> return cmp == 1
565
-
} else {
566
-
throw "Cannot compare counter with " + other.type as @string
567
557
}
568
558
},
569
559
@@ -588,8 +578,6 @@ less = c < 42
588
578
other_clone = other.clone()
589
579
cmp = self_clone.compare(other_clone)
590
580
-> return cmp == -1
591
-
} else {
592
-
throw "Cannot compare counter with " + other.type as @string
593
581
}
594
582
},
595
583
@@ -614,8 +602,6 @@ more_or_eq = c >= 10
614
602
other_clone = other.clone()
615
603
cmp = self_clone.compare(other_clone)
616
604
-> return cmp == 1 || cmp == 0
617
-
} else {
618
-
throw "Cannot compare counter with " + other.type as @string
619
605
}
620
606
},
621
607
@@ -640,8 +626,6 @@ less_or_eq = c <= 42
640
626
other_clone = other.clone()
641
627
cmp = self_clone.compare(other_clone)
642
628
-> return cmp == -1 || cmp == 0
643
-
} else {
644
-
throw "Cannot compare counter with " + other.type as @string
645
629
}
646
630
},
647
631
@@ -668,8 +652,6 @@ eq = c == 42
668
652
other_clone = other.clone()
669
653
cmp = self_clone.compare(other_clone)
670
654
-> return cmp == 0
671
-
} else {
672
-
throw "Cannot compare counter with " + other.type as @string
673
655
}
674
656
},
675
657
@@ -700,8 +682,6 @@ c += 10
700
682
self.add(num)
701
683
} else if num.type == @counter {
702
684
num.clone().add_to([self])
703
-
} else {
704
-
throw "Cannot add " + num.type as @string + " to counter"
705
685
}
706
686
},
707
687
@@ -732,8 +712,6 @@ c -= 5
732
712
733
713
} else if num.type == @counter {
734
714
num.clone().subtract_from([self])
735
-
} else {
736
-
throw "Cannot subtract " + num.type as @string + " from counter"
737
715
}
738
716
},
739
717
@@ -747,8 +725,6 @@ c *= 6
747
725
self.multiply(num)
748
726
} else if num.type == @counter {
749
727
self.multiply(num)
750
-
} else {
751
-
throw "Cannot multiply counter by " + num.type as @string
752
728
}
753
729
},
754
730
@@ -761,8 +737,6 @@ c /= 6
761
737
self.divide(num)
762
738
} else if num.type == @counter {
763
739
self.divide(num)
764
-
} else {
765
-
throw "Cannot divide counter by " + num.type as @string
766
740
}
767
741
},
768
742
@@ -778,8 +752,6 @@ c = 42
778
752
}
779
753
} else if num.type == @counter {
780
754
num.copy_to([self])
781
-
} else {
782
-
throw "Cannot assign" + num.type as @string + " to counter"
783
755
}
784
756
},
785
757
@@ -791,14 +763,10 @@ c <=> c2
791
763
// c is now 42, c2 is now 23
792
764
")]
793
765
(self, num: @counter) {
794
-
if num.type == @counter {
795
-
swap_tmp = @counter::new();
796
-
self.add_to(swap_tmp)
797
-
num.add_to(self)
798
-
swap_tmp.add_to(num)
799
-
}else {
800
-
throw "Cannot swap counter with " + num.type as @string
801
-
}
766
+
swap_tmp = @counter::new();
767
+
self.add_to(swap_tmp)
768
+
num.add_to(self)
769
+
swap_tmp.add_to(num)
802
770
},
803
771
804
772
to_const: #[desc("Converts the counter into a normal number (very context-splitting, be careful)") example("
0 commit comments