Kareila's Fugue Edit

From Gwen Morse's Wiki
Jump to: navigation, search
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; defining Improved Fugue Edit command
;;;
;;; FROM: http://www.chaoticmux.org/~kareila/TF/
;;;
;;; FugueEdit macro (ed obj/attr)
;;; Probably the most common tf macro out there is one that will grab the text of 
;;; an attribute into the input buffer for editing. The incarnation I was given required
;;; some softcode to implement, and the only tf-side code you had to define was the 
;;; gag-trigger that got the input. This worked, but I was annoyed that I had to
;;; port this piece of softcode to every game I was on. So I recoded it to be 
;;; defined entirely within tf. It uses the usual syntax: "/ed <obj>/<attr>".
;;;
;;; FugueEdit macro (ed obj/attr) coded by Kareila@ChaoticMUX
;;;  based on mushcode that originated with van@TinyTIM
;;;  and has mutated several times since then.
;;; Thanks to Gwen Morse for the incentive to make improvements.  :)
;;;
;;; Gwen: works -- very nice! And, look, I get credit for "inspiring" improvements!


; edmarker can be anything you like - no spaces allowed.

/set edmarker FugueEdit
/eval /def -p100 -ag -t'%{edmarker} > *' edtrig = /grab %%-2

/def ed = \
	/if (regmatch('/',{*})) \
		/let edobj %PL %; \
		/let edattr %PR %; \
		/def -n1 -t#* -q -ag tempedtrig = \
			@pemit me = switch(%%*, \
			#-1, I don't see that here., \
			#-2, I don't know which one you mean!, \
			%{edmarker} > &%{edattr} %{edobj} = \
			[get(%%*/%{edattr})]) %; \
		/send @pemit me = locate(me, %{edobj}, *) %; \
	/else /echo %% %{edmarker}: ed argument must be of form <obj>/<attr> %; \
	/endif
/def -h"send ed *" edhook = /ed %-1

/def ng = \
	/if (regmatch('/',{*})) \
		/echo %% %{edmarker}: ng argument must be a valid object name %; \
	/else \
		/def -n1 -t#* -q -ag tempngtrig = \
			@pemit me = switch(%%*, \
			#-1, I don't see that here., \
			#-2, I don't know which one you mean!, \
			%{edmarker} > @name %* = [translate(fullname(%%*))]) %; \
		/send @pemit me = locate(me, %*, *) %; \
	/endif
/def -h"send ng *" nghook = /ng %-1

/def lock = \
	/if (regmatch('/',{*})) \
		/let edobj %PL %; \
		/let edattr %PR %; \
		/def -n1 -t#* -q -ag templocktrig = \
			@pemit me = switch(%%*, \
			#-1, I don't see that here., \
			#-2, I don't know which one you mean!, \
			%{edmarker} > @lock/%{edattr} %{edobj} = \
			[lock(%%*/%{edattr})]) %; \
		/send @pemit me = locate(me, %{edobj}, *) %; \
	/else \
		/def -n1 -t#* -q -ag templocktrig = \
			@pemit me = switch(%%*, \
			#-1, I don't see that here., \
			#-2, I don't know which one you mean!, \
			%{edmarker} > @lock %* = [lock(%%*)]) %; \
		/send @pemit me = locate(me, %*, *) %; \
	/endif
/def -h"send lock *" lockhook = /lock %-1

/def edhelp = \
	/echo -p @{h}ed <obj>/<attr>:@{n} \
		edits the given attribute on the given object. %; \
	/echo -p @{h}ng <obj>:@{n} \
		grabs the name of the given object for editing. %; \
	/echo -p @{h}lock <obj>[/<type>]:@{n} \
		edits the given lock (default lock if no type given).