Whatclaim (uses Claim Array)

From Gwen Morse's Wiki
Jump to: navigation, search

The /whatclaim command uses Galvin's Virtual Array. This array code is duplicated in Utilities (used to be "Mylib.tf"). This command also needs the Claim Array

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; What Claim am I in?
;;; type /whatclaim when standing in the FIRST ROOM of the claim
;;; needs Galvin's array as well as the claim array database.

/require lisp.tf

/def -F -p20 -T"tiny.mush.cm" whatclaim = \
  /send -w @pemit me=The first room of the claim I'm in is: [name(loc(me))]%;\

/def -F -T"tiny.mush.cm" -mregexp -t"^The first room of the claim I'm in is: ([A-Za-z0-9- ]+)" claim_namesearch = \
  /set CLAIM_FIRST_ROOM=%P1%;\
  /_echo Claim room: %{CLAIM_FIRST_ROOM}%;\
  /test CLAIM_ROOM_LIST := searchstr_2array("claim", "0", "1", "164","%{CLAIM_FIRST_ROOM}")%;\
  /send -w credits%;\
  /repeat -1 -w 1 /builder_loop %{CLAIM_ROOM_LIST}

/def builder_loop = \
  /if ({#}) \
    /set CLAIM_NUM=%{1}%;\
    /test CLAIM_ARRAY_BUILDER := get_2array("claim", "%{CLAIM_NUM}", "2")%;\
    /if ({CLAIM_ARRAY_BUILDER} =~ {CLAIM_BUILDER}) \
      /test CLAIM_PATH := get_2array("claim", "%{CLAIM_NUM}", "3")%;\
      /list2array claim %{CLAIM_NUM}%;\
      /_echo Path: %{CLAIM_PATH}%;\
    /else \
      /shift %;\
      /repeat -1 -w 1 /builder_loop %{*} %;\
    /endif%;\
  /endif

;;; Regexp match fixed by Tommy (hair at vnet dot net)
/def -F -p20 -T"tiny.mush.cm" -mregexp -t'^This claim was built by ([A-Za-z-,& \(\)\;\:]+)(\.|\.\.)$' claim_builder = \
        /set CLAIM_BUILDER=%P1

;;;
;;; Type /path after you've used /whatclaim to see the path and the LZ (if known).
;;; Path does not (yet) work with multi-path claims.

/def -F -p20 -T"tiny.mush.cm" path = \
  /send -w @pemit me=%{CLAIM_PATH}%;\
  /send -w @pemit me=%{locsaved}
;;;
;;; What Claim am I in?
;;; type /whatclaim when standing in the FIRST ROOM of the claim
;;; needs Galvin's array as well as the claim array database.

/require lisp.tf

/def -F -p20 -T"tiny.mush.cm" whatclaim = \
  /send -w @pemit me=The first room of the claim I'm in is: [name(loc(me))]%;\

/def -F -T"tiny.mush.cm" -mregexp -t"^The first room of the claim I'm in is: ([A-Za-z0-9- ]+)" claim_namesearch = \
  /set CLAIM_FIRST_ROOM=%P1%;\
  /_echo Claim room: %{CLAIM_FIRST_ROOM}%;\
  /test CLAIM_ROOM_LIST := searchstr_2array("claim", "0", "1", "164","%{CLAIM_FIRST_ROOM}")%;\
  /send -w credits%;\
  /repeat -1 -w 1 /builder_loop %{CLAIM_ROOM_LIST}

/def builder_loop = \
  /if ({#}) \
    /set CLAIM_NUM=%{1}%;\
    /test CLAIM_ARRAY_BUILDER := get_2array("claim", "%{CLAIM_NUM}", "2")%;\
    /if ({CLAIM_ARRAY_BUILDER} =~ {CLAIM_BUILDER}) \
      /test CLAIM_PATH := get_2array("claim", "%{CLAIM_NUM}", "3")%;\
      /list2array claim %{CLAIM_NUM}%;\
      /_echo Path: %{CLAIM_PATH}%;\
    /else \
      /shift %;\
      /repeat -1 -w 1 /builder_loop %{*} %;\
    /endif%;\
  /endif

;;; Regexp match fixed by Tommy (hair at vnet dot net)
/def -F -p20 -T"tiny.mush.cm" -mregexp -t'^This claim was built by ([A-Za-z-,& \(\)\;\:]+)(\.|\.\.)$' claim_builder = \
        /set CLAIM_BUILDER=%P1

;;;
;;; Type /path after you've used /whatclaim to see the path and the LZ (if known).
;;; Path does not (yet) work with multi-path claims.

/def -F -p20 -T"tiny.mush.cm" path = \
  /send -w @pemit me=%{CLAIM_PATH}%;\
  /send -w @pemit me=%{locsaved}

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