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.

multi cmdchars

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
e
edu
Voice
Posts: 31
Joined: Sun Oct 29, 2006 2:10 pm

multi cmdchars

Post by edu »

Code: Select all

set cmdchar ". ! `"

proc cmd { } {
	global cmdchar
	foreach cmd_char $cmdchar {
		return $cmd_char
	}
}

bind pub -|- [cmd]say pub:say

proc pub:say {nickname hostname handle channel text} {
	global cmd
	set text [split $text]
        if {$text == ""} {
            putquick "NOTICE $nickname :syntax: [cmd]say <text>"
            return
       }
	putquick "PRIVMSG $channel :$text"
}
how can I make this script to work when I type .say <text> / !say <text> or `say <text> -- and if no "text" is specified to return .say <text> / !say <text> or `say <text>

Thank you, please help me.
Seek the truth
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

I think more of what you are after is this:

Code: Select all

set cmdchars ".!`"

foreach cmdchar [split $cmdchars ""] {
  bind pub - ${cmdchar}say pub:say
}
and then your proc...
e
edu
Voice
Posts: 31
Joined: Sun Oct 29, 2006 2:10 pm

Post by edu »

I dont need it this way..

I need to make the [cmd] proc to use it, like:

proc -|- [cmd]say say_proc
proc -|- [cmd]die die_proc
etc..

and then into the "code" if $text isn't specified to do: putquick "notice $nickname :[cmd]say <text>"

pls help me :)
Seek the truth
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

You can't do what you are trying to do that way. What []'s do is evaluate a command immediately. For example:

Code: Select all

proc test {} {
  return "moo boo who"
}

bind pub - "[test]unf" proc:unf
This will cause the pub event to be bound to "moo boo who".
ie. To trigger the proc, you would have to say in a channel:

<user> moo boo whounf

NOT "moounf" or "boounf" or "whounf"

You will need to create multiple bindings as I just provided you the code for, or you will need to bind a pubm to * and check inside the proc itself.
e
edu
Voice
Posts: 31
Joined: Sun Oct 29, 2006 2:10 pm

Post by edu »

you dont get it -- I'll make it with only one cmdchar

Thanks anyway
Seek the truth
User avatar
Nor7on
Op
Posts: 185
Joined: Sat Mar 03, 2007 8:05 am
Location: Spain - Barcelona
Contact:

Post by Nor7on »

Code: Select all

bind pub -|- !say pub:say 
bind pub -|- .say pub:say 
bind pub -|- `say pub:say 
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

Nor7on wrote:

Code: Select all

bind pub -|- !say pub:say 
bind pub -|- .say pub:say 
bind pub -|- `say pub:say 
That's what my code above did. He doesn't want that apparently.
:roll:
e
edu
Voice
Posts: 31
Joined: Sun Oct 29, 2006 2:10 pm

Post by edu »

so, let me explain it again.. more clearly.. (I hope)

I want to make this script that has a lot of binds, and I want to use more cmdchars, for this reason I want to make this proc [cmd] and set more binds, like:

Code: Select all

bind pub -|- [cmd]say proc_say
bind pub -|- [cmd]die proc_die
and so on..

I dont want to set 3 times the same thing..

help me if you can, thank you & for your time.
Seek the truth
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

As I told you, you can't do it like that.
You will either have to set multiple binds, or create a pubm bind to match against * and parse the text inside the proc. Both have their benefits and fallbacks. Multiple binds means, well, multiple bindings (which isn't a bad thing unless you create a million binds, so I don't know why you wouldn't want this). A pubm bound procedure would have to process all text in a channel, which isn't too efficient.

So again... I repeat to you the solution I posted above, commented:

Code: Select all

# Set below the characters you wish to use prior to your command
# ie: 1) !command 2) .command 3)`command
set cmdchars ".!`"

# now we will set up the bindings based on that information provided above, you don't need to edit this part
foreach cmdchar [split $cmdchars ""] {
  bind pub - ${cmdchar}say pub:say
}

#done
This does exactly what you ask, despite how many times you say it isn't what you are asking.
Post Reply