ID:927282
 
Code:
mob/proc/ShowMap()
var
buf = ""
top = min(y+client.view+6.5, world.maxy)
bottom = max(y-client.view-6.5, 1)
left = max(x-client.view-13, 1)
right = min(x+client.view+13, world.maxx)

for(var/yy = top, yy >= bottom, yy--)
for(var/xx = left, xx <= right, xx++)
var/turf/T = locate(xx,yy,z)
var/mob/M = locate() in T
if(M)
buf += M.text
else
buf += T.text
buf += "\n"
mb_msgout("")

mb_msgout(buf)

mb_msgout("Location: [x],[y]")
mb_msgout("Nearby: ")
mb_msgout("Facing: [Direction]")


Problem description:
I am making a MUD... I have outputting the map to text like above! I am trying to figure out how to keep the players * character centered on the screen... Also, currently I spawn at 1,1,1 and the map is small and when moving it just keeps getting bigger... i wanna maintain 13x13 regardless of position if on edge or anything.
I'm not sure what you mean. Can you post some screenshots of what you are trying to do? Are you trying to use the output to show the map like a roguelike?
This is it for instance...
....................
....................
....................
....................
....................
....................
....................
....................
........*...........
....................
....................
....................
....................
....................




Location: 9,9
Nearby:
Facing: South
You move southwest.

...................
...................
...................
...................
...................
...................
...................
...................
.......*...........
...................
...................
...................
...................




Location: 8,8
Nearby:
Facing: South
You move east.

....................
....................
....................
....................
....................
....................
....................
....................
........*...........
....................
....................
....................
....................




Location: 9,8
Nearby:
Facing: South
You move east.

.....................
.....................
.....................
.....................
.....................
.....................
.....................
.....................
.........*...........
.....................
.....................
.....................
.....................




Location: 10,8
Nearby:
Facing: South
You move east.

......................
......................
......................
......................
......................
......................
......................
......................
..........*...........
......................
......................
......................
......................




Location: 11,8
Nearby:
Facing: South
You move east.

.......................
.......................
.......................
.......................
.......................
.......................
.......................
.......................
...........*...........
.......................
.......................
.......................
.......................




Location: 12,8
Nearby:
Facing: South
You move east.

.......................
.......................
.......................
.......................
.......................
.......................
.......................
.......................
...........*...........
.......................
.......................
.......................
.......................




Location: 13,8
Nearby:
Facing: South
You move east.

.......................
.......................
.......................
.......................
.......................
.......................
.......................
.......................
...........*...........
.......................
.......................
.......................
.......................




Location: 14,8
Nearby:
Facing: South
You move west.

.......................
.......................
.......................
.......................
.......................
.......................
.......................
.......................
...........*...........
.......................
.......................
.......................
.......................




Location: 13,8
Nearby:
Facing: South
You move west.

.......................
.......................
.......................
.......................
.......................
.......................
.......................
.......................
...........*...........
.......................
.......................
.......................
.......................




Location: 12,8
Nearby:
Facing: South
You move west.

......................
......................
......................
......................
......................
......................
......................
......................
..........*...........
......................
......................
......................
......................




Location: 11,8
Nearby:
Facing: South
You move west.

.....................
.....................
.....................
.....................
.....................
.....................
.....................
.....................
.........*...........
.....................
.....................
.....................
.....................




Location: 10,8
Nearby:
Facing: South
You move west.

....................
....................
....................
....................
....................
....................
....................
....................
........*...........
....................
....................
....................
....................




Location: 9,8
Nearby:
Facing: South
You move west.

...................
...................
...................
...................
...................
...................
...................
...................
.......*...........
...................
...................
...................
...................




Location: 8,8
Nearby:
Facing: South
You move west.

..................
..................
..................
..................
..................
..................
..................
..................
......*...........
..................
..................
..................
..................




Location: 7,8
Nearby:
Facing: South
You move west.

.................
.................
.................
.................
.................
.................
.................
.................
.....*...........
.................
.................
.................
.................




Location: 6,8
Nearby:
Facing: South
You move west.

................
................
................
................
................
................
................
................
....*...........
................
................
................
................




Location: 5,8
Nearby:
Facing: South
You move west.

...............
...............
...............
...............
...............
...............
...............
...............
...*...........
...............
...............
...............
...............




Location: 4,8
Nearby:
Facing: South
You move west.

..............
..............
..............
..............
..............
..............
..............
..............
..*...........
..............
..............
..............
..............




Location: 3,8
Nearby:
Facing: South
You move west.

.............
.............
.............
.............
.............
.............
.............
.............
.*...........
.............
.............
.............
.............




Location: 2,8
Nearby:
Facing: South
You move west.

............
............
............
............
............
............
............
............
*...........
............
............
............
............




Location: 1,8
Nearby:
Facing: South
You move south.

............
............
............
............
............
............
............
............
*...........
............
............
............




Location: 1,7
Nearby:
Facing: South
You move south.

............
............
............
............
............
............
............
............
*...........
............
............




Location: 1,6
Nearby:
Facing: South
You move south.

............
............
............
............
............
............
............
............
*...........
............




Location: 1,5
Nearby:
Facing: South
You move south.

............
............
............
............
............
............
............
............
*...........




Location: 1,4
Nearby:
Facing: South
You move south.

............
............
............
............
............
............
............
............
*...........




Location: 1,4
Nearby:
Facing: South

Even if on the edge i would like the map to still not get that small. i want it to stay at the size i wanna set... and i always want the *, the player, to stay in the middle

~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~,,,,,,,,~~~~~~~
~~~~~~~~,,,,,*,,,,,,,,,,,,,
~~~~~~~~,,,,,,,,,,,,,,,,,,,
~~~~~~~~,,,,,,,,,,,,,,,,,,,
~~~~~,,,,,,,,,,,,,,,,,,,,,,
~~~~~,,,,,,,,,,,,,,,,,,,,,,
~~~~~,,,,,,,,,,,,,,,,,,,,,,
~~~~~,,,,,,,,,,,,,,,,,,,,,,
~~~~~,,,,,,,,,,,,,,,,,,,,,,

Location: 398,442


this is the desired size and effect i want regardless on the edge or in the middle of the map
The map isn't getting any smaller. Your mob is always in the center of your screen by default. Outside the map it's black. The map isn't getting smaller, you are just filling your screen with more and more of non-existent space. Just keep your mob from getting that close to the edge and your problem is solved.
Actually, in his case, he's printing the map to the output element. He has to compensate for whitespace manually if the player is too close to the edges of the map, or has to clamp the map using client.lazy_eye.

@IScet, try looking up the client variables, lazy_eye, and centering your map on the mob's client eye instead of on the mob.
hmm cant work out an exact solution but from what im reading.. this is exactly what im talking about! :) any suggestions on how to tackle or go ter13?
mob/proc/ShowMap()
var
buf = ""
top = min(y+client.view+6.5, world.maxy)
bottom = max(y-client.view-6.5, 1)
left = max(x-client.view-13, 1)
right = min(x+client.view+13, world.maxx)


This is where your mistake lies. You aren't actually relocating your viewport. Your math is all wrong here.

client
perspective = EDGE_PERSPECTIVE //make it so that the client's view never goes past the map edge.


Use this, first of all, somewhere in your code. And calculate the edges from this:

left = client.virtual_eye.x - round(client.view/2)
bottom = client.virtual_eye.y - round(client.view/2)
right = left + client.view
top = bottom + client.view


That should do the trick. Check out the virtual_eye var of the client. When using edge perspective, it won't always be equal to the player's mob, and will avoid moving after the edge of the view reaches the edges of the map. This means you don't have to do any work yourself. BYOND does it all for you.
It's client/perspective, not edge_limit.
In response to Albro1 (#7)
Albro1 wrote:
It's client/perspective, not edge_limit.

Good catch.