| View previous topic :: View next topic |
| Author |
Message |
primus Voice
Joined: 31 Jul 2015 Posts: 12 Location: West Coast
|
Posted: Mon Aug 03, 2015 12:43 am Post subject: slots.tcl - Slot Machine for your Eggy |
|
|
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: |
#################################################################
# --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... |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Tue Aug 04, 2015 1:33 am Post subject: |
|
|
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: |
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. |
|
| Back to top |
|
 |
primus Voice
Joined: 31 Jul 2015 Posts: 12 Location: West Coast
|
Posted: Tue Aug 04, 2015 12:15 pm Post subject: |
|
|
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: |
proc spin {count} {
|
so changed it to...
| Code: |
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... |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|