The Following code will display an ascii style map in a console window at the upper right corner of the main window. (Thought was it would be nice to be able to display it without setting the mapper into grid mode... so you can still edit the map in the mapper window)
createMiniConsole( "ASCIIMAP", 0, 0, 600, 600 )
setMiniConsoleFontSize("ASCIIMAP", 16)
Fx,Fy = calcFontSize(16)
resizeWindow("ASCIIMAP",15*Fx,11*Fy)
function Amap(roomid)
local ColorKey = getCustomEnvColorTable()
local Caa= getRoomArea(roomid)
local Cxx,Cyy,Czz = getRoomCoordinates( roomid )
local CurLo
local WindowWidth, WindowHeight = getMainWindowSize();
moveWindow("ASCIIMAP",WindowWidth-(15*Fx)-15,2)--WindowWidth-40*Fx-18,0)
hideWindow("ASCIIMAP")
clearUserWindow("ASCIIMAP")
local xx,yy,tt,r,g,b
yy=Cyy+5
while yy >= Cyy-5 do
xx=Cxx-7
while xx <= Cxx+7 do
-- resetFormat()
CurLo = getRoomsByPosition(Caa, xx,yy,Czz)
if CurLo[0] then
local cc = getRoomEnv(CurLo[0])
r,g,b = ColorKey[cc][1],ColorKey[cc][2],ColorKey[cc][3]
tt = getRoomChar(CurLo[0])
-- echo(tt)
if tt=="" then
tt = "O"
end
if xx == Cxx and yy == Cyy then
setBgColor("ASCIIMAP",178,34,34 )
else
setBgColor("ASCIIMAP", 0, 0,0 )
end
setFgColor("ASCIIMAP",r,g,b)
echo("ASCIIMAP",tt)
else
setBgColor("ASCIIMAP", 0, 0,0 )
echo("ASCIIMAP"," ")
end
xx=xx+1
end--while
echo("ASCIIMAP","\n")
xx=1
yy=yy-1
end--while
showWindow("ASCIIMAP")
end--func
I am not completly happy with this. It renders pretty slowly. (that is why it only displays a grid 15x11)
The slowest part of the code is getRoomsByPosition. If anyone has any thoughts of how to improve the preformance of this, I would be greatfull. (is there a way to localize the getRoomsByPosition function? grasping at straws.... swear I have had similar maps running much better than this does.)