Game Map : allow visitors to choose one entry point ?

Hello everyone,

First I must really thank and congratulate all the people involved in the creation and maintenance of H5P which is an amazing tool ! I cannot imagine all the work hidden behind this !

Now to my question : I am wondering if there is a way to adapt the Game Map so that it would be possible to have all the stages locked except one at the beginning (so far so good...) but also to be able to let the website visitor manually choose the first stage from which he will start. I imagined for exemple a group of radio buttons trigerring the addition and removal of some css classes to and from the concerned stages but despite many trials I cannot manage to have additionnal javascript interact with the Game Map.

From reading the documentation here I know adding custom css or javascript is not straigthforward but eventhough I managed to customize the Game Map appearance to some extent, I couldn't manage my wish to be able to choose the first stage. Does that echo to someone ? Does anyone think this is feasible or not ? Is it worth trying a little more ? :-)

Many thanks for your advice !

Robin

Content types: 
otacke's picture

Hi Robin!

I won't pretend to fully understand your intention, but you can select multiple stages to be starting stages and one will then be chosen randonly. If you then set the map roaming option to something else but free roaming, then this might be close to what you have in mind - the starting stage cannot be chosen by the user though.

Best,

Oliver

Hi Olivier,

Many thanks for taking the time to answer me ! Yes Indeed I know I can do that, which is not that far from the use case I am looking for. Doing just that is easy, but still I am really interested if anyone knows if I could add some javascript to be able to manually interact with which stage is open or not through an external button. Or anything close to that ?

Thank you all for taking the time to read me :-)

Robin

otacke's picture

If you don't want to run your own fork, you can use the alter script hook (https://h5p.org/node/2692) to pass your own JavaScript that can then access `H5P.instances[0]` inside the iframe after the content type was instantiated. All functions and variables are exposed, so you are pretty free in what you can do. Stages have a `setState` function that can be used to, well, set their state.

The source code of GameMap is openly available at https://github.com/otacke/h5p-game-map ready to be explored.