Lavaeolous / PF1-StatBlock-Converter-Module

FoundryVTT Module to convert PF1 Statblocks into Foundry Actors (PC or NPC).
MIT License
14 stars 12 forks source link

Update creation of attack subactions #534

Closed Lavaeolous closed 2 years ago

Lavaeolous commented 2 years ago

[9:01 PM] Ethaks: The API of actions is not yet fully compatible with the regular document stuff, so temporary creation works only via new ItemAction(somePartialActionData, parent) [9:03 PM] Primer: nice, i will try that. Is there some documentation related to actions/subactions i could consult? [9:03 PM] Ethaks: And then the order should be something like new ItemAction(…) → item.data.update({"data.actions": [ itemActionInstance.data ]}) → item.prepareData() [9:03 PM] Primer: i'm not particularily active on discord so miss most stuff [9:04 PM] Ethaks: The prepareData step is necessary to get the action into the collection, and calling item.data.update does not trigger a data preparation call (contrary to the DB-backed item.update, which would obviously not work for a temporary item). [9:06 PM] Ethaks: Not yet I'm afraid. There's currently no base class for components like Changes and Actions yet, so you'd have to read each component's source code to figure out which parts of the documents-like workflow they support. [9:07 PM] Ethaks: I've been preparing the introduction of a DocumentComponentPF class that covers most relevant parts of the regular API, but that'll most likely only hit once v10 is released, as it makes use of the new DataModel class. [9:09 PM] Ethaks: Until then the most important bits: the constructor can create a temporary class instance and has a signature like (partialComponentData, parent), and .create/.update etc. are used for permanent creation. [9:10 PM] Ethaks: And when modifying a document's data object with data.update() (which will become updateSource in v10 btw), run prepareData for the document afterwards if you want to get properly updated derived data etc.

Lavaeolous commented 2 years ago

Done