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.

mrc to tcl

Help for those learning Tcl or writing their own scripts.
Post Reply
L
Leon--
Voice
Posts: 14
Joined: Sat Sep 02, 2023 8:35 am

mrc to tcl

Post by Leon-- »

Hi,
The next text i want it in tcl. i tried but it is not done for me.
I don't no why but for me it's complicated.

Code: Select all

on users:text:!pay*:#: {
  if (%cmd == on) { goto begin }
  if (%cmd == off) { goto end | halt }
  :begin
  if ($2 == topic) { goto topic }
  if ($2 == cola) { goto cola }
  :topic
  if ( $readini(users.ini,users,$nick) <= 10) { /notice $nick U heeft niet genoeg geld. }
  else { /set %nick $nick | /notice $nick Er wordt €10.00 afgeschreven. | /msg $me calc $readini(users.ini,users,$nick) - $readini(bar.ini,bar,topic) | /topic $chan $3- | /timer 1 300 topic $chan $readini(topic.ini,topic,1) | /set %cmd off | /timer 1 90 /set %cmd on | halt }
  :cola
  if ( $readini(users.ini,users,$nick) <= 2.50) { /notice $nick U heeft niet genoeg geld. }
  else { /set %nick $nick | /notice $nick Er wordt €2.50 afgeschreven. | /msg $me calc $readini(users.ini,users,$nick) - $readini(bar.ini,bar,cola) | /ame geeft $nick een lekker koud glas cola, met ijsklontjes. | /set %cmd off | /timer 1 90 /set %cmd on | halt }
  :end
  /notice $nick De cmd is momenteel uitgeschakeld.
}
Thanks for some help.
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Re: mrc to tcl

Post by willyw »

Leon-- wrote:Hi,
The next text i want it in tcl. i tried but it is not done for me.
I don't no why but for me it's complicated.
...

As it is right now, the number of people here that even can respond to your request is limited to those that can interpret the code that you have posted.

Many here know TCL. :)

I don't know how many know that code that you posted. I _think_ that it is mIRC code. Not sure.

So -
If you don't get a response here within a couple days, perhaps you could describe - line by line might be best - just what that code is doing. Your post implies that you do understand that code, so you can do this.

Let's see what other replies you get in here. :)
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
Online
User avatar
CrazyCat
Revered One
Posts: 1300
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

And even if I can read mIRC's code, without the users.ini and the bar.ini, I can't really help.

As willyw said, it's probably better to describe what your script does
L
Leon--
Voice
Posts: 14
Joined: Sat Sep 02, 2023 8:35 am

Post by Leon-- »

If this scripts works and some one type .pay topic that er will be removed 10 euro's from the user account and if they type !register they will be added to the userlist and get 50 euro to expand by this robot. This is a little bit the intention to work. I hope you can help me :)
Online
User avatar
CrazyCat
Revered One
Posts: 1300
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

CrazyCat wrote:And even if I can read mIRC's code, without the users.ini and the bar.ini, I can't really help.
L
Leon--
Voice
Posts: 14
Joined: Sat Sep 02, 2023 8:35 am

Post by Leon-- »

This is in the bar.ini

Code: Select all

[bar]
topic=10
cola=2.50
sigaret=0.50
and the users.ini is

Code: Select all

[users]
Leon=470.5
This means i have 470.5 euro's, the topic costs 10 euro's and so on
Online
User avatar
CrazyCat
Revered One
Posts: 1300
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Ok, I don't think using .ini files is the best solution with eggdrop script, unless you really want it.
How are users added in the users.ini ?
L
Leon--
Voice
Posts: 14
Joined: Sat Sep 02, 2023 8:35 am

Post by Leon-- »

This is in tcl script

Code: Select all

bind pub - ${trigger}register pub:register
proc pub:register {nick host hand chan arg} {
  set fname "money.txt"
  set fp [open $fname "r"]
  set data [read -nonewline $fp]
  close $fp
  set lines [split $data "\n"]
  set searchresult ""
  foreach line $lines {
     if {[string match *$nick* [join $line]]} {
        lappend searchresult $line
     }
     if {[$nick == "[lindex [split [join $searchresult] "|"] 0]"} {
        putserv "NOTICE $nick :Je bent al een keer hier geweest."
        return 0
     }
     set linetoadd "$nick|50"
     set fname "money.txt"
     set fp [open $fname "a"]
     puts $fp $linetoadd
     close $fp
     putserv "NOTICE $nick :U heeft 50 euro gekregen om uit te geven aan de bar."
     return 0
  }
}
L
Leon--
Voice
Posts: 14
Joined: Sat Sep 02, 2023 8:35 am

Post by Leon-- »

Ok, I don't think using .ini files is the best solution with eggdrop script, unless you really want it.
How are users added in the users.ini ?
How would you do it then, yes it's beter by host. but i have no idea how.[/quote]
Online
User avatar
CrazyCat
Revered One
Posts: 1300
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Here is a little version:

Code: Select all

namespace eval leon {

   variable ulist "users.txt"
   variable items
   set items(topic) {10 ""}
   set items(cola) {2.50 "geeft %nick% een lekker koud glas cola, met ijsklontjes."}
   set items(sigaret) {0.50 "geeft %nick% een peuk"}

   variable trigger "!"
   
   variable lastuse 0
   
   proc reguser {nick uhost handle chan text} {
      set fi [open $::leon::ulist r]
      set users [split [read -nonewline $fi] "\n"]
      close $fi
      set uid [lsearch -glob -nocase $users "$nick|*"]
      if {$uid >= 0} {
         putserv "NOTICE $nick :Je bent al een keer hier geweest."
      } else {
         set fo [open $::leon::ulist a]
         puts $fo "[string tolower $nick]|50"
         close $fo
         putserv "NOTICE $nick :U heeft 50 euro gekregen om uit te geven aan de bar."
      }
   }
   
   proc pay {nick uhost handle chan text} {
      set now [clock seconds]
      if {[expr $now - $::leon::lastuse]<90} {
         putserv "NOTICE $nick :De cmd is momenteel uitgeschakeld."
         return 0
      }
      set item [join [lindex [split $text] 0]]
      set rest [join [lrange [split $text] 1 end]]
      if {![info exists ::leon::items($item)]} {
         putserv "NOTICE $nick :Sorry, I don't know what $item is"
         return 0
      }
      set val [lindex $::leon::items($item) 0]
      set utext [lindex $::leon::items($item) 1]
      set utext [string map [list "%nick%" $nick] $utext]
      set fi [open $::leon::ulist r]
      set users [split [read -nonewline $fi] "\n"]
      close $fi
      set uid [lsearch -glob -nocase $users "$nick|*"]
      if {$uid == -1 || [lindex [split [lindex $users $uid] "|"] 1]<$val} {
         putserv "NOTICE $nick :U heeft niet genoeg geld."
         return 0
      }
      if {$item eq "topic"} {
         putserv "TOPIC $chan :$rest"
      } else {
         putserv "NOTICE $nick :Er wordt €$val afgeschreven."
         putserv "PRIVMSG $chan :\001ACTION $utext\001"
      }
      ::leon::debt $nick $val
      set ::leon::lastuse [clock seconds]
   }
   
   proc debt {nick val} {
      set fi [open $::leon::ulist r]
      set users [split [read -nonewline $fi] "\n"]
      close $fi
      set fo [open $::leon::ulist w]
      foreach e $users {
         if {[string match -nocase "$nick|*" $e]} {
            lassign [split $e "|"] u v
            set v [expr $v - $val]
            puts $fo "$nick|$v"
         } else {
            puts $fo $e
         }
      }
      close $fo
   }
   
   bind pub - ${trigger}register ::leon::reguser
   bind pub - ${trigger}pay ::leon::pay
}
L
Leon--
Voice
Posts: 14
Joined: Sat Sep 02, 2023 8:35 am

Post by Leon-- »

Thanks for this :)
L
Leon--
Voice
Posts: 14
Joined: Sat Sep 02, 2023 8:35 am

Post by Leon-- »

Can you also made a little script to see how much money some one have with the command !money and from the same users.txt Thanks alot for this, the script you made i like it very much.
Online
User avatar
CrazyCat
Revered One
Posts: 1300
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Just add the following code in the script (before the bind lines):

Code: Select all

   proc money {nick uhost handle chan text} {
      set fi [open $::leon::ulist r]
      set users [split [read -nonewline $fi] "\n"]
      close $fi
      set uid [lsearch -glob -nocase $users "$nick|*"]
      if {$uid == -1} {
         putserv "NOTICE $nick :Sorry, maar u bent niet bekend"
         return
      }
      putserv "NOTICE $nick :Je hebt momenteel €[lindex [split [lindex $users $uid] "|"] 1] in je portemonnee"
   }
   
   bind pub - ${trigger}money ::leon::money
The final tcl is not optimised as some pieces of code a used in different places
L
Leon--
Voice
Posts: 14
Joined: Sat Sep 02, 2023 8:35 am

Post by Leon-- »

Thanks for this script :)
Post Reply