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>