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.

Problem with variables ($nick , $arg)

Old posts that have not been replied to for several years.
Locked
M
Mentolboy

Post by Mentolboy »

Hi!
I made a little script (see below) where you kan !kiss somebody in the channel. The only problem is, that the "$nick" and "$arg" variables are not be converted to the nickname and the arguments. For example:
<testbot> $arg gets a kiss from $nick
that should be:
<testbot> personB gets a kiss from personA (in which "personA" is the person who gave the command and "personB" is the argument given)
How can I do that??

btw: i replaced the "[" and "]" by "(" and ")" to prevent forum error

Code: Select all

set rankiss {
"$nick blows $arg a kiss! :smile:"
"$arg gets a kiss from $nick"
"After some hugging, $nick kisses $arg"
}
proc pub_kiss {nick uhost hand chan $rankiss} {
  global rankiss
set lengthstr { rand (length $rankiss) }
    putchan $chan "[lindex $rankiss (rand (llength $rankiss)))"
    return 1
}
bind pub - !kiss pub_kiss
<font size=-1>[ This Message was edited by: Mentolboy on 2002-01-10 08:05 ]</font>
P
Petersen
Owner
Posts: 685
Joined: Thu Sep 27, 2001 8:00 pm
Location: Blackpool, UK

Post by Petersen »

putchan $chan "[subst [lindex [blah.... ]]]"
M
Mentolboy

Post by Mentolboy »

It still doesn't work :sad:
now I get the following error:

TCL error (pub_mast): invalid command name "substAfter some hugging, $nick kisses $arg"


p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

You are failing to place a space between "[subst" and the "[lindex" command.

EG
subst[lindex
when it should be
[subst [lindex
M
Mentolboy

Post by Mentolboy »

didn't know a space would make that difference!
thanx! :smile:
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Yes it does.

doing
[subst[lindex
whatever lindex returns, gets appended to "subst", thus making it think the command doesn't exist.
Locked