ALIAS Acalc {
tokenize 32 $remove($1-,$chr(44),$chr(32))
var %matches $regex($1-,/L(\d\d?)/gi), %i = 1, %calculate = $1-
while (%i <= %matches) {
var %calculate = $replace(%calculate,L $+ $regml(%i),$LevelsAndXp($regml(%i)))
inc %i
}
if (k isin %calculate) {
var %x = 1, %total = $pos(%calculate,k,0)
while (%x <= %total) {
var %kpos = $pos(%calculate,k,%x), %kstartpos = $calc(%kpos - 1), %klen = 1
while ($mid(%calculate,%kstartpos,1) isin 1234567890.) && (%kstartpos > 0) { dec %kstartpos | inc %klen }
var %calculate = $iif(%kstartpos >= 0,$left(%calculate,%kstartpos)) $+ $chr(40) $+ $mid(%calculate,$calc($iif(%kstartpos == 0,0,%kstartpos +1)),%klen) $+ $chr(41) $+ $right(%calculate,- $+ %kpos)
inc %x
}
}
if (m isin %calculate) {
var %x = 1, %total = $pos(%calculate,m,0)
while (%x <= %total) {
var %mpos = $pos(%calculate,m,%x), %mstartpos = $calc(%mpos - 1), %mlen = 1
while ($mid(%calculate,%mstartpos,1) isin 1234567890.) && (%mstartpos > 0) { dec %mstartpos | inc %mlen }
var %calculate = $iif(%mstartpos >= 0,$left(%calculate,%mstartpos)) $+ $chr(40) $+ $mid(%calculate,$calc($iif(%mstartpos == 0,0,%mstartpos +1)),%mlen) $+ $chr(41) $+ $right(%calculate,- $+ %mpos)
inc %x
}
}
var %calculate $replace($remove(%calculate,$chr(44),$chr(61)),x,*,k,*1000,m,*1000000)
var %answer = $bytes($calc(%calculate),db)
return %answer
}
on $*:text:/^[!@.]calc */Si:*: {
if ($isignored($nick)) halt
if ($regex($2-,/[a-jln-z]/i)) { notice $nick 1*** [4Calc1]: ERROR: Illegal Letters Detected. Only M for Millions and K for Thousands are allowed. | halt }
if ($2 == $null) { notice $nick 1*** [4Calc1]: Usage: .calc <math> - Example: .calc 2.3m-357k - Only M for Millions and K for Thousands are allowed. | halt }
var %send = $iif($left($1,1) != !,msg $chan,notice $nick)
%send 1*** [4Calc1]: $2- = $acalc($2-)
if ((!$regex($2-,/[km]/i)) && (%calc.note. [ $+ [ $nick ] ] != 1)) { set -u43200 %calc.note. [ $+ [ $nick ] ] 1 | notice $nick 1*** [4Calc1]: Did you know you can use M for Millions and K for Thousands? Try it out sometime! (Shev is gay! }
}