mIRC Homepage
Posted By: CountMonday Trying to Run a Script - 10/06/14 03:38 AM
Hello all!

I want to use the below dice rolling script for a game I'll soon GM. Unfortunately, it's not running, and I have next to no experience at coding (I found it off a Google search). I'm just an RPG enthusiast who enjoys running games over IRC and wants use scripts as a time-saving alternative to rolling physical dice. They might as well be written in Greek to me.

Code:
on *:text:roll &:#: {
  if ($2 !isnum) { msg $chan Invalid number of dice. | return }
  var %c = $2
  while (%c) {
    var %roll = $rand(1,10)
    if (%roll = 1) { var %roll = #04,01 $+ %roll }
    elseif (%roll isnum 2-7) { var %roll = #00,01 $+ %roll }
    elseif (%roll isnum 8-9) { var %roll = #03,01 $+ %roll }
    else { var %roll = #09,01 $+ %roll }
    var %dice = %dice $+ $iif(%dice,# $+ $chr(44)) %roll
    dec %c
  }
  describe $chan $nick rolls $2 dice: $replace(%dice,$chr(46),# $+ $chr(44) $+ $chr(32))
}


I don't think there's anything wrong with the script itself, as it worked for other posters in the thread I found it from. When I type 'roll 2' or 'roll 4', though, nothing happens. I just get the text I enter displayed as a message, no dice rolled. I've been able to successfully run another (less convenient) dice rolling script, so at least this one isn't working because IRC categorically hates my guts.

Hopefully the answer to my problem will turn out to be something totally simple. Thank you very much for any help!
Posted By: Nillen Re: Trying to Run a Script - 10/06/14 04:09 AM
There's nothing wrong with the script. Make a new file and paste it in there instead. It's likely that your script is never triggered due to something else triggering before it in the same file.

Go to File > New and paste the script in there instead and it's likely to work.
Posted By: CountMonday Re: Trying to Run a Script - 11/06/14 03:53 AM
Sadly, no dice. Literally in my case. It's the only script that's there in aliases, but when I type 'roll 2' it still displays as a normal message.
Posted By: Nillen Re: Trying to Run a Script - 11/06/14 03:57 AM
You're not supposed to paste it in aliases, paste it in the remote.
Posted By: CountMonday Re: Trying to Run a Script - 12/06/14 01:32 AM
Glad to get that fixed, but still no luck. Is there some other obvious step I might be missing?
Posted By: blessing Re: Trying to Run a Script - 12/06/14 02:21 PM
try type /remote on in your editbox?

or ask your friend to trigger it for you?

or maybe you need to show what you have in your remote.
Posted By: LostServ Re: Trying to Run a Script - 12/06/14 06:43 PM
Originally Posted By: CountMonday
Glad to get that fixed, but still no luck. Is there some other obvious step I might be missing?


The script you found is written using the on text event. This event can't be triggered by you specifically, only other users on the channel.

So, with this script, you can't use it, but others can.

You have a few options..


  • Make it an alias that only _you_ can type, /roll (This script will only work in the Remotes tab unless you remove the word 'alias' on the first line.)
    Code:
    ; Usage: /roll #
    ; This command can only be typed into a window starting with a '#' (e.g. a channel)
    alias roll {
      if ($left($active,1) == #) {
        if ($1 !isnum) { echo -ac info * Invalid number of dice. | return }
        var %c = $1
        while (%c) {
          var %roll = $rand(1,10)
          if (%roll = 1) { var %roll = #04,01 $+ %roll }
          elseif (%roll isnum 2-7) { var %roll = #00,01 $+ %roll }
          elseif (%roll isnum 8-9) { var %roll = #03,01 $+ %roll }
          else { var %roll = #09,01 $+ %roll }
          var %dice = %dice $+ $iif(%dice,# $+ $chr(44)) %roll
          dec %c
        }
        describe $active rolled $1 dice: $replace(%dice,$chr(46),# $+ $chr(44) $+ $chr(32))
      }
    }
    
  • Just let others type it and not you
  • Copy and paste the mirc.exe into a new folder on its own to create a second instance of mIRC and put your roll script in that one. This way, you have a separate "bot" connection to your IRC channel.
  • Read up on the ON INPUT event which will trigger when YOU type something and not other users. (If you go this route, you will have two events.. one ON INPUT and one ON TEXT.)
© mIRC Discussion Forums