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.

slots.tcl - Slot Machine for your Eggy

Support & discussion of released scripts, and announcements of new releases.
Post Reply
p
primus
Voice
Posts: 12
Joined: Fri Jul 31, 2015 10:43 pm
Location: West Coast

slots.tcl - Slot Machine for your Eggy

Post by primus »

Its been reworked once prior to myself... It now works with eggdrop1.6.X, not sure about earlier version... Let me know if anything needs fixed in the script or if it works with earlier eggdrop versions... And please post in the topic of the forum.... More info after code...

Code: Select all

#################################################################
#             --The Ultimate eggdrop Slot Machine --  
#            slots.tcl v3.0 by Pr|muS@Undernet 8/2/2015
#
#               For eggdrop1.6.X and maybe older...
#
#              In Honor of MC_8 (Carl M. Gregory)
#                We need you back on IRC buddy!
#
#           DO NOT Distribute this TCL in any edited form
#             without the existing revision history!!!
#                            
#
#################################################################  
#  v3.0 by Pr|muS@Undernet
#
#  v3.0 Changes (8/2/2015)
#  - Shortened output to keep from flooding
#  - Removed set botnick "$botnick"
#    (Was causing crash on startup)
#  - Added channel set (Single Channel Only)
#  - Added option to change !Trigger
#  - Removed "Hearts" and added "Diamond" & "Seven" to reels
#
#  v2.0 Changes (11/15/97) by Chuck Jedlicka
#    (jcme1@hotmail.com)
#  - Changed output to channel
#  - Added message funtionality so your users 
#    don't tie up the channel.
#  - Added prizes and more...
#  
#  v1.0 Original Code (6/22/97) by Lorna MacTavish
#   (macgirl@poboxes.com)
#
#  This is a slot machine proc for your eggdrop bot
#  Tested on eggdrop1.6.21
###############################################################


#Settings

#Set the channel to play in. ex: set slotchan "#playslots"
set slotchan "#underground"

#Set the public channel comand to pull the lever ex:"!spin"
set lever "!spin"
##############################################################
#Do Not Edit below this line unless you know TCL!!!
##############################################################


set slots {
  "Lemon"
  "Orange"
  "Cherry"
  "Lime"
  "Bar"
  "Bell"
  "Seven"
  "Diamond"
}

bind pub - $lever play_slots

proc play_slots {nick uhost handle chan args} {
  global slotchan
  if {$chan == $slotchan} {
  putserv "PRIVMSG $slotchan :<<$nick>> puts a quarter in the slot machine, pulls the lever, The reels are spinning... coming to a stop..."
  global slots botnick lever
  set slot1 [lindex $slots [rand [llength $slots]]]
  set slot2 [lindex $slots [rand [llength $slots]]]
  set slot3 [lindex $slots [rand [llength $slots]]]
  putserv "PRIVMSG $slotchan :| $slot1 | $slot2 | $slot3 |"
  if {$slot1 == $slot2} {
    if {$slot2 == $slot3} {
      putserv "PRIVMSG $slotchan :Congratulations! $nick  You hit the Jackpot!  \$500 !! =)"
      putserv "PRIVMSG $slotchan :Hey everyone! $nick Just hit the Jackpot!"
      putserv "NOTICE  $nick :Don't ya wish it were Real!!  lmfao! :P"
      return 1
     }
     putserv "PRIVMSG $slotchan :Aww Shucks $nick, :(  2 out of 3 only pays \$50 !  =)"
     putserv "NOTICE  $nick :Too bad it's only on IRC... like your other \"scores\" :P"
    return 1
  }
  if {$slot3 == $slot2} {
    if {$slot2 == $slot1} {
      putserv "PRIVMSG $slotchan :Congratulations! $nick  You hit the Jackpot! \$500 !! =)"
      putserv "PRIVMSG $slotchan :Hey everyone! $nick Just hit the Jackpot!"
      putserv "notice  $nick :Don't ya wish it were Real!!  lmfao! :P"	
      return 1
    }
    putserv "PRIVMSG $slotchan :Not too shabby $nick  you just won \$50 !  =)"
    putserv "NOTICE  $nick :Too bad it's only on IRC... like your other \"scores\" :P"
    return 1
  }
  if {$slot1 == $slot3} {
    if {$slot2 == $slot1} {
      putserv "PRIVMSG $slotchan :Congratulations! $nick  You hit the Jackpot!  \$500 !! =)"
      putserv "PRIVMSG $slotchan :Hey everyone! $nick Just hit the Jackpot!"
      putserv "NOTICE  $nick :Don't ya wish it were Real!!  lmfao! :P"
      return 1
    }
    putserv "PRIVMSG $slotchan :Getting close there $nick,  outside matches pay \$25 ! =)"
    putserv "NOTICE  $nick :Too bad its like your other \"SCORES\" on IRC  :P"
    return 1
  }
  putserv "PRIVMSG $slotchan :Sorry $nick not everyone can be a winner.  Better luck next time, Chump!"
  putserv "NOTICE  $nick :You can also play in private!  Use /msg $botnick $lever Good Luck!"
   return 1
 }
}

bind msg - $lever play_slotsm
proc play_slotsm {nick uhost handle chan args} {
  putserv "PRIVMSG $nick :<<$nick>> puts a quarter in the slot machine, pulls the lever, The reels are spinning... coming to a stop..."
  putserv "PRIVMSG $nick :<<$nick>> is feeling mighty lucky today!"
  global slots
  set slot1 [lindex $slots [rand [llength $slots]]]
  set slot2 [lindex $slots [rand [llength $slots]]]
  set slot3 [lindex $slots [rand [llength $slots]]]
  putserv "PRIVMSG $nick :| $slot1 | $slot2 | $slot3 |"
  if {$slot1 == $slot2} {
    if {$slot2 == $slot3} {
      putserv "PRIVMSG $nick :Congratulations! $nick  You hit the jackpot!  \$500 !! =)"
      putserv "PRIVMSG $nick :Hey everyone! $nick Just hit the Jackpot!"
      putserv "PRIVMSG $nick :Don't ya wish it were Real!!  lmfao! :P"
      return 1
     }
     putserv "PRIVMSG $nick :Aww Shucks $nick, :(  2 out of 3 only pays \$50 !  =)"
     putserv "PRIVMSG $nick :Too bad it's only on IRC... like your other \"scores\" :P"
    return 1
  }
  if {$slot3 == $slot2} {
    if {$slot2 == $slot1} {
      putserv "PRIVMSG $nick :Congratulations! $nick  You hit the Jackpot! \$500 !! =)"
      putserv "PRIVMSG $nick :Hey everyone! $nick Just hit the Jackpot!"
      putserv "PRIVMSG $nick :Don't ya wish it were Real!!  lmfao! :P"	
      return 1
    }
    putserv "PRIVMSG $nick :Not too shabby $nick  you just won \$50 !  =)"
    putserv "PRIVMSG $nick :Too bad it's only on IRC... like your other \"scores\" :P"
    return 1
  }
  if {$slot1 == $slot3} {
    if {$slot2 == $slot1} {
      putserv "PRIVMSG $nick :Congratulations! $nick  You hit the Jackpot!  \$500 !! =)"
      putserv "PRIVMSG $nick :Hey everyone! $nick Just hit the Jackpot!"
      putserv "PRIVMSG $nick :Don't ya wish it were Real!!  lmfao! :P"
      return 1
    }
    putserv "PRIVMSG $nick :Getting close there $nick,  outside matches pay \$25 ! =)"
    putserv "PRIVMSG $nick :Too bad its like your other \"SCORES\" on IRC  :P"
    return 1
  }
  putserv "PRIVMSG $nick :Sorry $nick not everyone can be a winner.  Better luck next time, Chump!"
  putserv "PRIVMSG $nick :Thanks for playing privately!  Your fellow channel members appreciate it! =)"
   return 1
 }



putlog "Slots 3.0 by Pr|muS@Undernet loaded succesfully"
I'm still new to TCL, in fact this is my first release of an older .tcl...

It still needs flood protection as it could easily post a lot of text to the channel and in PRVMSG..

A timer to throttle responses would be great and if anyone happens to add it, please PM me the entire edited code so I can add you to the revision history...
w
willyw
Revered One
Posts: 1197
Joined: Thu Jan 15, 2009 12:55 am

Re: slots.tcl - Slot Machine for your Eggy

Post by willyw »

primus wrote:
....
A timer to throttle responses would be great and if anyone happens to add it,...

Here is a command throttle for you to check out:

http://forum.egghelp.org/viewtopic.php?p=45537#45537

and

http://forum.egghelp.org/viewtopic.php?p=75097#75097


I hope this helps.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Here's my attempt at this slots game, but did only the "channel" part, replaced that set slotchan "#underground" with a channel flag so could run this on multiple channels and activate or deactivate it from party line (DCC chat/telnet with the bot) via .chanset +slots or .chanset -slots

Code: Select all

namespace eval slots {

	set slots {
			"Lemon"
			"Orange"
			"Cherry"
			"Lime"
			"Bar"
			"Bell"
			"Seven"
			"Diamond"
	}

	set lever "!spin"
	setudef flag slots
	bind pub - $lever [namespace current]::play

	proc play {nick uhost hand chan text} {
		if {![channel get $chan slots]} return
		set result [spin 3]
		foreach word [split $result] {
			incr count($word)
		}
		puthelp "PRIVMSG $chan :<<$nick>> puts a quarter in the slot machine, pulls the lever, The reels are spinning... coming to a stop..." 
		puthelp "PRIVMSG $chan :| [join [split $result] " | "] |"
		switch -- [llength [array names count]] {
			"1" {
				puthelp "PRIVMSG $chan :Congratulations! $nick  You hit the Jackpot!  \$500 !! =)"
				puthelp "PRIVMSG $chan :Hey everyone! $nick Just hit the Jackpot!"
			}
			"2" {
				puthelp "PRIVMSG $chan :Aww Shucks $nick, :(  2 out of 3 only pays \$50 !  =)"
			}
			"3" {
				puthelp "PRIVMSG $chan :Sorry $nick not everyone can be a winner.  Better luck next time, Chump!"
			}
		}
	}
		
	proc spin {count} {
		variable slots
		set len [llength $slots]
		for {set x 0} {$x<$count} {incr x} {
			lappend result [lindex $slots [rand $len]]
		}
		return $result
	}
}
There's even room to extend it, meaning instead of 3 slots can have 4 or even 5. Would just need to add more lines under the "switch" :)

You could add user's throttled proc from the first link willyw kindly gave to you to prevent a flood on the bot. I'm too busy with work to finish the code right now.
Once the game is over, the king and the pawn go back in the same box.
p
primus
Voice
Posts: 12
Joined: Fri Jul 31, 2015 10:43 pm
Location: West Coast

Post by primus »

Thanks Caesar,

Did a test run with it, but got this:

[08:59:47] Tcl error [::slots::play]: can't read "slots": no such variable

so looked through the code and noticed this..

Code: Select all

proc spin {count} {
so changed it to...

Code: Select all

proc slots {count} {
After the change, worked flawless...

When I get time, which most of us dont have a lot of now, I will recode with the changes... I still got to look at the links from willyw to check out throttling...
Post Reply