This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

HighLow Repeat

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

HighLow Repeat

Post by ComputerTech »

Hey all so i am using the script game highlow

and it works perfect, but

i need it to repeat after someone guess's the right answer

so when someone gets it correct it will reset the guess to 1 - 100 again

Code: Select all


############################
## Set this to your nick. ##
############################

set hlownerofbot "ComputerTech"

############################################################
## Do NOT forget to set this to the name of your channel. ##
############################################################

set hlchan "#technet"

################################################################################################
## You can set this to the highest number you want to be able to guess from (default 100000). ##
################################################################################################

set highestnumber "100"

########################################################################################
## You can set this to the lowest number you want to be able guess from (default 10). ##
########################################################################################

set lowestnumber "1"

######################################################################
## Random messages the bot will use when you get the correct guess. ##
######################################################################

set correctmsgs {
  "Good job!"
  "Congratulations!"
  "Wowzers!"
  "Great Guess!"
  "Good work!"
  "Outstanding!"
  "Now win again!"
}

#########################################################################
## Random messages your bot will use when you make an incorrect guess. ##
#########################################################################

set incorrectmsgs {
  "Sorry"
  "Too bad,"
  "Try again,"
  "Incorrect guess,"
  "Keep trying"
}

######################################################
## You don't need to edit anything below this line. ##
######################################################

####################################
## Do NOT change these variables! ##
####################################

set hlonoroff 1
set hldeact 0
set hlinuse 0
set numbertouse ""
set correctnumber ""
set hlcreator "Justdabomb2"
set hlturnedoff "High Low has been turned off by"
set hlnoton "\0039High Low\0031 is not currently on."
set hlalreadyoff "\0039High Low\0031 is already off."
set hlinvalidguess "Your guesses must be bewteen"
set hlinvalidnumber "Please use a number between"
set hlalreadyon "\0039High Low\0031 is already on."
set hlnumberstoguess "\0031The numbers vary from\0033\002 0\002 \0031to\0037"
set hlturnedon "\0039High Low\00314 has been turned on by"
set hlnumbertoolow "won't use that number, it is too low."
set hltryhigher "Try a higher number."
set hlnumbertoohigh "won't use that number, it is too high."
set hltrylower "Try a lower number."
set hlguesscmd "Type \002!guess <number>\002"
set hlcmd "Type \002!hl on <number>.\002"
set hlhelpon "Turns the game on and tells the bot to pick a number between 0 and <number>."
set hlhelpoff "Turns the game off."
set hlhelpguess "Guesses <number> and tells you if your guess what too high or too low."
set hlhelpactivate "Activates the script so others can use it."
set hlhelpdeactivate "Deactivates the script so others can not use it."
set hldeactivated "\0039High Low\0031 has been deactivated. Ask $hlownerofbot to activate it."
set hlbeenactivated "\0039High Low\0031 has been activated."
set hlalreadyactivated "\0039High Low\0031 has already been activated."
set hlbeendeactivated "\0039High Low\0031 has been deactivated."
set hlalreadydeactivated "\0039High Low\0031 has already been deactivated."
set hlonlyinchan "\0039High Low\0031 is only played in"
set hloncmd "on"
set hloffcmd "off"
set hlhelpcmd "help"
set hlactivatecmd "activate"
set hldeactivatecmd "deactivate"

#############################
## These are the commands. ##
#############################

bind pub - !hl hl:setuse
bind pub - !guess hl:guess

######################################################################
## This is where the '!hl <command(s)>' part of the script starts.  ##
######################################################################

proc throttled {id seconds} {
	global throttle
	if {[info exists throttle($id)]&&$throttle($id)>[clock sec]} {
		set id 1
	} {
		set throttle($id) [expr {[clock sec]+$seconds}]
		set id 0
	}
}

bind time - ?0* throttledCleanup
proc throttledCleanup args {
	global throttle
	set now [clock sec]
	foreach {id time} [array get throttle] {
		if {$time<=$now} {unset throttle($id)}
	}
}


proc hl:setuse {nick uhost hand chan arg} {
  global hlinuse correctnumber hlcreator numbertouse highestnumber lowestnumber hlonoroff hlchan hlownerofbot hlcmd
  global hlguesscmd hlnumberstoguess hloncmd hloffcmd hlhelpcmd hlactivatecmd hldeactivatecmd hlinvalidnumber
  global hlnumbertoolow hlnumbertoohigh hlhelpon hlhelpoff hlhelpguess hlonlyinchan hlturnedoff hlbeenactivated
  global hlbeendeactivated hlturnedon hlalreadyon hlalreadyoff hldeactivated hldeact hlhelpactivate hlhelpdeactivate
  global hlalreadyactivated hlalreadydeactivated
  if { $hldeact == 1 } {
    set command [lindex $arg 0]
    if {[string tolower $command] == [string tolower $hlactivatecmd]} { 
      if {[string tolower $nick] == [string tolower $hlownerofbot]} {
        putquick "PRIVMSG $chan :$hlbeenactivated"
        set hlonoroff 1
        set hldeact 0
        } else {
        putquick "NOTICE $nick :Only $hlownerofbot can use this command."
      }
      return
    }
    if {[string tolower $command] == [string tolower $hldeactivatecmd]} { 
      if {[string tolower $nick] == [string tolower $hlownerofbot]} {
        putquick "PRIVMSG $chan :$hlalreadydeactivated"
        } else {
        putquick "NOTICE $nick :Only $hlownerofbot can use this command."
      }
      return
    }
  }
  if { $hlonoroff == 1 } {
    if {[string tolower $chan] == [string tolower $hlchan]} {
      set command [lindex $arg 0]
      if {$command == ""} {
        putquick "NOTICE $nick :\0030,1Type $hlcmd"
      }
      if {[string tolower $command] == [string tolower $hloncmd]} { 
        if { $hlinuse == 0 } {
          set numbertouse [lindex $arg 1]
          if {$numbertouse == ""} {
            putquick "NOTICE $nick :\0030,1Type $hlcmd"
            return
          }
          if {[string tolower $numbertouse] < [string tolower $lowestnumber]} { 
            putquick "NOTICE $nick :\0030,1$hlnumbertoolow $hlinvalidnumber $lowestnumber and $highestnumber."
            return
          }
          if {[string tolower $numbertouse] > [string tolower $highestnumber]} { 
            putquick "NOTICE $nick :\0030,1$hlnumbertoohigh $hlinvalidnumber $lowestnumber and $highestnumber."
            return
            } else {
            set hlinuse 1
            set correctnumber [rand $numbertouse]
            putquick "PRIVMSG $chan :\0039,1High Low\0038,14 By: $hlcreator" 
            putquick "PRIVMSG $chan :$hlturnedon \00310$nick\00314. $hlguesscmd to guess a number." 
            putquick "PRIVMSG $chan :$hlnumberstoguess \002$numbertouse\002\0031." 
          }
          } else {
          putquick "PRIVMSG $chan :$hlalreadyon"
        }
      }
      if {[string tolower $command] == [string tolower $hloffcmd]} { 
        if { $hlinuse == 1 } {
          set hlinuse 0
          set numbertouse ""
          putquick "PRIVMSG $chan :\0034$hlturnedoff \00310$nick."
          } else {
          putquick "PRIVMSG $chan :\0031$hlalreadyoff"
        }
      }
      if {[string tolower $command] == [string tolower $hlhelpcmd]} {
        if {[string tolower $nick] == [string tolower $hlownerofbot]} {
          putquick "NOTICE $nick :\0037,1\002!hl on <number> \002\0033,1- $hlhelpon"
          putquick "NOTICE $nick :\0037,1\002!hl off \002\0033,1- $hlhelpoff"
          putquick "NOTICE $nick :\0037,1\002!guess <number> \002\0033,1- $hlhelpguess"
          putquick "NOTICE $nick :\0037,1\002!hl activate \002\0033,1- $hlhelpactivate"
          putquick "NOTICE $nick :\0037,1\002!hl deactivate \002\0033,1- $hlhelpdeactivate"
          } else {
          putquick "NOTICE $nick :\0037,1\002!hl on <number> \002\0033,1- $hlhelpon"
          putquick "NOTICE $nick :\0037,1\002!hl off \002\0033,1- $hlhelpoff"
          putquick "NOTICE $nick :\0037,1\002!guess <number> \002\0033,1- $hlhelpguess"
        }
      }
      if {[string tolower $command] == [string tolower $hlactivatecmd]} { 
        if {[string tolower $nick] == [string tolower $hlownerofbot]} {
          putquick "PRIVMSG $chan :$hlalreadyactivated"
          } else {
          putquick "NOTICE $nick :\0030,1Only $hlownerofbot can use this command."
        }
      }
      if {[string tolower $command] == [string tolower $hldeactivatecmd]} { 
        if {[string tolower $nick] == [string tolower $hlownerofbot]} {
          putquick "PRIVMSG $chan :$hlbeendeactivated"
          set hlonoroff 0
          set hlinuse 0
          set hldeact 1
          set numbertouse ""
          set correctnumber ""
          } else {
          putquick "NOTICE $nick :\0030,1Only $hlownerofbot can use this command."
        }
      }
      } else {
      putquick "PRIVMSG $chan :$hlonlyinchan $hlchan"
    }
    } else {
    putquick "PRIVMSG $chan :$hldeactivated"
  }
}

#####################################################################
## This is where the '!guess <number>' part of the script starts.  ##
#####################################################################

proc hl:guess {nick uhost hand chan args} {
  global hlinuse correctnumber numbertouse lowestnumber hlchan hlonoroff hlownerofbot 
  global hldeactivated hltrylower hltryhigher hlnoton hlinvalidguess correctmsgs incorrectmsgs hlguesscmd
  if {[throttled $uhost,$chan 300]} {
  puthelp "PRIVMSG $chan :$nick: Only One Guess Per 5Min"
  return
  }
  set correctmsg [lindex $correctmsgs [rand [llength $correctmsgs]]]
  set incorrectmsg [lindex $incorrectmsgs [rand [llength $incorrectmsgs]]]
  if { $hlonoroff == 1 } {
    if {[string tolower $chan] == [string tolower $hlchan]} {
      if { $hlinuse == 1 } {
        set guess [lindex $args 0]
        if {$guess == ""} {
          putquick "NOTICE $nick :\0030,1$hlguesscmd"
          return
          } else {
          if { [string tolower $guess] == [string tolower $correctnumber] } {
            set hlinuse 0
            putquick "PRIVMSG $chan :\00310$nick\00313 got the correct guess of \002\00312$correctnumber\00313\002. $correctmsg"
            putserv "CHGHOST $nick  winner.guess.TechNet"
            putquick "privmsg $chan :!hs on 100"
          }
          if { [string tolower $guess] > [string tolower $numbertouse] } {
            putquick "NOTICE $nick :\0030,1$hlinvalidguess\0033,1\002 0\002 \0030,1and\0037,1 \002$numbertouse\002."
            return
          }
          if { [string tolower $guess] > [string tolower $correctnumber] } {
            	putquick "PRIVMSG $chan :\0037$incorrectmsg \00310$nick\0037. Your guess of \002$guess\002 was too \002high\002. $hltrylower"
          }
          if { [string tolower $guess] < [string tolower $correctnumber] } {
            	putquick "PRIVMSG $chan :\0033$incorrectmsg \00310$nick\0033. Your guess of \002$guess\002 was too \002low\002. $hltryhigher"
          }
        }
        } else {
        putquick "PRIVMSG $chan :\0031Sorry \00310$nick,\0031 $hlnoton"
      }
      } else {
      putquick "PRIVMSG $chan :$hlonlyinchan $hlchan."
    }
    } else {
    putquick "PRIVMSG $chan :$hldeactivated"
  }
}
any help appreciated 8)
ComputerTech
Post Reply