SpaceMap

Spacemap prints a 25x25 (49x25 trelane_space_map.txtreally) ASCII map of a three-dimensional space, using colour coding to represent the Z axis. Scaling, centering, and changes in perspective are all possible. It should be possible to interface with any three-dimensional space.

Author: Trelane@M*U*S*H
Category: Other
Commands: @name, @pemit, @set, @teleport.
Features: #lambda.
Compatibility: PennMUSH.

Instructions

Copy and paste the below code into a compatible MUSH or MUX.

MUSHCode for SpaceMap

@@ Project Trelane_Spacemap
@@ Version 2
@@
@@ Description:
@@ Spacemap prints a 25x25 (49x25 really) ASCII map of a
@@ three-dimensional space, using colour coding to represent
@@ the Z axis. Scaling, centering, and changes in perspective
@@ are all possible. It should be possible to interface with
@@ any three-dimensional space... See +SPACEMAP HELP <file>, or
@@ contact Trelane @ M*U*S*H for questions or comments.
@@
@@ Version log:
@@ Author: Trelane <FreeVerse>
@@ Date: Fri Apr 3 13:49:18 2009 -0700
@@ v2v
@@
@@ Initial Commit
@@
@@ Readme:
@@ Readme
@@
@@ Language: MushCode
@@ Installer file created by RubySVC (Softcode Version Control)
@@
@@
@@
@@ Creating Rooms, Things and Exits.
@@
@@
@set me=SVC`Td28d66ba70ead917f0aa:[default(SVC`Td28d66ba70ead917f0aa,create(Td28d66ba70ead917f0aa))]
@@
@@
@@ Objects created, now setting attributes, locks, etc.
@@
@@
@@
@@ Filling out SpaceMap
@@
@name [v(SVC`Td28d66ba70ead917f0aa)]=SpaceMap
@tel [v(SVC`Td28d66ba70ead917f0aa)]=v(SVC`owner)
@set [v(SVC`Td28d66ba70ead917f0aa)]=iter(setdiff(lflags([v(SVC`Td28d66ba70ead917f0aa)]),NO_COMMAND),!##) [setdiff(NO_COMMAND,lflags([v(SVC`Td28d66ba70ead917f0aa)]))]
&HSPACE`HS_LIST2COORDS [v(SVC`Td28d66ba70ead917f0aa)]=iter(%0,hs_get_attr(##,x) [hs_get_attr(##,y)] [hs_get_attr(##,z)] [hs_get_attr(##,type)],,if(%1,%1,|))
&HSPACE`EXAMPLE2 [v(SVC`Td28d66ba70ead917f0aa)]=u(spacemap/hspace`example,hs_list(43,0,1),10 5 0,10,1,2,3)
&HSPACE`EXAMPLE [v(SVC`Td28d66ba70ead917f0aa)]=iter(u(spacemap/hspace`draw,%0,%1,%2,%3,%4,%5),rjust(add(switch(sign(sub(#@,13)),-1,abs(sub(#@,13)),0,0,-[sub(#@,13)]),elements(%1,%4)),4) ##,%r,%r)
&HSPACE`DRAW [v(SVC`Td28d66ba70ead917f0aa)]=u(FUN`DRAW.MAP,u(HSPACE`HS_LIST2COORDS,%0),%1,%2,%3,%4,%5)
&HSPACE [v(SVC`Td28d66ba70ead917f0aa)]=HSpace Interface Tree
&HELP`INFO [v(SVC`Td28d66ba70ead917f0aa)]=Direct questions and comments to Trelane@M*U*S*H. If you have a suggestion, or something to add to the system, feel free!%r%rApologies for the help files, and lack of 'user friendliness'.
&HELP`HELP [v(SVC`Td28d66ba70ead917f0aa)]=SpaceMap creates an ASCII map for a set of three-dimensional coordinates, supplied by a space system, user, or other source. Due in part to reasonably small function invocation limits, and size limitations for MUSH clients, the map itself is limited to 25x25 'points.' However, it may be scaled from 1:1, one point per real whole unit, upwards. (For a well-spaced system of objects, between -110 * * and 120 * *, (1:)10 has worked in the past)%rAn experienced coder should be able to interface with the system using just DRAW.MAP, described in its own help file. An example of a simple interface for HSpace is contained under the HSpace tree.%r%r[edit(map(#lambda/center(\%0,78),table(remove(iter(lattr(%!/HELP`*),after(##,HELP`)),HELP),13,78),%r,%r),_,%b)]
&HELP`DRAW.MAP [v(SVC`Td28d66ba70ead917f0aa)]=Syntax: u(FUN`DRAW.MAP,<List of Coords>,<Center>,<Scale>,%r%b<X Axis>,<Y Axis>,<Z Axis>)%r%rThis function is the main function, and theoretically the only one of the DRAW.* functions you should ever need to use. (The thers are there anyway, though, of course) It returns a \%r-separated list of 25 rows of 25 space-separated characters representing 'points' (whole units of some sort) in space.%r%rList of Coords is a pipe (|)-separated list of coordinates in this format: X Y Z TYPE|X Y Z TYPE. X Y and Z in this list are pretty self-explanatory. TYPE is a number used to determine the character to display for this object. (See CONFIGURATION)%rCenter is another coordinate, (X Y Z) used to transpose coordinates to an equivalent position around 0 0 0, before scaling. To correct axis labels, use add(mul(<-12 to 12>,SCALE),<XYZ>) where <XYZ> is from CENTER. If I was labeling X, for example, I'd use iter(lnum(-12,12),round(add(mul(##,SCALE),first(CENTER)),0))%rScale is more or less self-explanatory... The map's scale will be 1:SCALE. That is, 1 point on the map to SCALE 'real' points.%rThe X/Y/Z Axis fields are more or less the most confusing parameters. They indicate which of the three True Axes should be used as the Map Axes. 1, 2 and 3 correspond to True X, Y and Z. So, for example, I'd use '...,2,3,1)' to look from the 'top' of True X, (Map Z) with True Z being up/down, (Map Y) and True Y being left/right. (Map X) Colours are used to indicate where an object is on Map Z. See CONFIGURATION for information on changing these.
&HELP`CONFIGURATION [v(SVC`Td28d66ba70ead917f0aa)]=CFG` is the configuration tree. Branches are all used for various configuration, described below.%r%rCFG`ZANSI: Space-separated list of colours used for Map Z. They range from -12 to 12, 25 values in all. If you come up with a really nice color scheme, feel free to send it to Trelane@M*U*S*H...%rCFG`KEY: Space-separated list of characters used by objects. TYPE is used to determine which character to use. (Using elements(CFG`KEY,TYPE) )%rCFG`HELP.SKIN: just the skin for the spacemap's help. You're looking at it right now. %0 is the attribute containing the help file.
&HELP [v(SVC`Td28d66ba70ead917f0aa)]=Help Tree
&FUN`TRANSPOSE [v(SVC`Td28d66ba70ead917f0aa)]=iter(%0,sub(elements(##,1),elements(%1,1)) [sub(elements(##,2),elements(%1,2))] [sub(elements(##,3),elements(%1,3))] [elements(##,4)],|,|)
&FUN`SCALE [v(SVC`Td28d66ba70ead917f0aa)]=iter(%0,round(fdiv(elements(##,1),%1),0) [round(fdiv(elements(##,2),%1),0)] [round(fdiv(elements(##,3),%1),0)] [elements(##,4)],|,|)
&FUN`DRAW.ROW [v(SVC`Td28d66ba70ead917f0aa)]=if(not(setr(0,graball(%0,replace(* * * *,%2,%4),|))),squish(repeat(.%b,25)),iter(lnum(-12,12),letq(0,graball(%q0,replace(* * * *,%1,##),|),if(%q0,u(FUN`DRAW.POINT,%q0,%3),.))))
&FUN`DRAW.POINT [v(SVC`Td28d66ba70ead917f0aa)]=ansi(elements(v(CFG`ZANSI),add(elements(%0,%1),13))[if(gt(words(%0,|),1),u)],letq(0,elements(v(CFG`KEY),elements(first(%0,|),4)),if(%q0,%q0,?)))
&FUN`DRAW.MAP [v(SVC`Td28d66ba70ead917f0aa)]=setq(0,edit(u(FUN`SCALE,u(FUN`TRANSPOSE,%0,%1),%2),-0,0))[iter(lnum(12,-12),ulocal(FUN`DRAW.ROW,%q0,%3,%4,%5,##),,%r)]
&FUN [v(SVC`Td28d66ba70ead917f0aa)]=Function Tree
&CMD`HELP [v(SVC`Td28d66ba70ead917f0aa)]=$+spacemap help*:@pemit %#=if(cand(%0,setr(0,grab(lattr(%!/HELP`*),HELP`[edit(squish(%0),%b,_)]*))),u(CFG`HELP.SKIN,%q0),u(CFG`HELP.SKIN,HELP`HELP))
&CMD [v(SVC`Td28d66ba70ead917f0aa)]=Command Tree
&CFG`ZANSI [v(SVC`Td28d66ba70ead917f0aa)]=c g gh y yh r rh m mh b bh xh w wh ch Bh Mh Rh Yh Gh Ch Bch Mch Rch Ych
&CFG`KEY [v(SVC`Td28d66ba70ead917f0aa)]=^ ! o @ x # & X %b
&CFG`HELP.SKIN [v(SVC`Td28d66ba70ead917f0aa)]=center(%b[map(#lambda/capstr(lcstr(\%0)),after(%0,HELP`),_,%b)]%b,78,=)%r[u(%0)]%r[repeat(=,78)]
&CFG [v(SVC`Td28d66ba70ead917f0aa)]=Configuration Tree
@set [v(SVC`Td28d66ba70ead917f0aa)]/HSPACE=no_command
@set [v(SVC`Td28d66ba70ead917f0aa)]/HELP=no_command
@set [v(SVC`Td28d66ba70ead917f0aa)]/FUN=no_command
@set [v(SVC`Td28d66ba70ead917f0aa)]/CFG=no_command
@@
@@ Triggering all startups, oncreates, onupdates.
@@