Idler

From Gwen Morse's Wiki
Jump to: navigation, search
; TinyFugue no-idle script.
;
; by Christian J.  Robinson <infynity at onewest dot net>
; Runs a command every 5 to 15 minutes.  (The time is random.)
;
; Set the variable 'Idler_Exclude_Worlds' with a | between each world name to
; exclude worlds from the idle trigger /send command.  Eg:
; /set Idler_Exclude_Worlds=foo|bar|baz
;
; -----------------------------------------------------------------------------
; RCS:
; $Id: idler.tf,v 1.3 2002/01/20 22:53:59 infynity Exp $
; $Log: idler.tf,v $
; Revision 1.3  2002/01/20 22:53:59  infynity
; Idler_Exclude_Worlds feature added.
; Don't set idlerpid if it's already set.
;
; Revision 1.2  2000/09/10 21:48:33  infynity
; Removed extra junk that I'd commented out.
;
; Revision 1.1  1999/07/12 08:25:55  infynity
; Initial revision
;

/loaded __OWNLILB__/idler.tf

/require lisp.tf

/eval /set idlerpid $[idlerpid ? : -1]

/def -i idler = \
	/if ({idlerpid} == -1) \
		/_idler %; \
		/echo %% No-Idle loop started. %; \
	/else \
		/echo %% No-Idle loop already running. %; \
	/endif

/def -i _idler = \
	/let _worlds= %;\
	/let _line= %;\
	/listsockets -s %| /while (tfread(_line) >= 0) \
		/if /eval /test '%_line' !/ '{%Idler_Exclude_Worlds}' %;\
		/then \
			/let _worlds=%_worlds %_line %;\
		/endif %; \
	/done %;\
	/for i 1 $(/length %{_worlds}) \
		/send -w\$(/nth \%{i} \%{_worlds}) \\\\ %;\
	/repeat -0:$[rand(5,15)]:$[rand(60)] 1 /_idler %;\
	/set idlerpid %?

;/def -i _idler = \
;	/send -W \\ %;\
;	/repeat -0:$[rand(5,15)]:$[rand(60)] 1 /_idler %;\
;	/set idlerpid %?

/def -i killidler = \
	/if ({idlerpid} != -1) \
		/kill %idlerpid %; \
		/set idlerpid -1 %; \
		/echo %% No-Idle loop killed. %; \
	/else \
		/echo %% No-Idle loop not running. %; \
	/endif

/def -i ki = /killidler