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.

what is wrong with this script?

Old posts that have not been replied to for several years.
Locked
m
mkluin
Voice
Posts: 27
Joined: Tue Nov 05, 2002 4:11 am

what is wrong with this script?

Post by mkluin »

The script doesn't respond at all, it also doesn't give any error.

Code: Select all

#Anaroch's info script by a_happy_visitor

putlog "loading Anaroch by a_happy_visitor..."

###############binds###############
bind pub +xp pub:xp
bind pub +potion pub:potion
bind pub +help pub:help

#Channels allowed to use these commands
set enabledchans {#anaroch #anaroch1 #r_anaroch #attack}

# procedure to check if chan where command is used is listed chan
proc isenabledchan { channel } {
   global enabledchans
   # compare each chan in $enabledchans with current chan and return 1 (true) if chan is listed
   foreach enablechan $enabledchans {
      if { $channel == $enablechan } {
         return 1
      }
   }
   return 0
}

# main procedure to handle the commands
proc pub:xp { nick uhost handle channel arg } {
   # check if command should work in this chan
   set chan [string tolower $channel]
   if { ![isenabledchan $chan] } {
      return 1
   }
   if { [llength $arg] == 0 } {
     putserv "NOTICE $nick :Unable to perform request, give command."
   } else {
      set command [lindex $arg 0]
      set command [string tolower $command]
         # check if valid number of arguments
         if { [llength $arg] < 1 } {
            putserv "NOTICE $nick :Please check the help function if you don't know how to use this command."
         # command syntax is ok, process request
         } else {
            set exp [string tolower [lindex $arg 1]]
            if { $exp == 1 } { putserv "NOTICE $nick :You must be dumb, check what level you start with." }
            if { $exp == 2 } { putserv "NOTICE $nick :you need 400 XP - 20 AP - 20 DP and 20 HP to fight level 2 Monsters." }
            if { $exp == 3 } { putserv "NOTICE $nick :you need 800 XP - 40 AP - 40 DP and 40 HP to fight level 3 Monsters." }
            if { $exp == 4 } { putserv "NOTICE $nick :you need 1600 XP - 80 AP - 80 DP and 80 HP to fight level 4 Monsters." }
            if { $exp == 5 } { putserv "NOTICE $nick :you need 3200 XP - 160 AP - 160 DP and 160 HP to fight level 5 Monsters." }
            if { $exp == 6 } { putserv "NOTICE $nick :you need 6400 XP - 320 AP - 320 DP and 320 HP to fight level 6 Monsters." }
            if { $exp == 7 } { putserv "NOTICE $nick :you need 12800 XP - 640 AP - 640 DP and 640 HP to fight level 7 Monsters." }
            if { $exp == 8 } { putserv "NOTICE $nick :you need 25600 XP - 1280 AP - 1280 DP and 1280 HP to fight level 8 Monsters." }
            if { $exp == 9 } { putserv "NOTICE $nick :you need 51200 XP - 2560 AP - 2560 DP and 2560 HP to fight level 9 Monsters." }
            if { $exp == 10 } { putserv "NOTICE $nick :you need 102400 XP - 5120 AP - 5120 DP and 5120 HP to fight level 10 Monsters." }
            if { $exp == 11 } { putserv "NOTICE $nick :you need 204800 XP - 10240 AP - 10240 DP and 10240 HP to fight level 11 Monsters." }
            if { $exp == 12 } { putserv "NOTICE $nick :you need 409600 XP - 20480 AP - 20480 DP and 20480 HP to fight level 12 Monsters." }
            if { $exp == 13 } { putserv "NOTICE $nick :you need 819200 XP - 40960 AP - 40960 DP and 40960 HP to fight level 13 Monsters." }
            if { $exp == 14 } { putserv "NOTICE $nick :you need 1638400 XP - 81920 AP - 81920 DP and 81920 HP to fight level 14 Monsters." }
            if { $exp == 15 } { putserv "NOTICE $nick :you need 3276800 XP - 163840 AP - 163840 DP and 163840 HP to fight level 15 Monsters." }
            if { $exp == 16 } { putserv "NOTICE $nick :you need 6553600 XP - 327680 AP - 327680 DP and 327680 HP to fight level 16 Monsters." }
            if { $exp == 17 } { putserv "NOTICE $nick :you need 13107200 XP - 655360 AP - 655360 DP and 655360 HP to fight level 17 Monsters." }
            if { $exp == 18 } { putserv "NOTICE $nick :you need 26214400 XP - 1310720 AP - 1310720 DP and 1310720 HP to fight level 18 Monsters." }
            if { $exp == 19 } { putserv "NOTICE $nick :you need 52418800 XP - 2621440 AP - 2621440 DP and 2621440 HP to fight level 19 Monsters." }
            if { $exp == 20 } { putserv "NOTICE $nick :you need 104857600 XP - 5242880 AP - 5242880 DP and 5242880 HP to fight level 20 Monsters." }
            if { $exp == 21 } { putserv "NOTICE $nick :you need 209715200 XP - 10485760 AP - 10485760 DP and 10485760 HP to fight level 21 Monsters." }
            if { $exp == 22 } { putserv "NOTICE $nick :you need 419430400 XP - 20971520 AP - 20971520 DP and 20971520 HP to fight level 22 Monsters." }
            if { $exp == 23 } { putserv "NOTICE $nick :you need 838860800 XP - 41943040 AP - 41943040 DP and 41943040 HP to fight level 23 Monsters." }
            if { $exp == 24 } { putserv "NOTICE $nick :you need 1677721600 XP - 83886080 AP - 83886080 DP and 83886080 HP to fight level 24 Monsters." }
            if { $exp == 25 } { putserv "NOTICE $nick :you need 3355443200 XP - 167772160 AP - 167772160 DP and 167772160 HP to fight level 25 Monsters." }
            if { $exp >= 26 } { putserv "NOTICE $nick :They added a new level to the game? As far as i know there are only 25 levels in this game." }
            if { $exp <= 0} { putserv "NOTICE $nick :4Error no info exists about this level" }
          }
       }
}
s
spyda
Halfop
Posts: 64
Joined: Mon Aug 12, 2002 2:22 am
Location: Australia

tcl.commands

Post by spyda »

PUB
bind pub <flags> <command> <proc>
procname <nick> <user@host> <handle> <channel> <text>

Description: used for commands given on a channel. The first word
becomes the command and everything else is the text argument.
Module: irc
Found the in tcl-commands.doc (/eggdrop/docs/)

mkluin
#Anaroch's info script by a_happy_visitor

putlog "loading Anaroch by a_happy_visitor..."

###############binds###############
bind pub +xp pub:xp
bind pub +potion pub:potion
bind pub +help pub:help

Code: Select all

bind PUB - +xp pub:xp
bind PUB - +potion pub:potion
bind PUB - +help :pub:help
Hope that helps
------------
ThePope
m
mkluin
Voice
Posts: 27
Joined: Tue Nov 05, 2002 4:11 am

Post by mkluin »

i used the - between pub and +xp.

now the bot responds, but every answer it gives is the answer from this line:

if { $exp <= 0} { putserv "NOTICE $nick :Error no info exists about this level" }
Regards,

Mkluin
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Instead of the lots of if's use something like this:

Code: Select all

if {$exp >= 26} {
putserv "NOTICE $nick :They added a new level to the game? As far as i know there are only 25 levels in this game."
return
}
if {$exp <= 0} {
putserv "NOTICE $nick :Error no info exists about this level."
return
} 
switch $exp {
"1" { putserv "NOTICE $nick :You must be dumb, check what level you start with." } 
"2" { putserv "NOTICE $nick :you need 400 XP - 20 AP - 20 DP and 20 HP to fight level 2 Monsters." } 
"3" { putserv "NOTICE $nick :you need 800 XP - 40 AP - 40 DP and 40 HP to fight level 3 Monsters." } 
"4" { putserv "NOTICE $nick :you need 1600 XP - 80 AP - 80 DP and 80 HP to fight level 4 Monsters." }
"5" { putserv "NOTICE $nick :you need 3200 XP - 160 AP - 160 DP and 160 HP to fight level 5 Monsters." } 
"6" { putserv "NOTICE $nick :you need 6400 XP - 320 AP - 320 DP and 320 HP to fight level 6 Monsters." } 
"7" { putserv "NOTICE $nick :you need 12800 XP - 640 AP - 640 DP and 640 HP to fight level 7 Monsters." } 
"8" { putserv "NOTICE $nick :you need 25600 XP - 1280 AP - 1280 DP and 1280 HP to fight level 8 Monsters." } 
"9" { putserv "NOTICE $nick :you need 51200 XP - 2560 AP - 2560 DP and 2560 HP to fight level 9 Monsters." } 
"10" { putserv "NOTICE $nick :you need 102400 XP - 5120 AP - 5120 DP and 5120 HP to fight level 10 Monsters." } 
"11" { putserv "NOTICE $nick :you need 204800 XP - 10240 AP - 10240 DP and 10240 HP to fight level 11 Monsters." } 
"12" { putserv "NOTICE $nick :you need 409600 XP - 20480 AP - 20480 DP and 20480 HP to fight level 12 Monsters." } 
"13" { putserv "NOTICE $nick :you need 819200 XP - 40960 AP - 40960 DP and 40960 HP to fight level 13 Monsters." } 
"14" { putserv "NOTICE $nick :you need 1638400 XP - 81920 AP - 81920 DP and 81920 HP to fight level 14 Monsters." } 
"15" { putserv "NOTICE $nick :you need 3276800 XP - 163840 AP - 163840 DP and 163840 HP to fight level 15 Monsters." } 
"16" { putserv "NOTICE $nick :you need 6553600 XP - 327680 AP - 327680 DP and 327680 HP to fight level 16 Monsters." } 
"17" { putserv "NOTICE $nick :you need 13107200 XP - 655360 AP - 655360 DP and 655360 HP to fight level 17 Monsters." } 
"18" { putserv "NOTICE $nick :you need 26214400 XP - 1310720 AP - 1310720 DP and 1310720 HP to fight level 18 Monsters." } 
"19" { putserv "NOTICE $nick :you need 52418800 XP - 2621440 AP - 2621440 DP and 2621440 HP to fight level 19 Monsters." } 
"20" { putserv "NOTICE $nick :you need 104857600 XP - 5242880 AP - 5242880 DP and 5242880 HP to fight level 20 Monsters." } 
"21" { putserv "NOTICE $nick :you need 209715200 XP - 10485760 AP - 10485760 DP and 10485760 HP to fight level 21 Monsters." } 
"22" { putserv "NOTICE $nick :you need 419430400 XP - 20971520 AP - 20971520 DP and 20971520 HP to fight level 22 Monsters." } 
"23" { putserv "NOTICE $nick :you need 838860800 XP - 41943040 AP - 41943040 DP and 41943040 HP to fight level 23 Monsters." } 
"24" { putserv "NOTICE $nick :you need 1677721600 XP - 83886080 AP - 83886080 DP and 83886080 HP to fight level 24 Monsters." } 
"25" { putserv "NOTICE $nick :you need 3355443200 XP - 167772160 AP - 167772160 DP and 167772160 HP to fight level 25 Monsters." } 
}
Once the game is over, the king and the pawn go back in the same box.
m
mkluin
Voice
Posts: 27
Joined: Tue Nov 05, 2002 4:11 am

Post by mkluin »

ok. i have it like this now. but it tells me that it is missing a close brace.

[09:02] Tcl error in file 'ahv.conf':
[09:02] missing close-brace
while executing
"proc pub:xp { nick uhost handle channel arg } {
# check if command should work in this chan
set chan [string tolower $channel]
if { ![isenabl..."
(file "scripts/anaroch.tcl" line 26)

ok. what i have now is:

Code: Select all

##############binds###############
bind pub +xp pub:xp
bind pub +potion pub:potion
bind pub +help pub:help

#Channels allowed to use these commands
set enabledchans {#anaroch #anaroch1 #r_anaroch #attack}

# procedure to check if chan where command is used is listed chan
proc isenabledchan { channel } {
   global enabledchans
   # compare each chan in $enabledchans with current chan and return 1 (true) if chan is listed
   foreach enablechan $enabledchans {
      if { $channel == $enablechan } {
         return 1
      }
   }
   return 0
}

# main procedure to handle the commands
proc pub:xp { nick uhost handle channel arg } {
   # check if command should work in this chan
   set chan [string tolower $channel]
   if { ![isenabledchan $chan] } {
      return 1
   }
   if { [llength $arg] == 0 } {
     putserv "NOTICE $nick :Unable to perform request, give command."
   } else {
      set command [lindex $arg 0]
      set command [string tolower $command]
         # check if valid number of arguments
         if { [llength $arg] < 1 } {
            putserv "NOTICE $nick :Please check the help function if you don't know how to use this command."
         # command syntax is ok, process request
         } else {
            set exp [string tolower [lindex $arg 1]]
            if {$exp >= 26} { putserv "NOTICE $nick :They added a new level to the game? As far as i know there are only 25 levels in this game." return } 
            if {$exp <= 0} { putserv "NOTICE $nick :Error no info exists about this level." return }
            switch $exp { 
            "1" { putserv "NOTICE $nick :You must be dumb, check what level you start with." } 
            "2" { putserv "NOTICE $nick :you need 400 XP - 20 AP - 20 DP and 20 HP to fight level 2 Monsters." } 
            "3" { putserv "NOTICE $nick :you need 800 XP - 40 AP - 40 DP and 40 HP to fight level 3 Monsters." } 
            "4" { putserv "NOTICE $nick :you need 1600 XP - 80 AP - 80 DP and 80 HP to fight level 4 Monsters." } 
            "5" { putserv "NOTICE $nick :you need 3200 XP - 160 AP - 160 DP and 160 HP to fight level 5 Monsters." } 
            "6" { putserv "NOTICE $nick :you need 6400 XP - 320 AP - 320 DP and 320 HP to fight level 6 Monsters." } 
            "7" { putserv "NOTICE $nick :you need 12800 XP - 640 AP - 640 DP and 640 HP to fight level 7 Monsters." } 
            "8" { putserv "NOTICE $nick :you need 25600 XP - 1280 AP - 1280 DP and 1280 HP to fight level 8 Monsters." } 
            "9" { putserv "NOTICE $nick :you need 51200 XP - 2560 AP - 2560 DP and 2560 HP to fight level 9 Monsters." } 
            "10" { putserv "NOTICE $nick :you need 102400 XP - 5120 AP - 5120 DP and 5120 HP to fight level 10 Monsters." } 
            "11" { putserv "NOTICE $nick :you need 204800 XP - 10240 AP - 10240 DP and 10240 HP to fight level 11 Monsters." } 
            "12" { putserv "NOTICE $nick :you need 409600 XP - 20480 AP - 20480 DP and 20480 HP to fight level 12 Monsters." } 
            "13" { putserv "NOTICE $nick :you need 819200 XP - 40960 AP - 40960 DP and 40960 HP to fight level 13 Monsters." } 
            "14" { putserv "NOTICE $nick :you need 1638400 XP - 81920 AP - 81920 DP and 81920 HP to fight level 14 Monsters." } 
            "15" { putserv "NOTICE $nick :you need 3276800 XP - 163840 AP - 163840 DP and 163840 HP to fight level 15 Monsters." } 
            "16" { putserv "NOTICE $nick :you need 6553600 XP - 327680 AP - 327680 DP and 327680 HP to fight level 16 Monsters." } 
            "17" { putserv "NOTICE $nick :you need 13107200 XP - 655360 AP - 655360 DP and 655360 HP to fight level 17 Monsters." } 
            "18" { putserv "NOTICE $nick :you need 26214400 XP - 1310720 AP - 1310720 DP and 1310720 HP to fight level 18 Monsters." } 
            "19" { putserv "NOTICE $nick :you need 52418800 XP - 2621440 AP - 2621440 DP and 2621440 HP to fight level 19 Monsters." } 
            "20" { putserv "NOTICE $nick :you need 104857600 XP - 5242880 AP - 5242880 DP and 5242880 HP to fight level 20 Monsters." } 
            "21" { putserv "NOTICE $nick :you need 209715200 XP - 10485760 AP - 10485760 DP and 10485760 HP to fight level 21 Monsters." } 
            "22" { putserv "NOTICE $nick :you need 419430400 XP - 20971520 AP - 20971520 DP and 20971520 HP to fight level 22 Monsters." } 
            "23" { putserv "NOTICE $nick :you need 838860800 XP - 41943040 AP - 41943040 DP and 41943040 HP to fight level 23 Monsters." } 
            "24" { putserv "NOTICE $nick :you need 1677721600 XP - 83886080 AP - 83886080 DP and 83886080 HP to fight level 24 Monsters." } 
            "25" { putserv "NOTICE $nick :you need 3355443200 XP - 167772160 AP - 167772160 DP and 167772160 HP to fight level 25 Monsters." } 
          }
       }
}
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

try replace

Code: Select all

else { 
      set command [lindex $arg 0] 
      set command [string tolower $command] 
         # check if valid number of arguments 
         if { [llength $arg] < 1 } { 
            putserv "NOTICE $nick :Please check the help function if you don't know how to use this command." 
         # command syntax is ok, process request 
         } else {
with

Code: Select all

else { 
      set command [lindex $arg 0] 
      set command [string tolower $command] 
         # check if valid number of arguments 
         if { [llength $arg] < 1 } { 
            putserv "NOTICE $nick :Please check the help function if you don't know how to use this command." 
         # command syntax is ok, process request 
         }
}else {
m
mkluin
Voice
Posts: 27
Joined: Tue Nov 05, 2002 4:11 am

Post by mkluin »

[04:43] extra characters after close-brace
while executing
"} else {
set command [lindex $arg 0]
set command [string tolower $command]
# check if valid number of arguments
if { [lle..."
(file "scripts/anaroch.tcl" line 35)
invoked from within
"source scripts/anaroch.tcl"

this is what i have now:

Code: Select all

   } else {
     set command [lindex $arg 0]
      set command [string tolower $command]
         # check if valid number of arguments
         if { [llength $arg] < 1 } {
            putserv "NOTICE $nick :Please check the help function if you don't $
         # command syntax is ok, process request
         }
  }else {
            set exp [string tolower [lindex $arg 1]]
Regards,

Mkluin
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

You forgot to add an } at the end of the proc. At his end should be 4 } not 3. Just add one and should be working.
Once the game is over, the king and the pawn go back in the same box.
m
mkluin
Voice
Posts: 27
Joined: Tue Nov 05, 2002 4:11 am

Post by mkluin »

still doesn't work.

now i keep getting an error about the second } else {

guess i better stop with it since i don't get it to work.

Thanks for the help guys
Regards,

Mkluin
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

mkluin wrote:still doesn't work.

now i keep getting an error about the second } else {

guess i better stop with it since i don't get it to work.

Thanks for the help guys
what you have is
}else {
what it should be is
} else {
m
mkluin
Voice
Posts: 27
Joined: Tue Nov 05, 2002 4:11 am

Post by mkluin »

i have tried that also.

no luck.

the part as i have it now is:

Code: Select all

# main procedure to handle the commands
proc pub:xp { nick uhost handle channel arg } {
   # check if command should work in this chan
   set chan [string tolower $channel]
   if { ![isenabledchan $chan] } {
      return 1
   }
   if { [llength $arg] == 0 } {
     putserv "NOTICE $nick :Unable to perform request, give command." }
   }
   } else {
      set command [lindex $arg 0]
      set command [string tolower $command]
         # check if valid number of arguments
         if { [llength $arg] < 1 } {
            putserv "NOTICE $nick :Please check the help function if you don't know how to use this command."
         # command syntax is ok, process request
         }
 else {
the error i get now is:

[02:52] Tcl error in file 'eggdrop.conf':
[02:52] invalid command name "}"
while executing
"} else {
set command [lindex $arg 0]
set command [string tolower $command]
# check if valid number of arguments
if { [ll..."
Regards,

Mkluin
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

The first "else" is not connected to a conditional if-statement, which causes the error message.

Look carefully where you open and close the braces and check on the correct application of the if-then-else constructions.

Besides, what you also have is:
}
else {
which should be:
} else {
Also, you are applying list commands ([llength], [lindex]) on strings.

Also, you first apply the test "{ [llength $arg] == 0 }" and not much later you apply the test "if { [llength $arg] < 1 } { ".
m
mkluin
Voice
Posts: 27
Joined: Tue Nov 05, 2002 4:11 am

Post by mkluin »

i am not that good in scripting.

This is the first script i tried to do without help.
Regards,

Mkluin
Locked