Mise en forme de code: pensez à utiliser les balises [ tcl ] et [ /tcl ] (sans les espaces bien sûr) autour de vos codes tcl afin d'avoir un meilleur rendu et une coloration syntaxique. x


Timer TCL
#9
salut,

pour ceux que ça intéresserais voila le utimer de eggdrop recodé entièrement en tcl pur avec after (comprend le killutimer et utimers)

tcl
proc timer {time proc} {
 variable timers
  set timerid [after [expr $time*1000] $proc]
  lappend timers "[expr [unixtime] + $time] $proc $timerid" 
  set after($timerid) [after [expr $time*1000] "[namespace current]::unsettimers {[expr [unixtime] + $time] $proc $timerid}"] 
  return $timerid
}
 
proc unsettimers {id} {
 variable timers
  if {[info exists timers] && $timers!=""} {
    set find [lsearch -exact $timers "$id"]
    if {$find!="-1"} {
      set timers [lreplace $timers $find $find]
    }
  }
}
 
proc timers { } {
 variable timers
  if {[info exists timers] && $timers!=""} {
    foreach u $timers {
      set u [charfilter $u]
      set t [lindex $u 0]
      set t [expr $t - [unixtime]]
      lappend ut "$t {[join [lrange $u 1 [expr [llength $u] - 2]]]} [lindex $u end]"
    }
    return $ut
  }
  return
}
 
proc killtimer {timerid} {
 variable timers
  if {[info exists timers] && $timers!=""} {
    foreach u $timers {
      if {[lindex $u end]==$timerid} {
        unsettimers $u
        catch {after cancel $timerid}
      }
    }
  }
}

C'est en reconnaissant ses erreurs que l'on progresse ;)
Away


Messages In This Thread
Timer TCL - by BlackNight - 05/07/2009, 13:29
RE: Timer TCL - by fedora - 05/07/2009, 15:40
RE: Timer TCL - by BlackNight - 05/07/2009, 16:01
RE: Timer TCL - by fedora - 05/07/2009, 16:05
RE: Timer TCL - by Artix - 06/07/2009, 09:46
RE: Timer TCL - by fedora - 06/07/2009, 09:55
RE: Timer TCL - by Artix - 06/07/2009, 19:53
RE: Timer TCL - by fedora - 06/07/2009, 21:04
RE: Timer TCL - by djkenny - 07/07/2009, 02:11
RE: Timer TCL - by djkenny - 07/07/2009, 02:14
RE: Timer TCL - by David - 18/07/2009, 11:17
RE: Timer TCL - by BlackNight - 09/08/2009, 02:36
RE: Timer TCL - by Babytigrou16 - 09/08/2009, 18:13
RE: Timer TCL - by BlackNight - 09/08/2009, 19:48
RE: Timer TCL - by DodY - 13/02/2010, 19:11
RE: Timer TCL - by DodY - 13/02/2010, 19:42

Possibly Related Threads…
Thread Author Replies Views Last Post
  timer KeeViiNou 1 1,199 20/08/2020, 18:19
Last Post: CrazyCat
  [Résolu] problème de timer sur un unban Alucard`68 6 3,775 18/04/2017, 15:25
Last Post: Alucard`68
  timer ban Marc 9 5,345 22/12/2009, 12:10
Last Post: CrazyCat
  Timer en Tcl Meribre 4 4,987 17/12/2009, 17:53
Last Post: Meribre
  erreur dans un timer caline012 2 4,663 17/10/2008, 13:52
Last Post: caline012

Forum Jump:


Users browsing this thread: 1 Guest(s)