Elrick's @doing Machine

From Gwen Morse's Wiki
Jump to: navigation, search
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; This is a (very rough) translation of Eldrik's @doing machine code
;;; to TF macros. No need for a parentable object on the MUSH to run it.
;;;
;;; To Use: Put this in your .tfrc. Once loaded in, type '/dohelp' for 
;;; command list.
;;;
;;; Original code by Eldrik@AmberMUSH. Modified for TF by Rina@pobox.com.
;;;
;;; Updated to work under tf40 by Gwen Morse (with mail list help)

/def -i dolist = @pemit me=Stored \
	@doings:[iter(lnum(words(v(doings_list),|)),\%r[add(##,1)]. \
	[extract(v(doings_list),add(##,1),1,|)])]
/def -i doset = @switch [and(lte(%*,words(v(doings_list),|)), \
	gt(%*,0))]=1,{@fo [setq(0,extract(v(doings_list),%1,1,|))]me= \
	@doing [r(0)];@pemit me=@doing set: [r(0)]},@pemit me=That is not \
	the number of a stored @doing.
/def -i doswap = @switch and(lte(%1,words(v(doings_list),|)), \
	gt(%1,0),lte(%2,words(v(doings_list),|)),gt(%2,0))=1,{&doings_list \
	me=[setq(0,extract(v(doings_list),%1,1,|))][replace(replace( \
	v(doings_list),%1,extract(v(doings_list),%2,1,|),|),%2,r(0),|)]; \
	@pemit me=@doings swapped.},@pemit me=At least one selection is invalid.
/def -i dorand = @fo [setq(0,extract(v(doings_list), \
	add(rand(words(v(doings_list),|)),1),1,|))]me=@doing [r(0)]; \
	@pemit me=@doing set: [r(0)]
/def -i dodel = @switch [and(lte(%*,words(v(doings_list),|)), \
	gt(%*,0))]=1,{&doings_list me=[ldelete(v(doings_list),{%*},|)]; \
	@pemit me=@doing deleted.},@pemit me=That is not a number of a \
	stored @doing.
/def -i dohelp = /echo @doing Machine commands:%;/echo%;/echo /dolist: List \
	stored @doings.%;/echo /doadd <text>: Add an @doing.%; \
	/echo /dodel <#>: Delete a stored @doing.%; \
	/echo /doset <#>: Set your @doing to a stored one.%; \
	/echo /dorand: Set your @doing randomly.%; \
	/echo /doswap <#> <#>: Swap one @doing with another.%; \
	/echo%;/echo Original code by Eldrik@AmberMUSH. Modified for TF \
	by Rina@pobox.com.
/def -i doadd = @switch gt(strlen(%*),40)=1,@pemit me={@doing is too long \
	-- not saved. ([strlen(%*)] chars, 40 max)},{@switch words( \
	v(doings_list),|)=0,&doings_list me={%*},{&doings_list me=[edit( \
	v(doings_list),$$,|{%*})]};@pemit me=@doing added.}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;