namespace eval rules {
set #Zelda("nick") "There is no need to spam nick changes; pick a nick and keep it! If you are in #RolePlay and need to change nicks frequently, please lea$
set #Zelda("flood") "Please do not flood (putting several lines of text into the channel at once) or spam (posting useless/irrelevant information). Consecu$
set #Zelda("ads") "Do not advertise any channels or servers. Do not advertise any TZCN channels on any other channels or servers."
set #Zelda("fights") "We ask that any arguments or fights be taken to another channel or private message."
set #Zelda("beg") "Do not beg for ops or moderator status. This includes attempting to use operator commands (including but not limited to !op, !up, !down,$
set #Zelda("mature") "Do not post grotesque or vulgar content. This includes, but is not limited to, shock sites, pornography, and explicit literature (ero$
set #Zelda("profanity") "Minor profanity is allowed. However, excessive swearing and discriminatory/racial slurs will be dealt with harshly."
set #Zelda("scripts") "While scripts can be humorous and fun, we ask that flood controls be implemented. Otherwise, your script will cause flooding, which $
set #Zelda("roleplay") "This channel (#Zelda) is meant for general discussion, not roleplaying. If you want to roleplay, join #RolePlay."
set #Zelda("nice") "The most important rule: be nice. Do not harass others be needlessly highlighting them (saying there name/nick). If they don't want to $
set #Zelda("agreement") "As with most communities, this chat room has rules. We (the moderators of this chat room) expect you to follow them at all times. $
set #Zelda("overview") "An overview of the rules: do not flood; do not post large amounts of text into the chat room, change nicks frequently, or rejoin th$
set #Zelda("unknown") "Unknown rule option. Syntax: !rule <option>. The options are:"
set #Zelda("options") [list "nick" "flood" "ads" "fights" "beg" "mature" "profanity" "scripts" "roleplay" "nice" "agreement" "overview" "default" "options"]
set #Hyrule_Castle("agreement") "You must keep this channel away from prying eyes (non-staff are not welcomed here)."
set #Hyrule_Castle("overview") "This is TZCN's Staff Channel. If you are not staff, get out. Otherwise, no rules. :)"
set #Hyrule_Castle("unknown") "Hey! There aren't any rules, okay!? Two options:"
set #Hyrule_Castle("options") [list "overview" "agreement"]
bind pub -|- "!rules" rules::showrules
proc showrules {nick uhost hand chan args} {
if { [set [subst $chan]("options")] == "" } { putnotc $nick "I do not know the rules for $chan. Be sure to ask the moderators." }
elseif {[lsearch $arg [set [subst $chan]("options")] != -1} { putnotc $nick [set [subst $chan]("options")] }
else {
join opts ", "
putnotc $nick "[set [subst $chan](unknown)] [set [subst $chan](options)]."
putnotc $nick "[set [subst $chan](agreement)]"
}
}
}
I'm trying to create a rules script. I can't seem to get it to work and my only solution (above) is turning out to be more complex than I had hoped.
Can someone help me?
I get this
Tcl error [rules::showrules]: can't read "#Hyrule_Castle("options")": no such variable
...
I'm trying to create a rules script. I can't seem to get it to work and my only solution (above) is turning out to be more complex than I had hoped.
...
[/quote]
As for this being the "only" solution... ... here's what I do, for what it may be worth -
I use this script:
holm-news.tcl 4.0 Displays the contents of a news file when a trigger is used.
found here:
http://www.egghelp.org/tclhtml/3478-4-0-0-1-holm-news.htm
to display channel rules.
I do change the trigger word.
All it does, is read a text file and display it.
Edit the script, and change the trigger to suit yourself, create a text file with your rules in it, and you are in business. :)
I hope one of these ideas helps.
A Hylian Human wrote:I'm trying to create a rules script. I can't seem to get it to work and my only solution (above) is turning out to be more complex than I had hoped.
Can someone help me?
I get this
Tcl error [rules::showrules]: can't read "#Hyrule_Castle("options")": no such variable
whenever I type
!rules
I just don't know what to do.
The problem is very simple. You forgot to link your "global" variables to the "local" scope of your procedure. I've corrected your procedure below and commented the single line I added, and you had some line with ( join opts ", " ) which is not anything resembling tcl..
Since the variables are within a given namespace ("rules"), using global as suggested by speechles is incorrect. Instead, you should either use fully qualified namespace paths, or the "variable" command to link the variable from the current namespace into your proc.
For reading arrays, I'd suggest using the "array" command such as this: