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.

help with add

Help for those learning Tcl or writing their own scripts.
Post Reply
m
monie089
Halfop
Posts: 76
Joined: Sat Jul 29, 2006 11:13 pm

help with add

Post by monie089 »

Code: Select all

########################################
#tested to work on windrop             #
#v1.0 soon to be more updated          #
#email me for comments ,hate , or help #
#monie @ XG.Monie089@gmail.com         #
########################################
set wififile "wifi/wifi.txt"
set mphfile "wifi/mph.txt"
set mkdsfile "wifi/mkds.txt"
set acwwfile "wifi/acww.txt"
set thasfile "wifi/thas.txt"
set starfoxfile "wifi/starfox.txt"
if {![file exists $wififile]} {
   catch {close [open $wififile w]}
}
if {![file exists $mphfile]} {
   catch {close [open $mphfile w]}
}
if {![file exists $mkdsfile]} {
   catch {close [open $mkdsfile w]}
}
if {![file exists $acwwfile]} {
   catch {close [open $acwwfile w]}
}
if {![file exists $thasfile]} {
   catch {close [open $thasfile w]}
}
if {![file exists $starfoxfile]} {
   catch {close [open $starfoxfile w]}
}
bind pub -|- &wifi pub:wifi
proc pub:wifi {nickname uhost hostname  arguments handle  } {
putquick "PRIVMSG $nickname :Welcome to The WiFi Gaming Center"
putquick "PRIVMSG $nickname :Games Currently supported are"
putquick "PRIVMSG $nickname :MKDS MPH THAS ACWW STARFOX More coming soon"
putquick "PRIVMSG $nickname :Commands are as Following"
putquick "PRIVMSG $nickname :&list - lists the current games open"
putquick "PRIVMSG $nickname :&join <name> - Joins the game thats open"
putquick "PRIVMSG $nickname :&create <name> -creates a game"
putquick "PRIVMSG $nickname :&leave <name> - Parts you from that game"
putquick "PRIVMSG $nickname :&add - adds your code for any game"
putquick "PRIVMSG $nickname :&find - finds you or a friends code"
}
bind pub -|- &add pub:add
proc pub:add {nick uhost hostname text arg handle channel } {
global mphfile mkdsfile thasfile acwwfile starfoxfile
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="mph"&& $code !=""} {
set fd [open $::mphfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="mkds"&& $code !=""} {
set fd [open $::mkdsfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="acww"&& $code !=""} {
set fd [open $::acwwfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="thas"&& $code !=""} {
set fd [open $::thasfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="starfox"&& $code !=""} {
set fd [open $::starfoxfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
}
bind pub -|- &find pub:find
proc pub:find {nick uhost hand chan arg} {
global mphfile mkdsfile thasfile acwwfile starfoxfile
set name [lindex [split $arg] 0]
if {$name != ""} {
set fd [open $::mphfile r]
while {! [eof $fd]} {
lappend list [gets $fd]
}
close $fd
if {[set le [lsearch -glob $list "*$name*"]] != -1} {
set line [lindex $list $le]
set code [string map {"" ""} [lindex $line 2]]
putserv "NOTICE $nick :$names mphcode is $code"
} else { 
putserv "NOTICE $nick :Name not found."
}
} else {
putserv "NOTICE $nick :Usage: &find nick"
}
set name [lindex [split $arg] 0]
if {$name != ""} {
set fd [open $::mkdsfile r]
while {! [eof $fd]} {
lappend list [gets $fd]
}
close $fd
if {[set le [lsearch -glob $list "*$name*"]] != -1} {
set line [lindex $list $le]
set code [string map {"" ""} [lindex $line 2]]
putserv "NOTICE $nick :$names mkdscode is $code"
} else { 
putserv "NOTICE $nick :Name not found."
}
} else {
putserv "NOTICE $nick :Usage: &find nick"
}
set name [lindex [split $arg] 0]
if {$name != ""} {
set fd [open $::thasfile r]
while {! [eof $fd]} {
lappend list [gets $fd]
}
close $fd
if {[set le [lsearch -glob $list "*$name*"]] != -1} {
set line [lindex $list $le]
set code [string map {"" ""} [lindex $line 2]]
putserv "NOTICE $nick :$names thascode is $code"
} else { 
putserv "NOTICE $nick :Name not found."
}
} else {
putserv "NOTICE $nick :Usage: &find nick"
}
set name [lindex [split $arg] 0]
if {$name != ""} {
set fd [open $::acwwfile r]
while {! [eof $fd]} {
lappend list [gets $fd]
}
close $fd
if {[set le [lsearch -glob $list "*$name*"]] != -1} {
set line [lindex $list $le]
set code [string map {"" ""} [lindex $line 2]]
putserv "NOTICE $nick :$names acwwcode is $code"
} else { 
putserv "NOTICE $nick :Name not found."
}
} else {
putserv "NOTICE $nick :Usage: &find nick"
}
set name [lindex [split $arg] 0]
if {$name != ""} {
set fd [open $::starfoxfile r]
while {! [eof $fd]} {
lappend list [gets $fd]
}
close $fd
if {[set le [lsearch -glob $list "*$name*"]] != -1} {
set line [lindex $list $le]
set code [string map {"" ""} [lindex $line 2]]
putserv "NOTICE $nick :$names starfoxcode is $code"
} else { 
putserv "NOTICE $nick :Name not found."
}
} else {
putserv "NOTICE $nick :Usage: &find nick"
}
}
bind pub -|- &create pub:create
proc pub:create { nick uhost hand chan arg } {
set table [lindex [split $arg] 0]
if {$table != ""} {
set fd [open $::wififile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end] == ""} {
set list [lreplace $list end end]
}
lappend list "\[$table\]"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &create game."
}
}

everything works but the add and how do i make the join leave and list part please help
Last edited by monie089 on Mon Aug 14, 2006 10:20 am, edited 1 time in total.
New server irc.NintendoXG.com come and visit
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

sigh.

also, why does it say "100% made by monnie" when half or more of this ''script'' has been made by others here.
m
monie089
Halfop
Posts: 76
Joined: Sat Jul 29, 2006 11:13 pm

Post by monie089 »

i did this
New server irc.NintendoXG.com come and visit
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

get rid of the [close [open]] nonsense and read here how you should deal with files
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
m
monie089
Halfop
Posts: 76
Joined: Sat Jul 29, 2006 11:13 pm

Post by monie089 »

ok thanks
EDIT:it still says TCL [pub:add]: missing close bracket

Code: Select all

bind pub -|- &add pub:add
proc pub:add {nick uhost hostname text arg handle channel } {
global mphfile mkdsfile thasfile acwwfile starfoxfile
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="mph"&& $code !=""} {
set fd [open $::mphfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="mkds"&& $code !=""} {
set fd [open $::mkdsfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="acww"&& $code !=""} {
set fd [open $::acwwfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="thas"&& $code !=""} {
set fd [open $::thasfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="starfox"&& $code !=""} {
set fd [open $::starfoxfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
}
thats what im having trouble with please help
New server irc.NintendoXG.com come and visit
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

It would be helpful if you tabinate.. This is unreadable as it is.
m
monie089
Halfop
Posts: 76
Joined: Sat Jul 29, 2006 11:13 pm

Post by monie089 »

rosc2112 wrote:It would be helpful if you tabinate.. This is unreadable as it is.
what do you mean by tabinate
New server irc.NintendoXG.com come and visit
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

m
monie089
Halfop
Posts: 76
Joined: Sat Jul 29, 2006 11:13 pm

Post by monie089 »

i dont even see errors in my script
New server irc.NintendoXG.com come and visit
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

<note>One should know how to debug it's own stuff.</note>

<off topic>
I've searched the dictionary and haven't found that word.
</off topic>

Anyway, he probably meant to use some sort of application to arrange your code. Something like this (and I quote):

Code: Select all

bind pub -|- &add pub:add
proc pub:add {nick uhost hostname text arg handle channel} {
  global mphfile mkdsfile thasfile acwwfile starfoxfile
  set game [lindex [split $arg] 0]
  set code [lindex [split $arg] 1]
  if {$game !="mph"&& $code !=""} { 
[...]
  }
}
Once the game is over, the king and the pawn go back in the same box.
m
monie089
Halfop
Posts: 76
Joined: Sat Jul 29, 2006 11:13 pm

Post by monie089 »

Code: Select all

########################################
#100% made by monie                    #
#tested to work on windrop             #
#v1.0 soon to be more updated          #
#email me for comments ,hate , or help #
#monie @ XG.Monie089@gmail.com         #
########################################
set wififile "wifi/wifi.txt"
set mphfile "wifi/mph.txt"
set mkdsfile "wifi/mkds.txt"
set acwwfile "wifi/acww.txt"
set thasfile "wifi/thas.txt"
set starfoxfile "wifi/starfox.txt"
bind pub -|- &wifi pub:wifi
proc pub:wifi {nickname uhost hostname  arguments handle  } {
putquick "PRIVMSG $nickname :Welcome to The WiFi Gaming Center"
putquick "PRIVMSG $nickname :Games Currently supported are"
putquick "PRIVMSG $nickname :MKDS MPH THAS ACWW STARFOX More coming soon"
putquick "PRIVMSG $nickname :Commands are as Following"
putquick "PRIVMSG $nickname :&list - lists the current games open"
putquick "PRIVMSG $nickname :&join <name> - Joins the game thats open"
putquick "PRIVMSG $nickname :&create <name> -creates a game"
putquick "PRIVMSG $nickname :&leave <name> - Parts you from that game"
putquick "PRIVMSG $nickname :&add - adds your code for any game"
putquick "PRIVMSG $nickname :&find - finds you or a friends code"
}
bind pub -|- &add pub:add
proc pub:add { nick uhost text channel arg } {
global mphfile mkdsfile thasfile acwwfile starfoxfile
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="mph"&& $code !=""} {
set fd [open $::mphfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""]} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="mkds"&& $code !=""} {
set fd [open $::mkdsfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""]} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="acww"&& $code !=""} {
set fd [open $::acwwfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""]} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="thas"&& $code !=""} {
set fd [open $::thasfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""]} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="starfox"&& $code !=""} {
set fd [open $::starfoxfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""]} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
}
bind pub -|- &find pub:find
proc pub:find {nick uhost hand chan arg} {
global mphfile mkdsfile thasfile acwwfile starfoxfile
set name [lindex [split $arg] 0]
if {$name != ""} {
set fd [open $::mphfile r]
while {! [eof $fd]} {
lappend list [gets $fd]
}
close $fd
if {[set le [lsearch -glob $list "*$name*"]] != -1} {
set line [lindex $list $le]
set code [string map {"" ""} [lindex $line 2]]
putserv "NOTICE $nick :$names mphcode is $code"
} else { 
putserv "NOTICE $nick :Name not found."
}
} else {
putserv "NOTICE $nick :Usage: &find nick"
}
set name [lindex [split $arg] 0]
if {$name != ""} {
set fd [open $::mkdsfile r]
while {! [eof $fd]} {
lappend list [gets $fd]
}
close $fd
if {[set le [lsearch -glob $list "*$name*"]] != -1} {
set line [lindex $list $le]
set code [string map {"" ""} [lindex $line 2]]
putserv "NOTICE $nick :$names mkdscode is $code"
} else { 
putserv "NOTICE $nick :Name not found."
}
} else {
putserv "NOTICE $nick :Usage: &find nick"
}
set name [lindex [split $arg] 0]
if {$name != ""} {
set fd [open $::thasfile r]
while {! [eof $fd]} {
lappend list [gets $fd]
}
close $fd
if {[set le [lsearch -glob $list "*$name*"]] != -1} {
set line [lindex $list $le]
set code [string map {"" ""} [lindex $line 2]]
putserv "NOTICE $nick :$names thascode is $code"
} else { 
putserv "NOTICE $nick :Name not found."
}
} else {
putserv "NOTICE $nick :Usage: &find nick"
}
set name [lindex [split $arg] 0]
if {$name != ""} {
set fd [open $::acwwfile r]
while {! [eof $fd]} {
lappend list [gets $fd]
}
close $fd
if {[set le [lsearch -glob $list "*$name*"]] != -1} {
set line [lindex $list $le]
set code [string map {"" ""} [lindex $line 2]]
putserv "NOTICE $nick :$names acwwcode is $code"
} else { 
putserv "NOTICE $nick :Name not found."
}
} else {
putserv "NOTICE $nick :Usage: &find nick"
}
set name [lindex [split $arg] 0]
if {$name != ""} {
set fd [open $::starfoxfile r]
while {! [eof $fd]} {
lappend list [gets $fd]
}
close $fd
if {[set le [lsearch -glob $list "*$name*"]] != -1} {
set line [lindex $list $le]
set code [string map {"" ""} [lindex $line 2]]
putserv "NOTICE $nick :$names starfoxcode is $code"
} else { 
putserv "NOTICE $nick :Name not found."
}
} else {
putserv "NOTICE $nick :Usage: &find nick"
}
}
bind pub -|- &create pub:create
proc pub:create { nick uhost hand chan arg } {
set table [lindex [split $arg] 0]
if {$table != ""} {
set fd [open $::wififile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end] == ""} {
set list [lreplace $list end end]
}
lappend list "\[$table\]"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
putquick "PRIVMSG $chan :$table was created"
} else {
putserv "PRIVMSG $nick :Usage: &create game."
}
}
bind pub - &join pub:join
proc pub:join { nick chan hand arg text} {
set join [lindex [split $arg] 0]
if {$join != ""} {
set fd [open $::wififile r+]
While {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end] = ""} {
set list [lreplace $list end end]
}
lappend list "\[$join\] $nick"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
putquick "PRIVMSG $nick :You have joined $join"
} else {
putserv "PRIVMSG $nick :Usage: &join name"
}
}
i found the missing brackets but now it says something bout "==" and interger
New server irc.NintendoXG.com come and visit
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

A hint... there is something wrong with this

Code: Select all

if {[lindex $list end == ""]} {
Actually, there's several things wrong with it...
Check the manual-page for lindex, and you'll see that argument 2 and following arguments should be list indexes ("start", "end", integers are some, == and "" are not)
Also, if you check the various operators supported in tcl (another manual-page), you'll find that == only works on numbers, not strings
NML_375
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

monie089 wrote:
rosc2112 wrote:It would be helpful if you tabinate.. This is unreadable as it is.
what do you mean by tabinate
Edit your code and indent as per the example given. It makes code reading far easier.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
incith
Master
Posts: 275
Joined: Sat Apr 23, 2005 2:16 am
Location: Canada

Post by incith »

The correct word is tabulate. Tabulate your code.
Post Reply