mIRC Home    About    Download    Register    News    Help

Print Thread
hangman [Twitch] #260059 25/02/17 12:27 AM
Joined: Jan 2016
Posts: 79
X
x3pos Offline OP
Babel fish
OP Offline
Babel fish
X
Joined: Jan 2016
Posts: 79
Code:
alias hc1 { return 03 }
alias hc2 { return 12 }
on *:Text:!*:#:{ do.hang $1- }
on *:Input:#:{ if ((.* iswm $1) || (!* iswm $1)) { do.hang ! $+ $right($1-,-1) } }
alias do.hang {
  if (($1 == !hangman) && (!$hget(hangman))) {
    hmake hangman 10
    hadd hangman word $read(hangman.txt)
    hadd hangman chan $chan
    hadd hangman man $iif($2 ison $chan, $2, $nick($chan, $rand(1,$nick($chan,0))))
    hmsg $msg.hang.start
  }
  if (!$hget(hangman)) { return }
  if ($1 == !hang) {
    if (($2 !isalpha) || ($len($2) != 1)) {
      hmsg $hc1 $+ You gotta pick a letter moron.
      return 
    }
    elseif ($hget(hangman,Picked. $+ $2)) {
      hmsg $hc1 $+ Idiot... Try picking a letter that somebody else hasn't picked.
      return
    }
    else {
      hadd hangman Picked. $+ $2 1
      if ($2 isin $hget(hangman,word)) { 
        hmsg $msg.hang.right
        hang.checkwin
      }
      else { 
        var %hang.part = $hang.part
        hmsg $msg.hang.wrong(%hang.part)
      }
    }
  }
}
alias hang.part {
  hadd hangman wrong $calc($hget(hangman, wrong) + 1)
  if ($hang.partname($hget(hangman, wrong)) == hanging) {
    hmsg $msg.hang.dead
    hfree hangman
    halt
  }
  return $hang.partname($hget(hangman, wrong))
}
alias hang.checkwin {
  if ($hang.got != $hget(hangman,word)) { return }
  hmsg $msg.hang.save
  hfree hangman
  halt
}
alias hang.partname { return $gettok(a head;a neck;torso;arms;hands;legs;feet;hanging, $1, $asc(;)) }
alias hang.got {
  var %i = 1,%hang.got = $hget(hangman, word)
  unset %hang.left
  while (%i <= 26) {
    if (!$hget(hangman, Picked. $+ $chr($calc(96 + %i)))) { 
      %hang.got = $replace(%hang.got, $chr($calc(96 + %i)), @) 
      set -u120 %hang.left %hang.left $+ $chr($calc(96 + %i)) 
    }
    inc %i
  }
  return %hang.got
}
alias hmsg { msg $$hget(hangman,chan) $1- }
alias msg.hang.clue { return $hc1 $+ Current clue: $hc2 $+ $hang.got $hc1 $+ Letters remaining: $hc2 $+ %hang.left }
alias msg.hang.save { return $hc2 $+ $hget(hangman,man) $+ $hc1 is saved! You're the best channelmates a person could want. }
alias msg.hang.dead { return $hc2 $+ $hget(hangman,man) $+ $hc1 is DEAD! You all suck. Word: $hc2 $+ $hget(hangman,word) }
alias msg.hang.wrong { return $hc1 $+ Smooth gimp! One step closer to dead. You just got $hc2 $+ $hget(hangman, man) $+ $hc1 $+ : $+ $hc2 $1 $+ $hc1 $+ ! $msg.hang.clue }
alias msg.hang.right { return $hc1 $+ Well done, $hc2 $+ $nick $+ $hc1 $+ ! You picked a winning letter. $msg.hang.clue }
alias msg.hang.start { return $hc1 $+ Get ready for some hangman... We are hanging $hc2 $+ $hget(hangman,man) $+ $hc1 $+ , unless you can prevent it. $hc2 $+ !hang <letter> $+ $hc1 to guess a letter. $msg.hang.clue }


This is working but how to delete color codes. i want this for twitch chat.

Re: hangman [Twitch] [Re: x3pos] #260060 25/02/17 02:22 AM
Joined: Oct 2015
Posts: 112
B
Blas Offline
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2015
Posts: 112
I did a quick search and replace for the aliases with the color codes and deleted all instances of the aliases in the script... hopefully this works, haven't tested it.

Code:
on *:Text:!*:#:{ do.hang $1- }
on *:Input:#:{ if ((.* iswm $1) || (!* iswm $1)) { do.hang ! $+ $right($1-,-1) } }
alias do.hang {
  if (($1 == !hangman) && (!$hget(hangman))) {
    hmake hangman 10
    hadd hangman word $read(hangman.txt)
    hadd hangman chan $chan
    hadd hangman man $iif($2 ison $chan, $2, $nick($chan, $rand(1,$nick($chan,0))))
    hmsg $msg.hang.start
  }
  if (!$hget(hangman)) { return }
  if ($1 == !hang) {
    if (($2 !isalpha) || ($len($2) != 1)) {
      hmsg $+ You gotta pick a letter moron.
      return 
    }
    elseif ($hget(hangman,Picked. $+ $2)) {
      hmsg $+ Idiot... Try picking a letter that somebody else hasn't picked.
      return
    }
    else {
      hadd hangman Picked. $+ $2 1
      if ($2 isin $hget(hangman,word)) { 
        hmsg $msg.hang.right
        hang.checkwin
      }
      else { 
        var %hang.part = $hang.part
        hmsg $msg.hang.wrong(%hang.part)
      }
    }
  }
}
alias hang.part {
  hadd hangman wrong $calc($hget(hangman, wrong) + 1)
  if ($hang.partname($hget(hangman, wrong)) == hanging) {
    hmsg $msg.hang.dead
    hfree hangman
    halt
  }
  return $hang.partname($hget(hangman, wrong))
}
alias hang.checkwin {
  if ($hang.got != $hget(hangman,word)) { return }
  hmsg $msg.hang.save
  hfree hangman
  halt
}
alias hang.partname { return $gettok(a head;a neck;torso;arms;hands;legs;feet;hanging, $1, $asc(;)) }
alias hang.got {
  var %i = 1,%hang.got = $hget(hangman, word)
  unset %hang.left
  while (%i <= 26) {
    if (!$hget(hangman, Picked. $+ $chr($calc(96 + %i)))) { 
      %hang.got = $replace(%hang.got, $chr($calc(96 + %i)), @) 
      set -u120 %hang.left %hang.left $+ $chr($calc(96 + %i)) 
    }
    inc %i
  }
  return %hang.got
}
alias hmsg { msg $$hget(hangman,chan) $1- }
alias msg.hang.clue { return Current clue: $hang.got  $+ Letters remaining: %hang.left }
alias msg.hang.save { return $hget(hangman,man) $+  is saved! You're the best channelmates a person could want. }
alias msg.hang.dead { return $hget(hangman,man) $+  is DEAD! You all suck. Word: $hget(hangman,word) }
alias msg.hang.wrong { return Smooth gimp! One step closer to dead. You just got $hget(hangman, man) $+ $+ : $+ $1 $+ ! $msg.hang.clue }
alias msg.hang.right { return Well done, $nick $+  $+ ! You picked a winning letter. $msg.hang.clue }
alias msg.hang.start { return Get ready for some hangman... We are hanging $hget(hangman,man) $+  $+ , unless you can prevent it. !hang <letter> to guess a letter. $msg.hang.clue }

Re: hangman [Twitch] [Re: Blas] #260065 25/02/17 09:29 AM
Joined: May 2015
Posts: 249
splinny Offline
Fjord artisan
Offline
Fjord artisan
Joined: May 2015
Posts: 249
There is no color code support at Twitch IRC, so no problem. (You can see colors only in your own IRC client, other users will not)


Dont give a fish - teach to fish!