mIRC Home    About    Download    Register    News    Help

Print Thread
#147564 20/04/06 04:32 PM
Joined: Jul 2005
Posts: 51
P
Babel fish
OP Offline
Babel fish
P
Joined: Jul 2005
Posts: 51
Hello! I'm planning to make a hangman script....

Code:
set %hangman.temp $read(hangman.txt)
set %hangman.hint $gettok(%hangman.temp,1,42)
set %hangman.answer $gettok(%hangman.temp,2,42)
var %tmp, %test = $regsub(%hangman.answer,/[1-9a-zA-Z]/gi,-,%tmp)
set %hangman.answer2 %tmp
 


Everything's ok so far.. now when someone does !hangman letter, it should replace "-" with the letter if it exists.. and I got stuck here....

In fact, I tried to get the position of the letter using $pos.. but I failed... can somebody help?

Thanks in advance.
Regards,
Chadi.


chadchoud @ DALnet
#147565 20/04/06 06:58 PM
Joined: Jul 2005
Posts: 51
P
Babel fish
OP Offline
Babel fish
P
Joined: Jul 2005
Posts: 51
Well I found it... looks a bit complicated eh? :P
Code:
alias replacemoo {
  var %tmp, %test = $regsub(%hangman.answer3,/[1-9a-zA-Z]/gi,-,%tmp)
  var %hangman.answer2 = %tmp
  var %a = 1
  var %b = $pos(%hangman.answer3,$1,0)
  while (%a <= %b) {
    var %firstpart = $mid(%hangman.answer2,0,$calc($pos($2-,$1,%a) - 1))
    if (%firstpart isnum) { var %firstpart = "" }
    var %lastpart = $mid(%hangman.answer2,$calc($pos($2-,$1,%a) + 1),$mid(%hangman.answer2,$calc($pos($2-,$1,%a) + 1),0))
    if (%lastpart isnum) { var %lastpart = "" }
    var %hangman.answer2 = %firstpart $+ $1 $+ %lastpart
    inc %a
  }
  return %hangman.answer2
} 


but There's a simple mistake... can you help now?

//echo -a $replacemoo(h,hi hthere) = h-h--h--
the space doesn't appear

#147566 20/04/06 07:17 PM
Joined: Jul 2005
Posts: 51
P
Babel fish
OP Offline
Babel fish
P
Joined: Jul 2005
Posts: 51
I helped myself :P
I replaced the space with a hard space $chr(160), then in the answer, I replaced it back.


chadchoud @ DALnet

Link Copied to Clipboard