I'm not sure I understood that, but perhaps it will help if I show you what I have:

Code:
on 1:TEXT:*roll*:#room: {
  if ($2 !isnum) { halt } {
    var %Roll.NumberOfdice = $2
    var %Success.Count = 0
    var %Trait.1 = 0
    var %Trait.2 = 0
    var %Trait.3 = 0
    var %Trait.4 = 0
    var %i = 1
    while (%i <= %Roll.NumberOfdice) {
      var %Die.Result = $rand(1,6)
      if (%Die.Result = 6) { inc %Success.Count 2 }
      if (%Die.Result = 5) { inc %Success.Count }
      if (%Die.Result = 4) { inc %Trait.4 }
      if (%Die.Result = 3) {
        inc %Trait.4
        inc %Trait.3
      }
      if (%Die.Result = 2) {
        inc %Trait.4
        inc %Trait.3
        inc %Trait.2
      }
      if (%Die.Result = 1) {
        inc %Trait.4
        inc %Trait.3
        inc %Trait.2
        inc %Trait.1
      }
      var %Roll.Result = %Roll.Result %Die.Result
      inc %i
    }
    /msg $chan * $nick rolls $2 dice ( %Roll.Result ) for %Success.Count success(es).
    /msg $chan * $nick may activate an Anima Trait of 4 to reroll %Trait.4 dice.
    /msg $chan * $nick may activate an Anima Trait of 3 to reroll %Trait.3 dice.
    /msg $chan * $nick may activate an Anima Trait of 2 to reroll %Trait.2 dice.
    /msg $chan * $nick may activate an Anima Trait of 1 to reroll %Trait.1 dice.
  }
}


This script will wait for the word "roll". Then, if there is a number in the 2nd position, it rolls x d6. It tallies one success for every '5', and two successes for every '6'. It also counts possible rerolls. If there is no number in the second position, it halts.

For example, I type:

roll 4

It returns:

rolls 4 dice ( 6 6 3 4 ) for 4 success(es).
may activate an Anima Trait of 4 to reroll 2 dice.
may activate an Anima Trait of 3 to reroll 1 dice.
may activate an Anima Trait of 2 to reroll 0 dice.
may activate an Anima Trait of 1 to reroll 0 dice.

Ideally, I want the Bot to look for the word "roll" or "rolls" anywhere in a line of text. If it finds those words followed by a number, it executes using that number as the variable. If it doesn't see the number, nothing happens.

I can easily do "roll" and "rolls" by making two separate on:TEXT: commands. But making it take look for the number after the word is what flummoxed me.

Later I want to add complexity by making it look for the text only from users I have identified as "players", but for now I just want the dice part to run right.

Thanks,

Longspeak

Edit: Removed redundant line of code

Last edited by Longspeak; 01/05/05 07:01 PM.