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 viewtopic.php?p=256785#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).
To start the webserver use the /experiments macro
Code: Select all
/experiments webapp [port]
e.g.
Code: Select all
/experiments webapp 8000
You will then get a message in the chat box about where you can point your browser at to continue, before you continue though I must warn you that the HTML is butt ugly as I only threw it together to test as I was developing, and what can I say I haven't had the need to do much html5/css/javascript before, nor have I ever used jquery before, (but you can try your own and make it prettier, more on that later in post). I also expect this functionality might be a little flakey still so don't get frustrated if things dont work the way you expect, also if you run MapTool from the command line you will see copious amounts of debug info printed out (sorry about that). None of the messages are localized yet but they are just place holder messages (and sadly most of my knowledge of other languages is restricted to profanities learnt in the school yard during early high school which I didn't think would convey the message adequately)
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

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
Will serve up files in the /tmp/my-new-mt-website, in the URL in your browser you will replace the /webapi with /test
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.
Then unzip the web-stuff.zip (from the above link) into this directory
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>
Once you do this you will have access to JQuery, handlebars (templating), and the MapTool api object.
API Functions available
- registerInitiativeListener(listener) - Registers a function to be called when ever the initiative is updated.
ExampleCode: Select all
handle = MapTool.initiative.registerInitiativeListener(function(data) {
console.log('Received: ' + JSON.stringify(data));
});
The argument passed to the listener looks likeCode: 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
}}
Where- 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
- id - The id of the 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.
ExampleCode: 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 changes.Code: Select all
{
"tokensChanged":["000000003220F4F64500000000000000"]
}
The function receives a value like the following when a token is added.Code: Select all
{
"tokensAdded":["000000003220F4F64500000000000000"]
}
The function receives a value like the following when a token is reoved.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).
ExampleCode: Select all
MapTool.token.getTokenProperties('000000003320F4F64700000000000000', function(data) {
console.log('Received: ' + JSON.stringify(data));
});
The value received by the function looks likeCode: 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
}
]
}
Where- 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
- name - The name of the property
- 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
- label - The macro button label
- 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.
ExamplesCode: 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 propertyNames argument can be either a single property name or an array of property names.
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});
}
As well as the API functions above you can use the following URLS to fetch images.
- .../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.
I realise that using this API character sheets are going to be a little fidely to write, what I intend to do is add the ability to serve a standard(ish) web page that follows a few conventions and the API be able to connect up the properties to fields in the form etc without the person creating the character sheet needing to do much (if any) javascript coding, but that all depends on the API above, and the API above will still exist for the ore complicated stuff people may want to do. So hopefully people get a chance to play around with this and I get some feedback. Also if anyone wants to try their hand at prettying up the HTML before I get around to it (I have quite a bit more to do before I do that) you won't hear me complaining
