Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $${
- // Calc v1.1
- STRIP(&chat,%CHAT%)
- IFMATCHES(%&chat%,^/calc)
- FILTER
- IFMATCHES(%&chat%,^/calc ([0-9]+))
- MATCH(%&chat%,^/calc (.*)$,{&calc})
- REPLACE(&calc," ","")
- MATCH(%&calc%,([0-9]+)(.)([0-9]+),{#num1,&operator,#num2})
- IF(%&operator%=="/")
- #num1a = #num1 * 1000
- #answer = #num1a / #num2
- IF(%#answer%<=99)
- SET(&answer,00%#answer%)
- ELSE
- SET(&answer,%#answer%)
- ENDIF
- MATCH(%&answer%,"([0-9]*)([0-9]{2})([0-9])",{#whole,&dec,#round})
- SET(#dec,%&dec%)
- IF(%#round%>=5)
- SET(#dec,%&dec%)
- INC(#dec)
- ELSE
- SET(#dec,%&dec%)
- ENDIF
- IF(%#dec%==0)
- SET(&answer,%#whole%)
- ELSE
- IF(%#dec%<10)
- SET(&answer,"%#whole%.0%#dec%")
- ELSE
- SET(&answer,"%#whole%.%#dec%")
- ENDIF
- ENDIF
- ELSEIF(%&operator%=="*")
- #answer = #num1 * #num2
- SET(&answer,%#answer%)
- ELSEIF(%&operator%=="+")
- #answer = #num1 + #num2
- SET(&answer,%#answer%)
- ELSEIF(%&operator%=="-")
- #answer = #num1 - #num2
- SET(&answer,%#answer%)
- ENDIF
- LOG(&6[&4CALC&6] &a%#num1% %&operator% %#num2% = %&answer%)
- ELSE
- LOG(&6[&4CALC&6] &aBasic Calculator that doesn't work well)
- LOG(&6[&4CALC&6] &aUsage: <number> <*/+-> <number>)
- LOG(&6[&4CALC&6] &aPlease do not use decimals or negative numbers because &athe calculator is dumb)
- LOG(&6[&4CALC&6] &av 1.1)
- ENDIF
- ENDIF
- SET(
- }$$
Advertisement
Add Comment
Please, Sign In to add comment