mIRC Home    About    Download    Register    News    Help

Print Thread
#250973 05/02/15 03:22 AM
Joined: Jul 2013
Posts: 9
I
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
I
Joined: Jul 2013
Posts: 9
Hello. I am trying to create a delay before i post a line from a read file. What I am trying to do, exactly, is to read a line, decide whether it is a delay token, and if it is, to set the delay time accordingly. However, if it is a normal line of text, then the script should message the line of text to the user.

I hope the idea is clear enough. So in a nutshell.. Read a line..determine if its a speed token..if it is..set new speed.. then.. delay a set time amount..them message a line.. Then do it again until the end of the file..

Here is the code. It worked at first.. But suddenly, now it doesn't..

Code:
on *:TEXT:!test:?:{ 
  var %temp 1
  while ($read(scripts/test.txt, n, %temp)) {
   if (#speed=* iswm $v1) {
    var %speed $gettok($v2,2,61))
    var %n 0
   }    
   else {
    inc %n
    timer -m 1 $calc(%speed * n) msg $nick $safe($v2)
   }
   inc %temp
  }
}
alias safe return $!decode( $encode($1-, m) ,m)


So now I am not sure why this is not working.. what is happening, is that it shoots out about 3 lines real quick..pauses for about 500 milliseconds.. then shoots out 3 more lines.. and on and on until the end of the text file.

The command in the text file is as follows..

Quote:
some text here
#speed=5000
more text here
rest of text here


Always remember...
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
See if /play is what you really want.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Jul 2013
Posts: 9
I
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
I
Joined: Jul 2013
Posts: 9
That's what i currently use, but it does not allow me to change the playback speed or anything else from the playback of the file. What I need is a method to change the playback speed based upon the embedded command in the text file.


Always remember...
Joined: Jul 2006
Posts: 4,185
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,185
Hello there, I helped you with this on IRC, that's my code with a typo, I gave you the correct line on IRC though, I thought you got it working, here the fixed code anyways:
Code:
on *:TEXT:!test:?:{ 
  var %temp 1
  while ($read(scripts/test.txt, n, %temp)) {
   if (#speed=* iswm $v1) {
    var %speed $gettok($v2,2,61))
    var %n 0
   }    
   else {
    inc %n
    .timer -m 1 $calc(%speed * %n) msg $nick $safe($v2)
   }
   inc %temp
  }
}
alias safe return $!decode( $encode($1-, m) ,m)


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jul 2013
Posts: 9
I
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
I
Joined: Jul 2013
Posts: 9
I copied and pasted from your irc post , and it was exactly as you posted in the mpaste. So I copied and pasted THIS one into the script window.. Now it plays lines randomly rather than in order. Also, It does not pause at all.. It posts as fast as it can.


Always remember...
Joined: Jul 2006
Posts: 4,185
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,185
I just tried it using this code:
Code:
alias test { 
  var %temp 1
  while ($read(test.txt, n, %temp)) {
    if (#speed=* iswm $v1) {
      var %speed $gettok($v2,2,61))
      var %n 0
    }    
    else {
      inc %n
      .timer -m 1 $calc(%speed * %n) echo -ta > $safe($v2)
    }
    inc %temp
  }
}
alias safe return $!decode( $encode($1-, m) ,m)
Note: I removed scripts\ from the path in $read()
I had this as my test.txt:
Quote:
A
#speed=2000
B
C
#speed=5000
D
E
Results were:
Quote:
[02:57:03] > A
[02:57:05] > B
[02:57:07] > C
[02:57:08] > D
[02:57:13] > E


Which is indeed not what you want laugh
After testing a bit, I think this is what you are looking for:
Code:
alias test { 
  var %temp 1,%speed 0,%0
  while ($read(test.txt, n, %temp)) {
    if (#speed=* iswm $v1) {
      var %speed $calc(%speed * %n + $gettok($v2,2,61))
      var %n 0
    }    
    else {
      inc %n
      .timer -m 1 $calc(%speed * %n) echo -ta > $safe($v2)
    }
    inc %temp
  }
}
alias safe return $!decode( $encode($1-, m) ,m)
Which resulted in:
Quote:
[03:03:22] > A
[03:03:24] > B
[03:03:26] > C
[03:03:31] > D
[03:03:40] > E
Don't forget to change "echo -ta >" back to "msg $nick" and to put back script\test.txt in $read()


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jul 2013
Posts: 9
I
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
I
Joined: Jul 2013
Posts: 9
Ok, not sure how this even goes in or gets activated. It suddenly changed from an event to an alias?


Always remember...
Joined: Jul 2006
Posts: 4,185
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,185
Sorry, I forgot I made it an alias to test easily, change
Quote:
alias test {
back to
Quote:
on *:TEXT:!test:?:{


#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard