HangMan

By josiah on Jun 27, 2004

Its A very cool snipet type !hangman to start and it will explain the rest.

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 }

Comments

Sign in to comment.
b0sse   -  Jun 16, 2009

decent script.

could use a !word trigger though, if you figure out the entire word and wanna guess at it, instead of having to type word for word all the way out

 Respond  
Eugenio   -  Aug 02, 2008

Different colours
rofl but still.....

 Respond  
JonB_   -  Aug 02, 2008

This guy doesnt know how to script he just stole this one from http://www.snippets.chat4all-worldwide.co.uk/Hangman.html

 Respond  
piratedninja   -  Mar 29, 2008

wow! i love this!

2 questions though, how do i end the game without having to finish guessing?

and how can i make it so the user can guess the entire word?

 Respond  
Sasuke   -  Mar 23, 2007

Kwabam! Awesome. :D

 Respond  
DrPlebb   -  Jul 25, 2004

if $2- = $hget(hangman,word) {

 Respond  
Controversy   -  Jul 19, 2004

can you write an !answer type option so you don\'t have to go through all the letter... it\'s quite fun, folks on my chan enjoy, especially since you create the clues yourself

 Respond  
ShowstoppeR   -  Jul 01, 2004

it works only for me once

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.