Monday, June 28, 2021

CMUD: Experiment in creating a visible color map

The createColorMap alias in CMUD will generate a pattern of rooms showing you each room color used in mapping.

 

<alias name="createColorMap" language="Lua" id="179">
  <value>local mapcolors ={"aliceblue",  "antiquewhite", "aqua", "aquamarine", "azure", "beige", "bisque", "black", 
 "blanchedalmond", "blue", "blueviolet", "brown", "burlywood", "cadetblue", "chartreuse", 
 "chocolate", "coral", "cornflowerblue", "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", 
 "darkgoldenrod", "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen", "darkorange", 
 "darkorchid", "darkred", "darksalmon", "darkseagreen", "darkslateblue", "darkslategray", 
 "darkturquoise", "darkviolet", "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick", 
 "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", "gold", "goldenrod", "gray",
 "green", "greenyellow", "honeydew", "hotpink", "indianred", "indigo", "ivory", "khaki", 
 "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", 
 "lightcyan", "lightgoldenrodyellow", "lightgreen", "lightgrey", "lightpink", "lightsalmon", 
 "lightseagreen", "lightskyblue", "lightslategray", "lightsteelblue", "lightyellow", "lime", 
 "limegreen", "linen", "magenta", "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", 
 "mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise", 
 "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", "navajowhite", "navy", 
 "oldlace", "olive", "olivedrab", "orange", "orangered", "orchid", "palegoldenrod", "palegreen", 
 "paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", 
 "purple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen", 
 "seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", "snow", "springgreen", 
 "steelblue", "tan", "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white"
 , "whitesmoke", "yellow", "yellowgreen"}
 
 function tablelength(T)
  local count = 0
  for _ in pairs(T) do count = count + 1 end
  return count
end

local maxcolumns = 10
local colorcount = tablelength(mapcolors)
local mapdir
local c
local targetcolor = 0
local r = 0
local numrows =  colorcount/maxcolumns + 1

for r = 1, numrows do
  if r % 2 == 0 then 
    mapdir = "e"
  else
    mapdir = "w"
  end
  -- always drop down for each row
   targetcolor = targetcolor + 1
   if targetcolor &gt; colorcount then
      break;
    end
    zs.make("s",mapcolors[targetcolor])
    zs.func.roomcol(null,mapcolors[targetcolor])

  for c = 1,maxcolumns - 1 do 
    targetcolor = targetcolor + 1
    if targetcolor &gt; colorcount then
      break;
    end
    zs.make(mapdir,mapcolors[targetcolor])
    zs.func.roomcol(null,mapcolors[targetcolor])
  end
end
</value>
</alias>

Saturday, January 9, 2021

Mud and cmud mapping

 

If you use cmud client, the following will capture room descriptions to the map.  It's not elegant code wise in that it requires a special color combination for room descriptions to enable the scripts to only see the room lines, build up the description and then update on the description termination Terrain.

Variables

flag to turn description capture on/off
#var roomdesc 1

holds the captured text of a description
#var description_store ""

a placeholder to capture result of function so as not to display on mud
#var result

Aliases

<alias name="roomson" id="136">
 <value>#var roomdesc 1;#show you have turned on update room desc.</value>
</alias>

<alias name="roomsoff" id="137">
  <value>#var roomdesc 0;#show you have turned off update room desc.</value>
</alias>

Triggers

Creates a trigger that matches any text that matches a foreground/background color.  The description color has to be a unique combo. each line is captured and adds it to the description_store variable and then when the 2nd trigger "Terrain:" hits, it updates the map room description

<trigger priority="1310" regex="true" linecolor="112" id="131">
 <pattern>(.*)</pattern>
<value>#var description_store %concat(@description_store,%1)</value>
</trigger>

<trigger priority="1330" id="133">
<pattern>Terrain:</pattern>
 <value>
#if (@roomdesc == 1) {
#var foo %roomdesc(%roomvnum,@description_store);
}
#var description_store "";
</value>
</trigger>