Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- alias coloron { set -n %color $1 }
- alias coloroff { unset %color }
- on *:input:*:{
- if (%color) && ($left($1,1) !isin /!) && (c !isincs $chan(#).mode) {
- haltdef
- say $chr(3) $+ %color $+ $chr(2) $+ $chr(2) $+ $1-
- }
- }
- # Dice roller, by Kardafol
- #rolldice on
- on *:text:*!roll*:%dr.chan.list: {
- ;flood protection
- if (%dr.flood.e) {
- if (%dr.flood.x. [ $+ [ # ] ] >= %dr.flood.t) return
- inc %dr.flood.x. [ $+ [ # ] ]
- if (!$timer(dr.flood.x. [ $+ [ # ] ])) .timerdr.flood.x. [ $+ [ # ] ] 1 %dr.flood.s unset %dr.flood.x. [ $+ [ # ] ]
- }
- if (%dr.gflood.e) {
- if (%dr.gflood.c >= %dr.flood.t) return
- inc %dr.gflood.c
- if (!$timer(dr.gflood)) .timerdr.gflood 1 %dr.gflood.s unset %dr.gflood.c
- }
- ; syntax things, and error checking
- if ((!$2) || ($2 == help)) {
- describe # , tadi $nick lupa caranya ngelempar dadu.
- return
- }
- var %x = $rolldice($2-)
- if (-* iswm %x) {
- describe # , $nick kok ga ngerti juga ya caranya ngelempar dadu.
- return
- }
- else {
- describe # , hari ini $nick melempar $2- dan mendapat %x $+ .
- }
- }
- alias rd {
- ; syntax things, and error checking
- if ((!$1) || ($1 == help)) {
- echo -a Syntax: <<dice>d<sides: 4/6/8/10/20/100 standard ad&d>|<number>>[<+/->...]. <> = required, [] = optional. $&
- ... means you may repeat the expression. <number> is a number to add to the total without rolling a dice for it. The first part must be a roll. $&
- Limit to <dice> is 100.
- echo -a Examples: !roll 2d6+5, !roll 1d20, !roll 2d6+1d8-3. Bad examples: !roll 2d2+4, !roll 5+2d6, !roll 101d4+5
- return
- }
- var %x = $rolldice($1-)
- if (-* iswm %x) {
- echo -a Your syntax is invalid. Possible errors: $gettok(%x,2-,32) $+ .
- return
- }
- else {
- echo -a You roll $1- $+ : %x
- }
- }
- alias -l rolldice {
- if (!$1) return -
- ; Syntax checking:
- var %s = $1-, %st = 09, %f = 1
- if ($len(%s) > 100) {
- return - ...(Males ah nulisnya, kepanjangan.)
- }
- while ($regsub(%s,/^((\d+)d\d+(?:[-+]|$)|\d+(?:[-+]|$))/,$null,%s)) {
- if ((%f == 1) && (*d* !iswm $regml(1))) {
- return - $+(%st,04,$regml(1),%s,14(Expression needs to start with xdx))
- }
- if ($regml(2) > 100) {
- return - $+(%st,04,$regml(1),%s,14(xdx: x cannot exceed 100))
- }
- var %st = $iif(%f > 2,09...,09) $+ $regml(1)
- inc %f
- }
- if (%s != $null) {
- return - $+(%st,04,$iif($len(%s) > 10,$+($mid(%s,1,7),...),%s),14(error parsing expression, see red for possible errors))
- }
- if ((*+ iswm %st) || (*- iswm %st)) {
- return - $+($mid(%st,1,$calc($len(%st) - 1)),04,$mid(%st,$calc($len(%st))),14(error parsing expression, see red for possible errors))
- }
- ; The actual calculations and rolls
- var %x = $1-, %rolls, %t, %total
- while ($regsub(roll,%x,/^(?:(\d+)(d)(\d+)([-+]|$)|(\d+)([-+]|$))/,$null,%x)) {
- if ($regml(roll,2) == d) {
- var %d = $regml(roll,1), %s = $regml(roll,3)
- var %o = $droll(%d,%s), %t = $gettok(%o,1,32), %rx = $gettok(%o,2-,32)
- var %total = $calc(%t %m %total)
- var %rolls = %rolls $iif(%m,%m) $+([,%rx,])
- var %m = $regml(roll,4)
- }
- else {
- if (!%m) %m = +
- var %total = $iif(%total,$calc(%total %m $regml(roll,1)),$regml(roll,1))
- var %rolls = %rolls %m $regml(roll,1)
- var %m = $regml(roll,2)
- }
- }
- if ($len(%rolls) > 150) %rolls = ...males ah nulisnya, kepanjangan
- return %rolls = %total
- }
- alias -l droll {
- if (($1 !isnum) || ($2 !isnum)) return
- var %n = $1, %s = $2, %r, %rolls, %t
- while (%n) {
- %r = $rand(1,%s)
- %t = $calc(%t + %r)
- %rolls = $iif(%rolls,$+(%rolls,+,%r),%r)
- dec %n
- }
- return %t $iif(+ isin %rolls,$+(%rolls,=,%t),%rolls)
- }
- #rolldice end
- alias dr {
- diceroll $1-
- }
- alias diceroll {
- if ((!$1) || ($1 == help)) {
- echo -ac info * DiceRoll is $iif($group(#rolldice) == on,enabled,disabled) $+ . /diceroll <on/off> to enable or disable.
- echo -ac info * /diceroll flood <on/off/set <times> <seconds>>. Flood is per channel. Default is: /dr flood set 1 2.
- echo -ac info * /diceroll <channel/chan/#> <list/add/del> [#channel]
- echo -ac info * /diceroll start. To revieve instructions on how to get started.
- echo -ac info * /diceroll <globalfoood/gflood> <on/off/set <times> <seconds>>. To set global flood. Default is: /dr gflood set 4 2.
- echo -ac info * /diceroll reset
- echo -ac info * You can also use /dr as an alias, and /rd to roll dice for yourself, using /echo.
- }
- if ($1 == on) {
- if ($group(#rolldice) == on) echo -ac info * DiceRoll is already enabled.
- else {
- .enable #rolldice
- echo -ac info * DiceRoll has been enabled.
- }
- .dr gflood on
- .dr flood on
- }
- elseif ($1 == off) {
- if ($group(#rolldice) == off) echo -ac info * DiceRoll is already disabled.
- else {
- .disable #rolldice
- echo -ac info * DiceRoll has been disabled. Type "/dr reset" to unset variables.
- }
- }
- elseif ($1 == flood) {
- if ($2 == on) {
- if (!%dr.flood) {
- set %dr.flood.t 1
- set %dr.flood.s 2
- }
- echo -ac info * DiceRoll flood protection $iif(%dr.flood.e == 1,is already,has been) enabled. $+([,%dr.flood.t time(s) in %dr.flood.s second(s),])
- set %dr.flood.e 1
- }
- elseif ($2 == off) {
- echo -ac info * DiceRoll flood protection $iif(%dr.flood.e == 0,is already,has been) disabled.
- set %dr.flood.e 0
- }
- elseif ($2 == set) {
- if (!$3) {
- echo -ac info * Invalid parameters, correct syntax is:
- echo -ac info * /diceroll flood <on/off/set <times> <seconds>>
- return
- }
- set %dr.flood.t $3
- set %dr.flood.s $4
- echo -ac info * DiceRoll flood protection has been set to %dr.flood.t time(s) in %dr.flood.s second(s) $+ $iif(%dr.flood.e == 0,but is disabled.,.)
- }
- else {
- echo -ac info * /diceroll flood <on/off/set <times> <seconds>>. Flood is per channel. Default is: /dr flood set 1 2.
- }
- }
- elseif (($1 == globalflood) || ($1 == gflood)) {
- if ($2 == on) {
- if (!%dr.gflood) {
- set %dr.gflood.t 4
- set %dr.gflood.s 2
- }
- echo -ac info * DiceRoll global flood protection $iif(%dr.gflood.e == 1,is already,has been) enabled. $+([,%dr.gflood.t time(s) in %dr.gflood.s second(s),])
- set %dr.gflood.e 1
- }
- elseif ($2 == off) {
- echo -ac info * DiceRoll global flood protection $iif(%dr.gflood.e == 0,is already,has been) disabled.
- set %dr.gflood.e 0
- }
- elseif ($2 == set) {
- if (!$3) {
- echo -ac info * Invalid parameters, correct syntax is:
- echo -ac info * /diceroll <globalfoood/gflood> <on/off/set <times> <seconds>>
- return
- }
- set %dr.gflood.t $3
- set %dr.gflood.s $4
- echo -ac info * DiceRoll global flood protection has been set to %dr.gflood.t time(s) in %dr.gflood.s second(s) $+ $iif(%dr.gflood.e == 0,$chr(44) but is disabled.,.)
- }
- else {
- echo -ac info * /diceroll <globalfoood/gflood> <on/off/set <times> <seconds>>. To set global flood. Default is: /dr gflood set 4 2.
- }
- }
- elseif (($1 == $(#,0)) || ($1 == chan) || ($1 == channel)) {
- if ((!$2) || ($2 == list)) {
- echo -ac info * DiceRoll is running on the channels: $iif(%dr.chan.list,$v1,(none))
- }
- elseif (($2 == add) && (#* iswm $3)) {
- if ($istok(%dr.chan.list,$3,44)) {
- echo -ac info * $3 is already on the DiceRoll channel list.
- return
- }
- set %dr.chan.list $addtok(%dr.chan.list,$3,44)
- echo -ac info * $3 has been added to the DiceRoll channel list.
- }
- elseif (($2 == del) && (#* iswm $3)) {
- if (!$istok(%dr.chan.list,$3,44)) {
- echo -ac info * $3 is not on the DiceRoll channel list.
- return
- }
- set %dr.chan.list $deltok(%dr.chan.list,$findtok(%dr.chan.list,$3,44),44)
- echo -ac info * $3 has been removed from the DiceRoll channel list.
- }
- else {
- echo -ac info * /diceroll <channel/chan/#> <list/add/del> [#channel]
- }
- }
- elseif ($1 == start) {
- echo -ac info * Welcome to DiceRoll.
- echo -ac info * First, you need to enable rolling (/dr on).
- echo -ac info * Then, you need to add channels (/dr $(#,0) add #channel).
- echo -ac info * Then you'll be all set! To see rolling syntax, type "!roll".
- echo -ac info * You can also type /rd (after typing /dr on) to roll for yourself (will echo to your active window).
- }
- elseif ($1 == reset) {
- unset %dr.*
- echo -ac info * DiceRoll variables have been unset.
- }
- else {
- echo -ac info * Type /dr help for commands, and status.
- }
- }
- on *:load: {
- echo -ac info * Dice Roll V1 by kardafol has been sucessfully loaded.
- echo -ac info * Type /diceroll start to get started.
- }
- on *:unload: {
- .unset %dr.*
Advertisement