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.

TCL Help

Old posts that have not been replied to for several years.
Locked
s
sirgrim

Post by sirgrim »

Hello, i'm writing a palm reading script for an eggdrop, but what I need it to do, first off is check if they did !palm 06/17/1982 (birthday) in mm/dd/yyyy format, if not it sends them an error. After that it will take the birthday and add it until it's one number. I.E. 6+1+7+1+9+8+2 = 34 (3+4) = 7. From there it will look for the $7 (or another number between 1-9.) descriptor which it will output to the channel for palm reading. Can anyone give me some advice on those two problems? Thanks.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

OK - simple script

Code: Select all

set palmread {
{This is plam reading for the number 1}
{This is plam reading for the number 2}
{This is plam reading for the number 3}
{This is plam reading for the number 4}
{This is plam reading for the number 5}
{This is plam reading for the number 6}
{This is plam reading for the number 7}
{This is plam reading for the number 8}
{This is plam reading for the number 9}
}

bind pub - "!palm" pub:palm
proc pub:palm {nick uh hand chan arg} {
  global palmread
  if {![regexp -- {[0-9]{2}/[0-9]{2}/[0-9]{4}} [lindex [split $arg] 0]]} {
    puthelp "PRIVMSG $chan :$nick - That is an invalid date"
    return
  }
  set a 0
  foreach b [split [lindex [split $arg] 0] /] {
    incr a $b
  }
  while {[string length $a] > 1} {
    set c 0
    foreach b [split $a {}] {
      incr c $b
    }
    set a $c
  }
  puthelp "PRIVMSG $chan :$nick - Palm reading is "[lindex $palmread [expr $a - 1]]""
}
s
sirgrim

Post by sirgrim »

Thanks, i'll try that right now and post the whole script when it works, it's very interesting. And actually acurite! Based on numerology.
s
sirgrim

Post by sirgrim »

OK, it works great, but my fortunes are too long, and it cuts off, any way to fix this? Thanks for the help.
s
sirgrim

Post by sirgrim »

n/m, i made a palmread2 variable that holds the second half of 'em. Thanks!
s
sirgrim

Post by sirgrim »

One last thing and it should be complete. When people use !palm 09/dd/yyyy I get
[18:50] <grimbot> [18:50] Tcl error [pub:palm]: expected integer but got "09" (looks like invalid octal number)
[18:51] <grimbot> [18:51] Tcl error [pub:palm]: expected integer but got "09" (looks like invalid octal number)
[18:51] <grimbot> [18:51] Tcl error [pub:palm]: expected integer but got "09" (looks like invalid octal number)
in the dcc chat.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

EEK - I missed out a rather large section, change the following.

Locate lines

Code: Select all

foreach b [split [lindex [split $arg] 0] /] {
  incr a $b
}
and change them to

Code: Select all

foreach b [split [lindex [split $arg] 0] /] {
  foreach t [split $b {}] {
    incr a $t
  }
}
It was failing to the first date addition pass with single digits, instead it was adding the day, month and year together. This fix will split it down that extra step.
s
sirgrim

Post by sirgrim »

Thanks, but I still get the:
[20:22] <grimbot> [20:22] Tcl error [pub:palm]: expected integer but got "09" (looks like invalid octal number)
does the same thing on 08 too.
W
Wcc
Master
Posts: 278
Joined: Sun Oct 28, 2001 8:00 pm
Location: USA
Contact:

Post by Wcc »

Ppslim, why not use expr? It doesn't care about 0's before a number.
s
sirgrim

Post by sirgrim »

I'm new to scripting, and never used the expr, so if you could enlighten me it would be appreciated.
s
sirgrim

Post by sirgrim »

OK, i fixed that problem, I just changed the first {[0-9]{2}....... to {[0-9]{1}.. so you can use like 9/12/2001 and 8/bla/bla, two digits like 10, 11, and 12 still work. That line you had me add after, that messed up the counting, it's accurate without it, but not with it, so i took it out. Seams to be working perfectly, i'll verify it then submit it to this page for ya'll to use, it's incredably accurate. Using numerology to explain your life, instead of palm/psychic readings.
W
Wcc
Master
Posts: 278
Joined: Sun Oct 28, 2001 8:00 pm
Location: USA
Contact:

Post by Wcc »

That won't do exactly what you want...
You could change

Code: Select all

proc pub:palm {nick uh hand chan arg} {
  global palmread
  if {![regexp -- {[0-9]{2}/[0-9]{2}/[0-9]{4}} [lindex [split $arg] 0]]} {
    puthelp "PRIVMSG $chan :$nick - That is an invalid date"
    return
  }
to

Code: Select all

if {![string match */*/* [lindex [split $arg] 0]]} {
    puthelp "PRIVMSG $chan :$nick - That is an invalid date"
    return
 }
regsub -all -- "/" "[lindex [split $arg] 0]]" "" date
foreach i [split $date ""] {
	if {![regexp ^[0-9]$ $i]} {
		puthelp "PRIVMSG $chan :$nick - That is an invalid date"
		return
	}
}
s
sirgrim

Post by sirgrim »

Really do appreciate all the help. I believe the script is 100% complete. Seams to be doing the math perfectly. I'll see if I can post the code... Here goes...

# Numerology Based Fortune Telling #
# You'd be surprised by the acuracy of this script #
# Programmed by sirgrim, with the help of egghelp.org Forums. #
# Contact sirgrim@WAGD.com with any questions. #

set palmread {
{ONES are independent, self motivated, hard workers. They have a strong desire to be #1. They are critical of themselves and as a result can be critical of others.}
{TWOS want peace. They try to be mediators. When they feel threatened or pushed to the wall, they become the terrible 2s. They seek love and do not like to be alone.}
{THREES communicate in all areas: written word and verbal. Writers, radio broadcasters, actors, singers, performers, counselors. They are the natural comedian. They can be manic depressive if they do not use their creative energy and tend to exaggerate the truth. Known by their trademark smile, eyes and voice.}
{FOURS seek security. Home is their haven. They are usually very cerebral and have to get out of their heads. Like NIKE, "Just Do It." Otherwise, great ideas live and die in their heads. The 4 Attitude is a list keeper. They can be very quiet; you don't know what they're thinking. They're keeping track of all that's happening. You might find them surrounded by nature, or doing any form of repair, or construction.}
{FIVES seek freedom, fun, adventure. If they do not live the adventure, their lives become soap operas. They are the natural detectives and celebrators of life (holidays). 5s have a hard time settling down and have a fear of being trapped or smothered.}
{SIXES are nurturers. If men, they rescue damsels in distress. If women, they mother the "little boy" in their men. They should manage or run the company. If every thing is going smoothly, they must be careful not to ruin it. They tend to put people on pedestals which then topple. Magnetic. People are drawn to them. Their moods affect the room.}
{SEVENS are another cerebral number. They have a loner quality. They need to learn to have faith. They have a love of natural beauty: ocean, green grass, plants, flowers, etc. If they do not have faith they tend to become very cynical and escape through drugs, alcohol, work, and geography. They have an air of mystery and do not want you to know who they are.}
{EIGHTS are here to master money. They do not feel safe unless they have financial security. It is difficult for the 8s to take advice.When they make a choice, they must feel it is their decision, NOT SOMEONE ELSES. As a result, they do tend to learn the hard way. 8s are very honest and by being so blunt, they unitentionally hurt feelings. Although they can sometimes appear insensitive, what is going on inside them is the exact opposite.}
{NINES are the natural leader. People assume they are in charge even if they are not. If in a department store, people think they work there. They take care of everyone else but need to learn to speak up when they need help, love, and hugs. 9s often feel unloved or abandoned by their mother or father, or they feel completely responsible for them. It's hard for them to let go of the past.}
}
set palmread2 {
{The 1 Attitude: This is someone who doesn't like to ask for help. They are completely self-motivated. They usually have issues with their self- esteem: they just don't think they're good enough. That's why they need praise from others. If you believe in them, then there's nothing they can't achieve; if you don't, they rebel.}
{The 2 Attitude is easy going. They tend to be the observer. They're also obsessed with anything regarding psychic ability, and experience déjà vu. They have dreams that come true. They are in touch with their intuition and the metaphysical side of life. They do have compassion for people and are fascinated with people's stories. They are seldom bored.}
{The 3 Attitude tends to be the joker. They have a sense of humor and are charismatic. The Peter Pan Syndrome, they don't necessarily grow up. But when they're in a good mood, It's a big smile, bright eyes, and great conversation. If they're in a bad mood, you don't get to be happy around them. They have that effect on people.}
{The 4 Attitude teaches all of us. They become an expert at their skill and teach us how to do it. They definitely will play devil's advocate: they make you see all sides. That's their Attitude Number.}
{The 5 Attitude is playful and fun. They need to go and look at this world. They can't wait to go and experience other parts of the planet, and if they get stuck in a situation, it's too dramatic and they wind up playing the martyr. So better a 5 get out there. It's all about adventure and excitement. They love to flirt and they're usually the life of the party.}
{The 6 Attitude is the nurturer. Male or female, they are taking care of everybody else. So if you have a child with a 6 attitude. They act as it they are your mother or father, they're the ones in charge; they don't want you telling them what to do or how to be. They feel useful only when things are out of control and they are fixing it. If it's peaceful, they don't know what to do with them selves.}
{The 7 Attitude. You don't get to know what they're thinking or feeling. They keep to themselves and are introspective. They must continue studying the quest of why they are here: The 7 Attitude asks the big questions. They will reveal themselves slowly as they go. They can shut down and make you feel they are not remotely interested in what you are saying, but the joke is on you because they are the ultimate observers. They don't miss anything.}
{The 8 Attitude, More often than not, when I see an 8 Attitude, they're reading Investors or Money Magazine. They are here to figure out how to make money. If they have family, they care very much about their security. Making their money grow is a priority. The flipside of the 8 Attitude is that money can seem completely unattainable. Money will slip right through their fingers. The key is to keep their sense of humor, there will be a payoff.}
{The 9 Attitude: The 9 is the leader. At work they'll not just do their job but everyone else's. That's the Attitude Number 9: show me what to do, I'll do it. When it's over, they're exhausted and drained, but rarely allow them selves to tell the people responsible, The Attitude Number 9 person may have old family pain that haunts them. And the 9 needs to overcome it in order to be happy today.}
}
bind pub - "!palm" pub:palm
proc pub:palm {nick uh hand chan arg} {
global palmread
global palmread2
if {![regexp -- {[0-9]{1}/[0-9]{2}/[0-9]{4}} [lindex [split $arg] 0]]} {
puthelp "PRIVMSG $chan :$nick - That is an invalid date, please use m(m)/dd/yyyy format."
return
}
set a 0
foreach b [split [lindex [split $arg] 0] /] {
incr a $b
}
while {[string length $a] > 1} {
set c 0
foreach b [split $a {}] {
incr c $b
}
set a $c
}
puthelp "PRIVMSG $chan :$nick - Palm reading is "[lindex $palmread [expr $a - 1]]""
puthelp "PRIVMSG $chan :"[lindex $palmread2 [expr $a - 1]]""
}

bind pub - "!palmhelp" pub:help
proc pub:help {nick uh hand chan args} {
set who [lindex $args 0]
putserv "PRIVMSG $chan :Thanks for your interest in my !palm readings $nick, it's based on Numerology, which seams pretty darn accurite."
putserv "PRIVMSG $chan :$nick, simply type !palm (m(m)/dd/yyyy) where the m/dd/yyyy is your birthday, or someone else's whom you are interested in knowing more about them. I will let you know if the date is incorrect."
return 1
}

That is a pretty simple script, really appreciate all the help. I'll be submitting this to the page now, feel free to use it. Just please leave the comments at the top. Thanks for all the help!
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

wcc, you try using expr with a number like that. Yes it does care about have a 0 as the first digit.

In computer math, a number begining with 0 is octal (AKA BASE :cool:, thus 08 and 09 are invalid numbers. Try it yourself, simple passing 08 or 09 to expr, and it will spit an error at you.

Proof of concept is in the time bind. If you wanted to run a script every 5 mins, without using combersom timers, you could do the following.
bind time - "*" mytime:bind
proc mytime:bind {min hour day month year} {
if {[expr $min % 5]} { return }
do stuff
}
When it reaches 8,and 9 minutes past the hour, expr will spit out errors (non-fatal I might add). Even though it doesn't crash the bot, failing to remove the errors would be classed as bad coding.

As for a script in this situation, where an "expr" would be a inmportant part of the script, a number that makes it error out, will cause you to wonder why no output is ever given.
% expr 5 + 6
11
% expr 05 + 6
11
% expr 9 + 6
15
% expr 09 + 6
"09" is an invalid octal number
W
Wcc
Master
Posts: 278
Joined: Sun Oct 28, 2001 8:00 pm
Location: USA
Contact:

Post by Wcc »

Ya, sorry, I did a quick test with 04 and diddn't get an error :smile:
Locked