You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While helping a user sort out roll formulas in the SWB discord server topic, I noticed that the buttons generated by items on an actor are unable to reference their parent actor's data for rolls. I'm not sure at what point in the process this is failing exactly, but the rough issue seems to be that their button formulas are written as @items.someItemAttrName and if someItemAttrName is a formula attribute referencing actor attributes, they're unable to drill deep enough in the roll data to work.
Steps to reproduce
Create a new actor
Create a Number attribute named foo with the value set to 1
Create a Formula attribute named bar with the value set to @foo + 1
Create an item on the actor
Create a Formula attribute on the item named fooRoll with the value set to d20 + @foo
Create a Formula attribute on the item named barRoll with the value set to d20 + @bar
Click the buttons for each roll on the actor's items tab.
Expected
fooRoll should generate a roll with the formula d20 + 1
barRoll should generate a roll with the formula d20 + 1 + 1
Actual
fooRoll works as expected
barRoll causes a fatal error due to no prop being found for @foo in the @foo + 1 formula.
If rolling directly from the attributes tab of the items sheet, both formulas work as expected.
Workarounds
This appears to be happening due to either how getRollData() is returning for the actor, or possibly due to differences in how rolls are evaluated now versus when this feature was originally written for SWB. I was able to work around it by modifying SimpleActorSheet#_onItemRoll() to use the following logic:
/** * Listen for roll buttons on items. * @param {MouseEvent} event The originating left click event */_onItemRoll(event){letbutton=$(event.currentTarget);constli=button.parents(".item");constitem=this.actor.items.get(li.data("itemId"));constactorRollData=this.actor.getRollData();constrollData=Object.assign(actorRollData,actorRollData.items[item.name.slugify({strict: true})],);constrollFormula=Roll.replaceFormulaData(button.data('roll'),rollData);letr=newRoll(rollFormula,rollData);returnr.toMessage({user: game.user.id,speaker: ChatMessage.getSpeaker({actor: this.actor}),flavor: `<h2>${item.name}</h2><h3>${button.text()}</h3>`});}
The text was updated successfully, but these errors were encountered:
While helping a user sort out roll formulas in the SWB discord server topic, I noticed that the buttons generated by items on an actor are unable to reference their parent actor's data for rolls. I'm not sure at what point in the process this is failing exactly, but the rough issue seems to be that their button formulas are written as
@items.someItemAttrName
and ifsomeItemAttrName
is a formula attribute referencing actor attributes, they're unable to drill deep enough in the roll data to work.Steps to reproduce
foo
with the value set to1
bar
with the value set to@foo + 1
fooRoll
with the value set tod20 + @foo
barRoll
with the value set tod20 + @bar
Expected
fooRoll
should generate a roll with the formulad20 + 1
barRoll
should generate a roll with the formulad20 + 1 + 1
Actual
fooRoll
works as expectedbarRoll
causes a fatal error due to no prop being found for@foo
in the@foo + 1
formula.Workarounds
This appears to be happening due to either how
getRollData()
is returning for the actor, or possibly due to differences in how rolls are evaluated now versus when this feature was originally written for SWB. I was able to work around it by modifyingSimpleActorSheet#_onItemRoll()
to use the following logic:The text was updated successfully, but these errors were encountered: