-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCORE 12 - Region System.txt
77 lines (44 loc) · 8.55 KB
/
CORE 12 - Region System.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
@@ ZONEMASTER SCHEMA?
@skip isdbref(tag(setr(1,reg)))={@assert/inline isdbref(globalroom())=@pemit %#=ERROR: No master room set!;@assert/inline isdbref(setr(0,create(Region System,,t)))=@pemit %#=ERROR: Could not create code object %q1: %q0;@set %q0=INDESTRUCTIBLE !NO_COMMAND;@tag/add %q1=%q0;@tel %q0=globalroom()}
@@ Commands and stuff.
&CMD.REGION #reg=$^(?s)(?\:\+)(reg|region|zdig|zopen)(?\:/(\\S+)?)?(?\: +(.+?))?(?\:=(.*))?$:th setq(!,switch(%1,reg,region,region,region,zdig,zdig,zopen,zopen),family);@attach #inc/GET_SWITCH=%2,%q<family>;@attach %!/SW.%q<family>.[strfirstof(%q<switch>,MAIN)]=%3,%4
@set #reg/CMD.REGION=regexp
&LOCK_USE #reg=[gtebittype(%#,2)]
@lock/use #reg=LOCK_USE/1
&SWITCHES.REGION.0 #reg=LIST
&SWITCHES.REGION.5 #reg=CREATE|RENAME|DELETE|GRANT|REVOKE
&FN.SEARCH #reg=searchngobjid([tag(gm)] TOTEMS=R)
&FN.SEARCH_NAME #reg=searchngobjid([tag(gm)] ETHING=\[cand(hastotem(##,REGION),strmatch(name(##),%0*))\])
&FIL.ROOTS #reg=!hasattr(%0/GAME.UPZONES)
&FN.ROOTS #reg=filter(FIL.ROOTS,u(FN.SEARCH))
&FIL.ROOM #reg=hastype(%0,ROOM)
&FN.ROOMS #reg=filter(FIL.ROOM,lzone(%0))
&FIL.BRANCH #reg=hastotem(%0,REGION)
&FN.BRANCHES #reg=filter(FIL.BRANCH,setunion(lcon(%0,THING),zlcon(%0,THING)))
&FN.FIND_REGION #reg=namegrab(u(FN.SEARCH_NAME,%0),%0)
&SW.REGION.MAIN #reg=@if strlen(%0)={@attach %!/INC.LIST=Regions Beginning with: %0,u(FN.SEARCH_NAME,%0)},{@attach %!/INC.LIST=Regions Tree,u(FN.ROOTS),0}
&FN.LIST_COLUMNS #reg=printf($-5s $-5s $-55s,Dbref,Mcnt,Name)
&FN.LIST_ROW #reg=printf($-5s $-5s $-55s,num(%0),words(lzone(%0)),[if(gt(%1,0),space(%1)-%B)][cname(%0)])
&DEPTH #reg=@if setr(!,add(words(%0),%q<total>),total)={@dolist/inline %0={@pemit %#=u(FN.LIST_ROW,%d0,%1);@if cand(strlen(%1),words(setr(!,u(FN.BRANCHES,%d0),branches)))={@attach %!/DEPTH=%q<branches>,inc(%1)}}}
&INC.LIST #reg=@pemit %#=header(%0);@pemit %#=ansi(confoverride(%#,COLUMN),u(FN.LIST_COLUMNS));@pemit %#=subheader();@attach %!/DEPTH=%1,%2;@pemit %#=footer(Total: %q<total>)
&INC.FINDREG #reg=@assert/inline strlen(%0)=@pemit %#=Region name field empty.;@assert/inline isdbref(setr(!,u(FN.FIND_REGION,%0),%1))=@pemit %#=Region '%0' not found.
&FN.SEARCH_BUILDER #reg=searchngobjid([tag(gm)] ETHING=\[cand(hastotem(##,REGION),elock(##/ZoneWizLock,num(%0)))\])
&SW.REGION.LIST #reg=@attach %!/INC.LIST=Your Buildable Regions,u(FN.SEARCH_BUILDER,%#)
&SW.REGION.CREATE #reg=@assert/inline valid(name,stripansi(%0))=@pemit %#=That's not a good name for a region.;@assert/inline setr(!,create(stripansi(%0),,t),reg)=@pemit %#=ERROR: %q<reg>;@if has_markup(%0)={@name/ansi %q<reg>=%0};@attach %!/INIT.REGION=%q<reg>;@pemit %#=Region [objid(%q<reg>)] '[cname(%q<reg>)]' Created.;@attach #inc/MSG_ALERT=Region [objid(%q<reg>)] '[cname(%q<reg>)]' Created.
&SW.REGION.RENAME #reg=@attach %!/INC.FINDREG=%0,reg;@assert/inline valid(name,stripansi(%1))=@pemit %#=That's not a good name for a region.;th setq(!,cname(%q<reg>),oldname);@if has_markup(%0)={@name/ansi %q<reg>=%0},{@name %q<reg>=%0};@pemit %#=Region [objid(%q<reg>)] '%q<oldname>' renamed to: [cname(%q<reg>)];@attach #inc/MSG_ALERT=Region [objid(%q<reg>)] '%q<oldname>' renamed to: [cname(%q<reg>)]
&FN.SAFEDELETE #reg=ofparse(3,if(!words(lzone(%0)),1,#-1 ZONE HAS MEMBERS. DEAL WITH THEM FIRST.),if(!lcon(%0,,,,,1),1,#-1 ZONE HAS lcon() CONTENTS. DEAL WITH IT FIRST.),if(!zlcon(%0,,,,,1),1,#-1 ZONE HAS zlcon() CONTENTS. DEAL WITH IT FIRST),1)
&SW.REGION.DELETE #reg=@attach %!/INC.FINDREG=%0,reg;@assert/inline setr(!,u(FN.SAFEDELETE,%q<reg>),res)=@pemit %#=ERROR: %q<res>;@assert/inline t(match([name(%q<reg>)]|[objid(%q<reg>)],%0,|))=@pemit %#=ERROR: Must have =<objid|name> to verify. Enter as: [ansi(hw,+region/destroy [name(%q<reg>)]=[objid(%q<reg>)])] for instance.;@pemit %#=Destroyed Region [objid(%q<reg>)] '[cname(%q<reg>)]';@attach #inc/MSG_ALERT=Destroyed Region [objid(%q<reg>)] '[cname(%q<reg>)]';@attach %!/DESTROY_REGION=%q<reg>
&SW.REGION.GRANT #reg=@attach %!/INC.FINDREG=%0,reg;@attach #inc/GET_PLAYER=%1,t1;@assert/inline gtebittype(%q<t1>,2)=@pemit %#=They must be at least bittype 2 (Guildmaster) to have build rights.;@break/inline t(match(setr(!,get(%q<reg>/BUILDERS),builders),%q<t1>))=@pemit %#=They are already a Builder for Region [objid(%q<reg>)] '[cname(%q<reg>)]';@set %q<reg>=BUILDERS:[setunion(%q<builders>,objid(%q<t1>))];@pemit %#=Added '[cname(%q<t1>)]' to Builders of Region [objid(%q<reg>)] '[cname(%q<reg>)]';@attach #inc/MSG_ALERT=Added '[cname(%q<t1>)]' to Builders of Region [objid(%q<reg>)] '[cname(%q<reg>)]';@pemit %q<t1>=You have been added to the Builders of Region [objid(%q<reg>)] '[cname(%q<reg>)]'
&SW.REGION.REVOKE #reg=@attach %!/INC.FINDREG=%0,reg;@attach #inc/GET_PLAYER=%1,t1;@assert/inline t(match(setr(!,get(%q<reg>/BUILDERS),builders),%q<t1>))=@pemit %#=They are not a Builder for Region [objid(%q<reg>)] '[cname(%q<reg>)]';@set %q<reg>=BUILDERS:[setdiff(%q<builders>,objid(%q<t1>))];@pemit %#=Removed '[cname(%q<t1>)]' from Builders of Region [objid(%q<reg>)] '[cname(%q<reg>)]';@attach #inc/MSG_ALERT=Removed '[cname(%q<t1>)]' from Builders of Region [objid(%q<reg>)] '[cname(%q<reg>)]';@pemit %q<t1>=Your Builder rights for Region [objid(%q<reg>)] '[cname(%q<reg>)]' have been revoked.
&INIT.REGION #reg=@set %0=ZONEMASTER INDESTRUCTIBLE;@totem %0=REGION;@parent %0=#reg_parent;@chown/preserve %0=[tag(gm)]
&DESTROY_REGION #reg=@set %0=!INDESTRUCTIBLE;+zone/purge %0;@set %0=!ZONEMASTER;@totem %0=!REGION;@destroy/override %0
&ZONEASSIGN #reg=@dolist/inline %0={+zone/add %d0=%1;@chown/preserve %d0=[tag(gm)]};
&ZBUILD #reg=th setq(z,lzone(%l));@if words(setr(!,filter(#lambda/[lit(isdbref(%0))],%q<results>),goodobj))={@pemit %#=Created [words(%q<goodobj>)] objects: %q<goodobj>.;@if cand(isdbref(%qz),elock(%qz/ZoneToLock,%#))={@attach %!/ZONEASSIGN=%q<goodobj>,%qz;@pemit %#=Assigned them to Zone %qz: [cname(%qz)] and @chowned to [tag(gm)]: [cname(tag(gm))].}}
&SW.ZDIG.MAIN #reg=@assert/inline strlen(setr(!,objeval(%#,dig(%0,before(%1,chr(44)),after(%1,chr(44)),,1),3),results));@attach %!/ZBUILD
&SW.ZOPEN.MAIN #reg=@assert/inline strlen(setr(!,objeval(%#,open(%0,%1),3),results));@attach %!/ZBUILD
+shelp/add Building/+region=#reg/SHLP.REGION
&SHLP.REGION #reg=The Region System is designed for organizing ZONEMASTER THING objects to ease collaborative building. It also provides a hierarchial structure for laying out game maps.%R%R[ansi(hc,Administrator Commands)]%R%R[ansi(hw,+region)]%R%TList all Regions as a tree structure.%R%R[ansi(hw,+region <name>)]%R%TSearch for regions of a certain name.%R%R[ansi(hw,+region/create <region>)]%R%TCreates a root Region.%R%R[ansi(hw,+region/delete <region>=<name or objid>)]%R%TDelete a region.%R%R[ansi(hw,+region/grant <region>=<player>)]%R%TGrant building rights to a player who's Guildmaster or higher.%R%R[ansi(hw,+region/revoke <region>=<player>)]%R%TRevoke building rights.%R%R[ansi(hc,Hierarchy)]%RRegions are, fundamentally, THING objects with the ZONEMASTER flag set and the REGION totem applied. Although newly created Regions are 'root' regions, you can @tel them inside the inventory of another Region to turn them into Sub-Regions. Alternatively, they can also be placed inside a ROOM assigned to another Region to achieve the same result. This might be used with all manner of code that expands on the concept of Regions. For instance, there might be a Region which represents a chunk of a solar system, that contains other REGION objects for each Planet, and a special command can target the REGIONS to land on the planet.%R%RThe logic for detecting sub-regions uses lcon(region) and zlcon(region) which means a sub-region will not be detected if the object is located inside the inventory of a thing or player.%R%RCircular relationships shouldn't cause anything to explode, but are best avoided.%R%R[ansi(hc,Upzones)]%RThe reverse of the +reg display, upzone(<target>) and upzones(<target>) functions provide a list of all ZONEMASTERS a target is recursively inside. Not all of them need be regions, but it should always end in a chain of them.
+shelp/add Building/+zopen=#reg/SHLP.ZOPEN
&SHLP.ZOPEN #reg=This is basically a version of [ansi(hw,@open)] which will detect if you are inside a Zoned Room. If you pass the Zone's ZoneToLock, then it will automatically assign the created exit to that Room's Zone and @chown/preserve the exit to #gm. It does not support return exits.
+shelp/add Building/+zdig=#reg/SHLP.ZDIG
&SHLP.ZDIG #reg=This is a specialized version of [ansi(hw,@dig)] which will detect if you are inside a Zoned Room. If you pass the Zone's ZoneToLock, then it will automatically assign the created room and exits to that Room's Zone and @chown/preserve them to #gm. It does not support any switches like /teleport.