The campaign format should be completely compatible with the latest 1.3 builds but as always backup before trying it
Edit: Update and a new build http://forums.rptools.net/viewtopic.php ... 85#p256785
You can download what you need from http://maptool.craigs-stuff.net/test-builds/
This build adds either one or two new features (depending on how you want to look at it) that are not yet ready to be used in anger.
- Added a new macro command /experiments. This command allows you to start experimental features that may be in a build.
- The MapTool client now contains a webserver that allows you interact with the local client via web browser (well just about anything but we will say browser for now).
Code: Select all
/experiments webapp [port]
Code: Select all
/experiments webapp 8000
I have tried Chrome, Safari, and Chrome on Android. It should also work on Firefox, Firefox Mobile, Safari Mobile, IE 10, IE 11, and Opera (but not Opera Mini).
If you have an error on one of these (ignoring the HTML formatting for now) can you please let me know.
What you will see when you first load the link is the initiative, so if MapTool looks like this Then the browser window will look something like this Any advancing of initiative in MapTool will be reflected in the browser (or browsers) and any in the browser will be reflected in MapTool and other browsers connected.
If you click on the "Sheet" button you will get a really rudimentary (and did I mention quite ugly) stat sheet (based on the properties defined as visible) and a list of the
macros. If a token changes this will be updated (no need to refresh). You can also run the macros by clicking on the macro buttons, the results will appear in MapTool chat.
At the moment everything is run as the logged in user in the client you attach to. What I want to do is add the ability for GMs to allow users to connect as specific players to a GM client, this will be handy for around the table/projector type games where the GM can allow players to view character sheets/run macros etc from tablets or what have you. This of course means I intend for a way for GMs to add their own HTML/Javascript/CSS to be served. Also once HTML5 is available in MapTool (shortly after we get everything working well on Java these would be viewable within MapTool so you can have HTML5 character sheets that should be viewable from within MapTool or on a table without any changes being made (possibly phone too but thats a screen based thing).
But this is so ugly and doesn't show me really what can be done... You are right, its very basic and ugly (but functional) luckily for those that want to (and I am really hoping that some people will want to so I can get some feedback) I have added a way to serve up HTML files from a directory on your machine (there will eventually be a way of getting these into the campaign file).
I have only tested this on Unix based systems at the moment but there is no reason it shouldn't work under windows, please let me know if you have problems.
To do this you need to start the webapp with a URI path and directory on your local file system for example
Code: Select all
/experiments webapp 8000 /test=/tmp/my-new-mt-website
So if the message you got was
Code: Select all
Webapp server has been started Connect to
http://172.0.01:8000/webapi on your browser/phone/tablet.
You would point your browser to http://172.0.01:8000/test (http://172.0.01:8000/webapi will still work but will show you the original that comes with MapTool not your changes).
You can the create your own web pages to be served up, you should not change the mtwebapp.js file or add/change anything in the bower_components directory.
But what can you do? Well I am glad you asked (ok not really since that means more typing for me).
The mtwebapp.js contains the MapTool javascript object that is used to get/send information from/to MapTool.
You can look at the index.html, initiative.js, tokensheet.js files to see how things are
To start with you will need to include
Code: Select all
<script type='text/javascript' src='bower_components/jquery/dist/jquery.js'></script>
<script type='text/javascript' src='bower_components/handlebars/handlebars.js'></script>
<script type='text/javascript' src='mtwebapp.js'></script>
API Functions available
- registerInitiativeListener(listener) - Registers a function to be called when ever the initiative is updated.
ExampleThe argument passed to the listener looks likeCode: Select all
handle = MapTool.initiative.registerInitiativeListener(function(data) { console.log('Received: ' + JSON.stringify(data)); });
WhereCode: Select all
{"initiative":[ { "id":"000000003320F4F64700000000000000", "name":"Elf", "holding":false, "initiative":"14", "tokenIndex":0, "playerOwns":true }, { "id":"000000003320F4F64700000000000000", "name":"Elf", "holding":false, "initiative":"11", "tokenIndex":1, "playerOwns":true }, { "id":"000000003220F4F64500000000000000", "name":"Eagle", "holding":false, "initiative":"10", "tokenIndex":2, "playerOwns":true }, { "id":"000000003320F4F64900000000000000", "name":"Elf 1", "holding":false, "initiative":"8", "tokenIndex":3, "playerOwns":true }], "current":1, "round":30, "canAdvance":true }}
- Initiative - A list of tokens in the initiative list
- id - The id of the token.
- name - The name of the token.
- holding - Is the token holding in the initative window
- initiative - The initiative value
- tokenIndex - The index within the initiative window.
- playerOwns - Is the player (MT client connected to) owner of token
- current - The index in the array of the token with the initiative
- round - The iniative round
- canAdvance - can the logged in player advance the initiative
- Initiative - A list of tokens in the initiative list
- removeInitiativeListener(handle) - Removes an initiative listener
ExampleCode: Select all
MapTool.initiative.removeInitiativeListener(handle);
- getCurrentRound() - Returns the current initiative round.
ExampleCode: Select all
round = MapTool.initiative.getCurrentRound();
- nextInitiative() - Advances the initiative.
ExampleCode: Select all
MapTool.initiative.nextInitiative();
- previousInitiative() - Sets the initiative to the previous token
ExampleCode: Select all
MapTool.initiative.previousInitiative();
- sortInitiative() - Sorts the initiative list.
ExampleCode: Select all
MapTool.initiative.sortInitiative();
- tokenHold(tokenId, tokenIndex) - Toggles on hold for a token in the initative
ExampleCode: Select all
MapTool.initative.toggleHold('000000003320F4F64700000000000000', 0);
- registerTokenChangeListener(listener) - Registers a function to be called when ever a token changes/is added/is removed.
ExampleThe function receives a value like the following when a token changes.Code: Select all
handle = MapTool.token.registerTokenChangeListener(function(data) { console.log("Tokens changed: " + JSON.stringify(data)); });
The function receives a value like the following when a token is added.Code: Select all
{ "tokensChanged":["000000003220F4F64500000000000000"] }
The function receives a value like the following when a token is reoved.Code: Select all
{ "tokensAdded":["000000003220F4F64500000000000000"] }
Code: Select all
{ "tokensRemoved":["000000003220F4F64500000000000000"] }
Due to the way changes happen you may get more than one change event for
a token change as well as a change event in addition to a add event when
a token is added. - removeInitativeListener(handle) - Remove a token change listener
ExampleCode: Select all
MapTool.token.removeInitiativeListener(handle);
- getTokenProperties(tokenId, callback) - Retrieves the tokens properties.
This function retreives the list of defied properties for a token (this registered in the campaign properties).
ExampleThe value received by the function looks likeCode: Select all
MapTool.token.getTokenProperties('000000003320F4F64700000000000000', function(data) { console.log('Received: ' + JSON.stringify(data)); });
WhereCode: Select all
{ "tokenId":"000000003220F4F64500000000000000", "name":"Eagle", "properties":{ "Strength":{ "name":"Strength", "shortName":"Str", "value":"10", "showOnStatSheet":false }, "HP":{ "name":"HP", "value":"27", "showOnStatSheet":true }, } "macros":[ { "label":"1d6", "tooltip":"Roll 1d6", "index":1, "fontColor":"black", "displayGroup":"Rolls", "group":"Rolls", "autoExecute":true, "maxWidth":"", "minWidth":"", "applyToTokens":false } ] }
- tokenId - Id of the token
- name - Name of the token
- properties - The defined token properties
- name - The name of the property
- shortName - The short name of the property
- value - The value of the property
- showOnStatSheet - Is the property displayed on the stat sheet when the mouse hovers over the token
- macros - The macros defined for the token
- label - The macro button label
- tooltip - The macro button tooltip
- index - The macro button index
- fontColour - The font colour of the macro button text
- displayGroup - The display group for the macro button
- group - The group for the macro button
- autoExecute - The auto execute flag for the macro button
- maxWidth - The maximum width for the macro button
- minWidth - The minimum width for the macro button
- applyToTokens - The applyToTokens flag for the macro button
- callMacro(tokenId, macroIndex) - Runs a macro on the MapTool client.
ExampleCode: Select all
MapTool.token.callMacro('000000003320F4F64700000000000000', 1);
- getProperties(tokenId, propertyNames, callback) - Retrieves the properties of a token
Unlike getTokenProperties() this function can be used to get the properties of a token not registred in the campaign properties.
ExamplesThe propertyNames argument can be either a single property name or an array of property names.Code: Select all
MapTool.token.getPropertiest('000000003320F4F64700000000000000', 'HP', function(data) { console.log('Received: ' + JSON.stringify(data)); }); MapTool.token.getPropertiest('000000003320F4F64700000000000000', ['HP', 'AC'], function(data) { console.log('Received: ' + JSON.stringify(data)); });
The value passed to the function looks something likeCode: Select all
{ "tokenId":"000000003220F4F64500000000000000", "properties": [ { "name": "HP", "value" 10 } ] }
- setProperties(tokenId, properties) - Sets the properties on a token
ExampleCode: Select all
{ MapTool.token.setProperties('000000003320F4F64700000000000000', {HP: 10, AC: 8}); }
- .../token/image/<tokenId> - Fetches Token Image.
- .../token/portrait/<tokenId> - Fetches Token Portrait.
- .../token/portraitOrImage/<tokenId> - Fetches Token Portrait if it has one otherwise its image.