Centering the Map [SOLVED]

I've only just discovered the facility to turn the map off and on dynamically using JS.ShowGrid (0) and JS.ShowGrid (300). This works very well at the beginning of a game, as a play option, but if the map is switched on after the player has moved, the map is no longer centred on the player. This is fixed automatically when the player makes the next move but I can't see how to do it when the map is opened. Help!


Take a look at some of the "Grid_" functions here (under Internal Core.aslx Functions): http://docs.textadventures.co.uk/quest/functions/

There is a Grid_SetCentre function, but you have to input the player's x/y coordinates to work it. Yes, there needs to be more documentation on explaining and using the various map functions.


Sorry Dcoder, I've already been down that route and couldn't find the co-ordinates for the player. There seem to be attributes grid_parent_offset_x and grid_parent_offset_y for the player but these had no effect when I used them as parameters to Grid_SetCentre


The best way to (sort of) understand how those map functions work is to check Filter --> Show Library Elements at the bottom left of the editor and then search for the function in question. You can copy the function (top right corner) to allow overwriting of its default scripting. Make sure to do this in a copy of your game first.


I think the grid_parent_offset stuff just draws the player not in the center of the room. Not much help, I know.

Does Grid_DrawPlayerInRoom (game.pov.parent) center the player?


Does Grid_DrawPlayerInRoom (game.pov) center the player?

Indeed it does! Thanks Dcoder.


Sorry, that should have been (game.pov.parent), not (game.pov). Glad it worked : )


Sorry, I corrected it without thinking! Just in case anyone else is planning to use this facility, my approach was to introduce a new Boolean attribute to game: 'map_on' (initially false), and a MAP command which simply switches between the map being visible and invisible (initially invisible):

if (game.map_on) {
  JS.ShowGrid (0)
  game.map_on = false
  msg ("The map has been hidden. Type MAP again to restore it.")
}
else {
  JS.ShowGrid (300)
  Grid_DrawPlayerInRoom (game.pov.parent)
  game.map_on = true
  msg ("The map has been restored. Type MAP again to hide it.")
}

Log in to post a reply.

Support

Forums