toggle map on/off in-game

psymann
04 May 2013, 23:46Hello all,
Is there a function I can call that will turn the in-game map on and off?
I figure some people would like the map and want to leave it on; others might dislike it and prefer to have more space on the page for text.
So I want "MAP ON" and "MAP OFF" functions which turn the map on and off. Presumably this is possible since I can choose the on or off setting in the GUI when I'm making the game in the first place? If so, does anyone know the syntax? I tried but failed to find it when trawling the list of built-in functions.
Thanks,
psy
Is there a function I can call that will turn the in-game map on and off?
I figure some people would like the map and want to leave it on; others might dislike it and prefer to have more space on the page for text.
So I want "MAP ON" and "MAP OFF" functions which turn the map on and off. Presumably this is possible since I can choose the on or off setting in the GUI when I'm making the game in the first place? If so, does anyone know the syntax? I tried but failed to find it when trawling the list of built-in functions.

Thanks,
psy

jaynabonne
05 May 2013, 00:41This is something I'd like to do as well. I've even looked at the code, but I don't have a concise answer for you. The main problem is that the current code Quest code is written with the assumption that if you want the grid map, you have it on from the beginning. So, for example, there is some code that only exists in StartGame, which would have to be done at the right time, when the map is shown. There is also the problem of what exactly should happen when the grid is turned on and off, especially if you have moved in the meantime while it's off. The gridmap code (again) assumes that you are using the gridmap right from the beginning, and it grows the map step by step as you move. It does *not* do well with anything that deviates from that.
I have code that will traverse, layout and draw the entire map up front. If that's sufficient, then that code can be worked in perhaps. If you still want it to be an incremental discovery, then the above mentioned problem will need to be addressed somehow.
I'll take a look at it when I'm less sleepy...
I have code that will traverse, layout and draw the entire map up front. If that's sufficient, then that code can be worked in perhaps. If you still want it to be an incremental discovery, then the above mentioned problem will need to be addressed somehow.
I'll take a look at it when I'm less sleepy...


psymann
05 May 2013, 01:18Thanks, jay... though it's not a vitally important thing, so if you're happy to investigate for the enjoyment of it, then go for it, but don't create work for yourself on my behalf!
For me, there are two ways the map on/off could work logically, depending on the way it's being done:
1) USER toggles it off:
- map should be drawn all the time, whether or not it's showing
- if map is turned on, map shows everything that has been discovered, regardless of whether it was found when map was on or off
- so it's just a .visible = true/false toggle as part of the game interface
2) GAME toggles it off:
- as if the hero of the story is drawing the map as he's going along, and when map is on, it's because he's drawing it himself with some paper, but when it's off, it's because he's running desperately through the forest, too quickly to keep track of where he's gone, and can't draw it, or even look at it.
- so it's actually more part of the game itself
I think (2) could also be achieved with non-directional exits? Or "move player" rather than using exits? Not sure.
What I was actually wanting though was (1), with the same incremental discovery as usual.
If it's not possible, then never mind, I'll leave the map on and people will have to live with it if they don't like it
psy

For me, there are two ways the map on/off could work logically, depending on the way it's being done:
1) USER toggles it off:
- map should be drawn all the time, whether or not it's showing
- if map is turned on, map shows everything that has been discovered, regardless of whether it was found when map was on or off
- so it's just a .visible = true/false toggle as part of the game interface
2) GAME toggles it off:
- as if the hero of the story is drawing the map as he's going along, and when map is on, it's because he's drawing it himself with some paper, but when it's off, it's because he's running desperately through the forest, too quickly to keep track of where he's gone, and can't draw it, or even look at it.
- so it's actually more part of the game itself
I think (2) could also be achieved with non-directional exits? Or "move player" rather than using exits? Not sure.
What I was actually wanting though was (1), with the same incremental discovery as usual.
If it's not possible, then never mind, I'll leave the map on and people will have to live with it if they don't like it

psy

jaynabonne
05 May 2013, 09:09Actually, what you said just made things easier. If you assume that "gridmap" is on from the beginning, then controlling the display and non-display of the map is straightforward. Try these commands:
This worked ok for me (not fully tested). It will continue to track and update the player's position on the grid map, even when not shown. The "Grid_DrawPlayerInRoom" in "map on" is necessary to force the grid map to center on the player's current position, in case it has changed.
<command name="MapOn">
<pattern>map on</pattern>
<script>
JS.ShowGrid(game.mapsize)
Grid_DrawPlayerInRoom (game.pov.parent)
</script>
</command>
<command name="MapOff">
<pattern>map off</pattern>
<script>
JS.ShowGrid(0)
</script>
</command>
This worked ok for me (not fully tested). It will continue to track and update the player's position on the grid map, even when not shown. The "Grid_DrawPlayerInRoom" in "map on" is necessary to force the grid map to center on the player's current position, in case it has changed.

psymann
05 May 2013, 20:42That appears to work perfectly 
I'll let you know if I find any problem in the future with it, but it looks as if it's spot on.
Once again I owe you many thanks!
psy

I'll let you know if I find any problem in the future with it, but it looks as if it's spot on.
Once again I owe you many thanks!
psy