Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $${
- // Calc v 1.2
- STRIP(&chat,%CHAT%)
- IFMATCHES(%&chat%,"^(/?)/calc")
- FILTER
- MATCH(%&chat%,"calc (.*)$",{&calc})
- REPLACE(&calc," ")
- IFMATCHES(%&calc%,"^(-?[0-9]+[*/+-]-?[0-9]+([*/+-]-?[0-9]+)*)$")
- DO(100)
- IFMATCHES(%&calc%,"(-?[0-9]+)([*/])(-?[0-9]+)")
- MATCH(%&calc%,"(-?[0-9]+)([*/])(-?[0-9]+)",{#num1,&operator,#num2})
- ELSE
- IFMATCHES(%&calc%,"(-?[0-9]+)([+-])(-?[0-9]+)")
- MATCH(%&calc%,"(-?[0-9]+)([+-])(-?[0-9]+)",{#num1,&operator,#num2})
- ENDIF
- ENDIF
- //Division
- IF(%&operator%=="/")
- SET(&calc,"&4please god no division")
- BREAK
- //Multiplication
- ELSEIF(%&operator%=="*")
- #answer = #num1 * #num2
- SET(&answer,%#answer%)
- //Addition
- ELSEIF(%&operator%=="+")
- #answer = #num1 + #num2
- SET(&answer,%#answer%)
- //Subtraction
- ELSEIF(%&operator%=="-")
- #answer = #num1 - #num2
- SET(&answer,%#answer%)
- ENDIF
- REGEXREPLACE(&calc,"((-?[0-9]+)\%&operator%(-?[0-9]+))","%#answer%")
- IFMATCHES(%&calc%,"([*/+-])")
- SET(loop)
- ELSE
- UNSET(loop)
- ENDIF
- WHILE(%loop%)
- LOG("&6[&4CALC&6]&a %&calc%")
- ELSE
- LOG("&6[&4CALC&6] &aBasic Calculator that doesn't work well")
- LOG("&6[&4CALC&6] &aPlease do not use decimals because &athe calculator is dumb")
- LOG("&6[&4CALC&6] &av 1.2")
- ENDIF
- ENDIF
- }$$
Advertisement
Add Comment
Please, Sign In to add comment