mIRC Home    About    Download    Register    News    Help

Print Thread
Cannot get script to continue #250164 04/01/15 07:51 PM
Joined: Jan 2015
Posts: 9
B
Budd Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Jan 2015
Posts: 9
In a Twitch channel, we have a function for a weekly "sweetheart". This person gets certain perks for the week and one of the fun functions is that the chat's bot "stalks" them.

However I can't get the script to go past this portion of the code and continue to read the rest of the script. I've tried re-writing this part several times now.

Could anyone help me figure out how to write this portion? Here is a sample of what I have now:

Code:
 ;SWEETHEART STALKER
on *:text:*:#: {
  if ($nick == %sweet. [ $+ [ $network ] $+ ] . [ $+ [ $chan ] ]) {
    var %sweetr = $rand(1,20)
    if (%sweetr == 1) { msg $chan Hey, sweetheart <3 } 
    if (%sweetr == 2) { msg $chan It's the channel qt 3.14 <3 } 
    if (%sweetr == 3) { msg $chan Wow you are absolutely A-M-A-Z-I-N-G <3 } 
    if (%sweetr == 4) { msg $chan Oh hey der Kappa <3 } 
  }
} 


Thanks!

Re: Cannot get script to continue [Re: Budd] #250170 04/01/15 08:59 PM
Joined: Oct 2009
Posts: 24
Scakk Offline
Ameglian cow
Offline
Ameglian cow
Joined: Oct 2009
Posts: 24
Your $rand() has 1-20 while you only have 4 if statements. Either add 16 more ifs or change the $rand() to be 1-4.

Re: Cannot get script to continue [Re: Scakk] #250172 04/01/15 09:12 PM
Joined: Jan 2015
Posts: 9
B
Budd Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Jan 2015
Posts: 9
I changed it to only 1,4 and the script still won't continue. I should note, the random statements work fine, I just can't get the script to read past this block of code.

I have this after it to test it:
Code:
;SCRIPT TESTER - Test to see if script is read to the very bottom
on *:text:!stest:#:{
  if ($nick == budd_manlove) { msg # Test successful! } { return }
}

Re: Cannot get script to continue [Re: Budd] #250174 04/01/15 09:54 PM
Joined: Jan 2004
Posts: 1,274
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,274
Well that's invalid syntax, so that might have something to do with it.

Re: Cannot get script to continue [Re: Budd] #250175 04/01/15 09:55 PM
Joined: Sep 2014
Posts: 259
S
Sakana Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
$network doesn't exist/work on the Twitch IRC server, so try and remove that part

Re: Cannot get script to continue [Re: Loki12583] #250176 04/01/15 10:56 PM
Joined: Jan 2015
Posts: 9
B
Budd Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Jan 2015
Posts: 9
Originally Posted By: Loki12583
Well that's invalid syntax, so that might have something to do with it.


Could you explain what you mean?

Also, the original code above actually works. I just cant get the script to read past it (even if the rand() is set 1-20, it works). The next block of code (!stest command) works as well but only when I comment out the sweetheart coding.

Last edited by Budd; 04/01/15 10:58 PM.
Re: Cannot get script to continue [Re: Sakana] #250177 04/01/15 11:03 PM
Joined: Jan 2015
Posts: 9
B
Budd Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Jan 2015
Posts: 9
Originally Posted By: Sakana
$network doesn't exist/work on the Twitch IRC server, so try and remove that part


I've removed it, the code still works but I still can't get it to read past it.

Re: Cannot get script to continue [Re: Budd] #250178 04/01/15 11:06 PM
Joined: Sep 2014
Posts: 259
S
Sakana Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
The syntax is supposed to be something like this (the return is redundant though)

Code:
on *:text:!stest:#:{
  if ($nick == budd_manlove) { 
  msg # Test successful! 
  return 
  }
}

Re: Cannot get script to continue [Re: Sakana] #250179 04/01/15 11:10 PM
Joined: Jan 2015
Posts: 9
B
Budd Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Jan 2015
Posts: 9
Thanks for that. The !stest portion actually worked before. I changed it to what you suggested and it still works but only if I comment out the sweetheart portion. If the sweetheart portion is active, it doesn't reach that part of the script to respond to the !stest command.

Re: Cannot get script to continue [Re: Budd] #250180 04/01/15 11:30 PM
Joined: Sep 2014
Posts: 259
S
Sakana Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
When you have a script that triggers on any text, it's usually a good idea to place it in its own file in the scripts editor. Otherwise, other on text events written in the same file tend to stop working

Re: Cannot get script to continue [Re: Sakana] #250181 05/01/15 12:01 AM
Joined: Jul 2006
Posts: 3,559
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,559
Well, events written in the same file just don't "tend" to stop working lol. mIRC will search the script file for a matching event, once one event has matched, mIRC simply stop looking into that file. You can only trigger one kind of event per file, suppose your remote script file is:
Code:
on *:text:*:#:{ echo -s $nick said on $chan : $1- }
on *:text:!test:#:{ echo -s $nick executed !test on $chan }


If someone type !test, the second on text event will never trigger, because the first one with the '*' matchtext will always match for "!test". Now suppose to change the order:

Code:
on *:text:!test:#:{ echo -s $nick executed !test on $chan }
on *:text:*:#:{ echo -s $nick said on $chan : $1- }


If someone now type !test, the first on text event will trigger, the second one won't, however in this situation, the second on text event can be triggered (for anything else than "!test" given as $1-)


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Cannot get script to continue [Re: Sakana] #250182 05/01/15 12:02 AM
Joined: Jan 2015
Posts: 9
B
Budd Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Jan 2015
Posts: 9
Originally Posted By: Sakana
When you have a script that triggers on any text, it's usually a good idea to place it in its own file in the scripts editor. Otherwise, other on text events written in the same file tend to stop working


Thank you, I'm a bit new to this if you couldn't tell. Would you mind telling me how to create a separate file for this? I've scripted everything so far in the "remote" tab so I don't know how to have mIRC read outside of that tab.

@Wims - That makes a lot of sense. So basically, I either need that portion at the bottom of the script, or not in the script at all, or accessible from another location.

Last edited by Budd; 05/01/15 12:06 AM.
Re: Cannot get script to continue [Re: Budd] #250183 05/01/15 01:48 AM
Joined: Sep 2014
Posts: 259
S
Sakana Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
smile

Just click File -> New when you're in the Remote tab. You can change between files under View

Re: Cannot get script to continue [Re: Sakana] #250186 05/01/15 02:59 AM
Joined: Jan 2015
Posts: 9
B
Budd Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Jan 2015
Posts: 9
Thanks Sakana!