mIRC Homepage
Posted By: Cheech $mp3dir - 15/02/03 02:51 AM
i want to be able to change the $mp3dir within a running script my intention was to set it a a %var and then swap it to additional %vars but i couldnt seem to work that out i looked into the /writeini command but it say not to change it while in use ? is it not possible ?

my point for doing so is i have 4 mp3 folders and i want to switch from one to another on a random/continous play option
thx for any help you can offer smile
Posted By: Hammer Re: $mp3dir - 15/02/03 03:01 AM
Use %mp3dir instead of $mp3dir and set it for whatever directory you like. laugh
Posted By: Cheech Re: $mp3dir - 15/02/03 03:03 AM
oh man that never crossed my mind lol thx smile
Posted By: Cheech Re: $mp3dir - 15/02/03 05:01 AM
ok i got it working almost like i want except for i need to go back to the beging of a line instead of all the way back to the top of the alias ? how would i do that i have
Code:

alias contplay {
  set %mp3dir $rand(1,4)
  if ( %mp3dir == 1 ) { set %p3dir c:\documents and settings\desktop\skynyrd tunes\ }
  if ( %mp3dir == 2 ) { set %p3dir c:\documents and settings\desktop\motown\ }
  if ( %mp3dir == 3 ) { set %p3dir c:\documents and settings\desktop\tunes\ }
  if ( %mp3dir == 4 ) { set %p3dir c:\documents and settings\desktop\alternative\ }
  :top
  set %z 1
  set %rand $findfile(%p3dir,*.mp3,$rand(1,$findfile(%p3dir,*.mp3,*)))
  run -np %rand
  msg $active 1 $+ $chr(91) $+  $+ $rand(1,7) $+ Continuous-Play $+ 1 $+ $chr(93) 1 $&
    $+ $chr(91) $+  $+ $rand(1,7) $+ $nopath(%rand) $+ 1 $+ $chr(93)
  set %starttime $mp3(%rand).length / 1000
  inc %z
  .timersong 1 %starttime /contplay
  if ( %z > 10 ) {
    set %mp3dir $rand(1,4)
    goto top
  }
}

the problem is the the /contplay takes me all the way back to the top i need to go back to the beginning of the line any ideas i looked at /return and while loops but i didnt see it would fix my problem ?

can you set a timer on a goto command ? as in .timersong 1 %starttime goto mid
and then just add in a :mid ?

[EDIT: formatting changes only to fit the forum better]
Posted By: Cheech Re: $mp3dir - 15/02/03 05:28 AM
ok the .timer goto bit doesnt work ? that was my last idea
Posted By: Hammer Re: $mp3dir - 15/02/03 07:50 AM
I'm not understanding why you even have a goto at all! Your script should end when you start the timer to re-issue the /contplay command when the MP3 ends.
Posted By: keeker Re: $mp3dir - 15/02/03 08:11 AM
Are you wanting it to continue for 10 songs, then reset to 0? if so here is your code modified for that purpose without using goto:

Code:
 alias contplay {  
  if (%z < 10) {
    inc %z
    var %mp3dir $rand(1,4)  
    if ( %mp3dir == 1 ) { var %p3dir c:\audio-visual\audio\311 }  
    if ( %mp3dir == 2 ) { var %p3dir c:\audio-visual\audio\a-teens }  
    if ( %mp3dir == 3 ) { var %p3dir c:\audio-visual\audio\angels }  
    if ( %mp3dir == 4 ) { var %p3dir c:\audio-visual\audio\alabama }  
    var %rand $findfile(%p3dir,*.mp3,$rand(1,$findfile(%p3dir,*.mp3,0)))
    run -np %rand 
    msg $active 1 $+ $chr(91) $+  $+ $rand(1,7) $+ Continuous-Play $+ 1 $+ $chr(93) $&
      1 $+ $chr(91) $+  $+ $rand(1,7) $+ $nopath(%rand) $+ 1 $+ $chr(93) 
    var %starttime $mp3(%rand).length / 1000
    .timersong 1 %starttime contplay  
  }
  else set %z 0
}
 
this will keep playing songs untill %z reaches 10, and then it resets %z to 0. If this isnt what ya want, please try explainin what yer trying to do smile

p.s. please disregard my music selection :0 i knwo i have bad tastes smile

[edit]
i changed your global variables (/set) to temp variables (/var) bacause I didnt see any need to have global variables, other than %z which is set when you inc %z, in an alias like this. Also rand(1,$findfile(%p3dir,*.mp3,*)) i changed to rand(1,$findfile(%p3dir,*.mp3,0))
Posted By: Cheech Re: $mp3dir - 16/02/03 12:38 AM
ok you almost got what i want i want to inc %z to 10 when
%z is greater than 10 i want to reset the directory then play ten songs from that directory and switch again th point of the goto in answer to Hammer's Question was supposed to do that but obviously it doesnt ? hope that helps make sense of it thx for the help smile


ok i think i got it
Code:
 

alias contplay {  
  if ( %mp3dir == 1 ) { set %p3dir c:\documents and settings\desktop\skynyrd tunes\ }
  if ( %mp3dir == 2 ) { set %p3dir c:\documents and settings\desktop\motown\ }
  if ( %mp3dir == 3 ) { set %p3dir c:\documents and settings\desktop\tunes\ }
  if ( %mp3dir == 4 ) { set %p3dir c:\documents and settings\desktop\alternative\ }
  set %rand $findfile(%p3dir,*.mp3,$rand(1,$findfile(%p3dir,*.mp3,*)))
  run -np %rand
  msg $active 1 $+ $chr(91) $+  $+ $rand(1,7) $+ Continuous-Play $+ 1 $+ $chr(93) 1 $&
    $+ $chr(91) $+  $+ $rand(1,7) $+ $nopath(%rand) $+ 1 $+ $chr(93) 
  set %starttime $mp3(%rand).length / 1000
  inc %z
  .timersong 1 %starttime /contplay
  if ( %z > 10 ) {
    set %z 0
    set %mp3dir $rand(1,4)
    .timersong off
     /contplay 
  }
}

not sure if it works i havent gotten to 10 yet but that might better explain what i wanted and i took out the goto smile

[EDIT: RE-formatted, yet again, the long line to better fit the forum.

Cheech: there is no reason to post long lines like that; they simply mess up the formatting of the forum, making anything with a long reply line require users to use the horizontal scroll bar. Since your long line is just a series of commands, putting each command on a separate line only makes sense. How you actually store it in your mIRC editor is entirely up to you.

-Hammer]
Posted By: Cheech Re: $mp3dir - 16/02/03 01:21 AM
ok i took out that last /contplay that was unnecessary and its workin fine i have one more question and then i will be finished with it
every so often you run accross a file that doesnt play and you get this error
* /run: unable to open 'c:\documents and settings\desktop\motown\Motown Smokey Robinson - you really got a hold on me.mp3' (line 6, script4)

is there anyway to make it keep going when that happens as it is scripted currently it halts the script when that happens ? thx smile
Posted By: Nimue Re: $mp3dir - 16/02/03 01:25 AM
Code:
alias contplay {
  if !$1 {
    var %a = $rand(1,4)
    if %a == 1 { set %p3dir c:\documents and settings\desktop\skynyrd tunes\ }
    if %a == 2 { set %p3dir c:\documents and settings\desktop\motown\ }
    if %a == 3 { set %p3dir c:\documents and settings\desktop\tunes\ }
    if %a == 4 { set %p3dir c:\documents and settings\desktop\alternative\ }  }
  }
  var %b = $findfile(%p3dir,*.mp3,$r(1,$findfile(%p3dir,*.mp3,0)),run -np $1-)
  msg $active $+(1[,$r(1,7),Continuous-Play1] [,$base($r(1,7),10,10,2),$nopath(%b),1])
  .timersong 1 $calc($mp3(%rand).length / 1000) contplay $calc(($1 + 1) % 10)
}
Posted By: Cheech Re: $mp3dir - 16/02/03 01:37 AM
can you explain what you changed i'm not sure i c what you did ?
Posted By: Nimue Re: $mp3dir - 16/02/03 02:10 AM
Firstly, the temporary /vars now have shorter names smile
Code:
alias contplay {
  if !$1 {

  [color:green]; If the command was simply "contplay" or "contplay 0", the above is $true, and we set the directory[/color]

    var %a = $rand(1,4)
    if %a == 1 { set %p3dir c:\documents and settings\desktop\skynyrd tunes\ }
    if %a == 2 { set %p3dir c:\documents and settings\desktop\motown\ }
    if %a == 3 { set %p3dir c:\documents and settings\desktop\tunes\ }
    if %a == 4 { set %p3dir c:\documents and settings\desktop\alternative\ }  }
  }
  [color:green]; else we have jumped to here


  ; $r(N,N) is a shortened version of $rand(N,N)
  ; next line is the same except the /run -np 'filename' is moved into the $findfile()[/color]

  var %b = $findfile(%p3dir,*.mp3,$r(1,$findfile(%p3dir,*.mp3,0)),run -np $1-)

  [color:green]; next line is the same except using $+() instead of bulk "$+" ;s and "$chr()" 's[/color]

  msg $active $+(1[,$r(1,7),Continuous-Play1] [,$base($r(1,7),10,10,2),$nopath(%b),1])

  [color:green]; next we will set the timer to repeat
  ; adding the iteration; eg contplay 1, 2, 3,.., 9, 0
  ; $calc(($1 +1) % 10) = $null/0 add 1 and then % (modulo) 10, to result in
  ; 1 2 3 4 5 6 7 8 9 and finally, 9 + 1 % 10 = 0 again, so the dir will be reset[/color]

  .timersong 1 $calc($sound(%b).length / 1000) contplay $calc(($1 + 1) % 10)
}


edit--
Changed the last line to use $sound instead of $mp3, and also to use the %b var instead of %rand
Posted By: Cheech Re: $mp3dir - 16/02/03 02:17 AM
ok i hate to be a bother just trying to learn as i go ? by putting the $+( then all this stuff ) it makes it so i dont have to use the $chr() ? and by changing up the /run that takes care of the error *unable to run etc..... ? if thats all true then i understand that part but i still dont understand the $base identifier i looked in the help but unfortunaly that didnt make any sense ?
Posted By: Nimue Re: $mp3dir - 16/02/03 02:26 AM
The error may be caused by double spaces in the filename.
You could change
var %b = $findfile(%p3dir,*.mp3,$r(1,$findfile(%p3dir,*.mp3,0)),run -np $1-)
to
var %b = $findfile(%p3dir,*.mp3,$r(1,$findfile(%p3dir,*.mp3,0)),run -np $1-).shortfn
to see if it helps.
© mIRC Discussion Forums