added item types

This commit is contained in:
Lyle hayhurst
2021-06-04 08:14:28 -05:00
parent 2dcbfbe096
commit 9ffa796eeb
3 changed files with 26 additions and 8 deletions

View File

@@ -1,6 +1,7 @@
# Dev Guide
In addition to this repo, you will also need to check out the [MaterialDeck_SD github repo](https://github.com/CDeenen/MaterialDeck_SD).
## Module Development
@@ -18,7 +19,10 @@ In the same file, in the setSystem() function, you need to wire in your system t
It's possible to debug on the Stream Deck, so you can do `console.log`. Just follow the instructions [from elgato here](https://developer.elgato.com/documentation/stream-deck/sdk/create-your-own-plugin/). After editing the code for the plugin, you need to either refresh by refreshing the debug window, or by deselecting the current button, and selecting it again.
##
When you go to the debugging page, there should be multiple options. With the property inspector open, you should connect to the one with property inspector in its name. If you go to to propertyinspector/js/common.js, near the top there's the debugEn variable. Set it to true, and you should get tons of messages, especially if you change any settings.
In the module, in MaterialDeck.js, at line 60, there's //console.log("Received",data);. If you uncomment that, it'll log everything that's send from the SD to the module. Might be helpful for debugging.
## Verify the below
For getStats, getRolls you cannot change value
@@ -26,12 +30,15 @@ For the others, it depends on the system. For example:
in 5e, to get the appraise skill modifier, you do token.actor.data.data.skills?.[skill].total where 'skill' is 'apr'. So in the plugin, you have to set the value to 'apr'.
## Streamdeck
On the SD side: The plugin in windows is located at AppData/Roaming/Elgato/StreamDeck/Plugins/com.cdeenen.materialdeck.sdPlugin
In propertyinspector/js/common.js starting at line 1274 there's various functions that are used to get the relevant options to show up in the SD plugin. Each array element has a value and a name, you should keep the value the same, but the name can be whatever you like. I think you'll be able to figure out how to add stuff for wfrp by looking at the others.
To enable logging on the streamdeck, [follow these instructions](https://developer.elgato.com/documentation/stream-deck/sdk/create-your-own-plugin/) from Elgato.
## Property discovery
In a Foundry client browser instance, if you go to the dev console, you can browser your tokens via the `canvas.tokens` path, for exmaple `canvas.tokens.children[0].children[0].actor.items`.
## Module Deployment
Copy the new system.js and tokenHelper.js
If you make changes to files in this project, you'll need to copy the changed files to your Foundry install folder, probably found here: `C:\Users\$USER\AppData\Local\FoundryVTT\Data\modules\MaterialDeck`.
If you change the `MaterialDeck_SD` code (for example, `propertyinspector\js\common.js`), you will need to copy that file to the Elgato streamdeck plugins directory, probably found here: `C:\Users\$USER\AppData\Roaming\Elgato\StreamDeck\Plugins\com.cdeenen.materialdeck.sdPlugin`.

View File

@@ -57,7 +57,7 @@ let WSconnected = false;
async function analyzeWSmessage(msg){
if (enableModule == false) return;
const data = JSON.parse(msg);
//console.log("Received",data);
console.log("Received",data);
if (data.type == "connected" && data.data == "SD"){
const msg = {

View File

@@ -104,17 +104,28 @@ export class wfrp4e {
/**
* Items
*/
getItems(token,itemType) {
if (itemType == undefined) itemType = 'any';
const allItems = token.actor.items;
console.log("allitems: "+ allItems);
if (itemType == 'any') return allItems.filter(i => i.type == "weapon" ||
i.type == "armour" ||
i.type == "ammunition" ); // i.type == 'item');
if (itemType == 'any') return allItems.filter(i => i.type == itemType);
} */
getItems(token,itemType) {
if (itemType == undefined) itemType = 'any';
const allItems = token.actor.items;
if (itemType == 'any') return allItems.filter(i => i.type == 'weapon' ||
i.type == 'ammunition' ||
i.type == 'armour' ||
i.type == 'trapping');
else {
return allItems.filter(i => i.type == itemType);
}
}
getItemUses(item) {
return {available: item.data.data.quantity};
}