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.

update global command

Help for those learning Tcl or writing their own scripts.
Post Reply
j
jeroen_005
Voice
Posts: 19
Joined: Sun Jun 22, 2008 7:47 am

update global command

Post by jeroen_005 »

Currently I have following global script


Code: Select all

bind pub -|- "!global" PubGlobal
setudef flag staff
proc PubGlobal {nick host hand chan text} {
 if {[channel get $chan staff]} {
  if {$text == ""} {
   puthelp "PRIVMSG $chan :\002FOUT:\002 Gelieve een global op te geven."
  } else {
   puthelp "PRIVMSG #twor :\002GLOBAL:\002 \[ \00307$nick\00301 \] $text"
   puthelp "PRIVMSG #tworSTAFF :\002GLOBAL:\002 \[ \00307$nick\00301 \] $text"
   puthelp "PRIVMSG #tworPA :\002GLOBAL:\002 \[ \00307$nick\00301 \] $text"
   putloglev p "#twor" "<TWOR_LOG> \002GLOBAL:\002 \[ \00307$nick\00301 \] $text"
   return 1
  }
 }
}
But i would like to change it so $nick can be specified.

Something like this:

!setperson My Name
!pglobal Tekst

GLOBAL: [ My Name ] Tekst

Code: Select all

bind pub -|- "!setperson" PubPerson
setudef flag staff
proc PubPerson {nick host hand chan text} {
 if {[channel get $chan staff]} {
  if {$text == ""} {
   puthelp "PRIVMSG $chan :\002FOUT:\002 Gelieve een naam op te geven."
  } else {
   puthelp "PRIVMSG $chan :\002NEW PERSON:\002 $text"
   set person $text
   return 1
  }
 }
}

bind pub -|- "!pglobal" PubpGlobal
setudef flag staff
proc PubpGlobal {nick host hand chan text} {
 if {[channel get $chan staff]} {
  if {$text == ""} {
   puthelp "PRIVMSG $chan :\002FOUT:\002 Gelieve een p-global op te geven."
  } else {
   puthelp "PRIVMSG #tworSTAFF :\002GLOBAL:\002 \[ \00307$person\00301 \] $text"
   putloglev p "#twor" "<TWOR_LOG> \002GLOBAL:\002 \[ \00307$person\00301 \] $text"
   return 1
  }
 }
}
Currently I got this but this doesn't work, any suggestions?
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Re: update global command

Post by speechles »

jeroen_005 wrote:Currently I got this but this doesn't work, any suggestions?
Ironically, you've forgotten to global variables in your global message script. Add this line:

Code: Select all

global person
As the very first line below both your procedures. This will allow the local-space variable "person" to carry across into global space. Otherwise the contents of this local-space variable will be destroyed at the end of the procedure. This allows two procedures to share the same variable/contents without having to be passed during invocation.
Post Reply