mIRC Home    About    Download    Register    News    Help

Print Thread
Trying to Run a Script #246420 10/06/14 03:38 AM
Joined: Jun 2014
Posts: 3
C
CountMonday Offline OP
Self-satisified door
OP Offline
Self-satisified door
C
Joined: Jun 2014
Posts: 3
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!

Last edited by CountMonday; 10/06/14 03:42 AM.
Re: Trying to Run a Script [Re: CountMonday] #246422 10/06/14 04:09 AM
Joined: Dec 2013
Posts: 779
N
Nillen Offline
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
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.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Re: Trying to Run a Script [Re: Nillen] #246434 11/06/14 03:53 AM
Joined: Jun 2014
Posts: 3
C
CountMonday Offline OP
Self-satisified door
OP Offline
Self-satisified door
C
Joined: Jun 2014
Posts: 3
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.

Re: Trying to Run a Script [Re: CountMonday] #246435 11/06/14 03:57 AM
Joined: Dec 2013
Posts: 779
N
Nillen Offline
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
You're not supposed to paste it in aliases, paste it in the remote.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Re: Trying to Run a Script [Re: Nillen] #246450 12/06/14 01:32 AM
Joined: Jun 2014
Posts: 3
C
CountMonday Offline OP
Self-satisified door
OP Offline
Self-satisified door
C
Joined: Jun 2014
Posts: 3
Glad to get that fixed, but still no luck. Is there some other obvious step I might be missing?

Re: Trying to Run a Script [Re: CountMonday] #246460 12/06/14 02:21 PM
Joined: Apr 2014
Posts: 191
B
blessing Offline
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
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.

Re: Trying to Run a Script [Re: CountMonday] #246472 12/06/14 06:43 PM
Joined: Mar 2004
Posts: 359
L
LostServ Offline
Fjord artisan
Offline
Fjord artisan
L
Joined: Mar 2004
Posts: 359
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.)

Last edited by LostServ; 12/06/14 06:45 PM.