Skip to content

Commit

Permalink
Swade System + SWRPG fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kekilla0 committed Sep 15, 2020
1 parent 4993ac0 commit 6961f1d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 12 deletions.
4 changes: 2 additions & 2 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title" : "Item Macro",
"description" : "A module that allows macros to be stored in items and executed in various places.",
"author" : "Kekilla#7036",
"version" : "v1.2.0",
"version" : "v1.3.0",
"minimumCoreVersion" : "0.6.0",
"compatibleCoreVersion": "0.6.6",
"esmodules" : ["scripts/main.js"],
Expand All @@ -18,5 +18,5 @@
],
"url" : "https://github.com/Kekilla0/Item-Macro",
"manifest" : "https://github.com/Kekilla0/Item-Macro/raw/master/module.json",
"download" : "https://github.com/Kekilla0/Item-Macro/archive/v1.2.0.zip"
"download" : "https://github.com/Kekilla0/Item-Macro/archive/v1.3.0.zip"
}
49 changes: 39 additions & 10 deletions scripts/itemMacro.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,25 +275,34 @@ export function changeButtons(app,html,data)
if(debug) log("Change Buttons | ", html, data, itemImage);
if(itemImage.length > 0)
{
itemImage.off();
itemImage.click(async (event) => {
let li = $(event.currentTarget).parents(".item");
console.log(itemImage);

if(debug) log("LI | ", event.currentTarget);
if(!game.modules.get("betterrolls-swade")?.active || game.system.id !== "swade")
{
itemImage.off();
}

itemImage.click(async (event) => {
if(game.system.id==="swade") return;

let li = $(event.currentTarget).parents(".item");
if(String(li.attr("data-item-id")) === "undefined") return;
let item = app.actor.getOwnedItem(String(li.attr("data-item-id")));

let flags = item.data.flags.itemacro?.macro;

if(flags === undefined || flags?.data.command === "")
{
//case statement for different systems
if(item.data.type===`spell`)
switch(game.system.id)
{
item.actor.useSpell(item);
}else {
item.roll(event);
case "sfrpg" :
case "dnd5e" :
if(item.data.type===`spell`)
{
item.actor.useSpell(item);
}else {
item.roll(event);
}
break;
}
}else{
if(app.actor.isToken)
Expand All @@ -304,5 +313,25 @@ export function changeButtons(app,html,data)
}
}
});

itemImage.contextmenu(async (event)=> {
if(game.system.id !== "swade") return;

let li = $(event.currentTarget).parents(".item");
if(String(li.attr("data-item-id")) === "undefined") return;
let item = app.actor.getOwnedItem(String(li.attr("data-item-id")));
let flags = item.data.flags.itemacro?.macro;

if(flags !== undefined || flags?.data.command !== "")
{
if(app.actor.isToken)
{
runMacro(app.actor.token.id, item.id);
}else{
runMacro(app.actor.id,item.id);
}
}
});

}
}
5 changes: 5 additions & 0 deletions scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ let knownSheets = {
Tidy5eNPC: ".item .item-image",
MonsterBlock5e: ".item .item-name",
ActorSheetSFRPGCharacter : ".item .item-image",
ActorSheetSFRPGNPC : ".item .item-image",
ActorSheetSFRPGStarship : ".item .item-image",
ActorSheetSFRPGVehicle : ".item .item-image",
ActorSheetSFRPGDrone : ".item .item-image",
SwadeCharacterSheet : ".item .item-image",
SwadeNPCSheet : ".gear .item-image",

// Sky5eSheet: ".item .item-image",
};
Expand Down

0 comments on commit 6961f1d

Please sign in to comment.