Open p4535992 opened 11 months ago
Can you share some examples of what your module is meant to do? You might be able to just access the setting with the triggers instead.
Or maybe adding a Hook call on Triggler when triggers are run or something instead.
@mclemente The use case is this i want to use the trigger database to choose what code to launch:
const actor = ...
// Check if actor can speak draconian using a existent triggler
const canSpeakDraconic = game.modules.get("condition-lab-triggler").api.isTrigglerPositiveByTriggerId(actor, "triggerId");
if(canSpeakDraconic) {
// Do something and maybe laungh the "apply macro and effect action later" with another api method
}
and maybe a API to use with a code prepared triggler, can be useful too if i dont' want to update the module setting
const actor = ...
// Check if actor can speak draconian using a new prepared trigger (no need for a id here)
const trigger = {
attribute: ...,
category: ...,
notZero: ...,
npcOnly: ...,
pcOnly: ...,
operator: ...,
property1: ...,
property2: ...,
triggerType: ...,
value: ...,
advancedName: ...,
};
const canSpeakDraconic = game.modules.get("condition-lab-triggler").api.isTrigglerPositive(actor, trigger);
if(canSpeakDraconic) {
// Do something and maybe laungh the "apply macro and effect action later" with another api method
}
NOTE: This code is a beta I stopped before going any further to ask if you are okay with the idea.
I started with the idea of integrating the trigger mechanism into another module for example silly things like "Run this macro only if the current state of the actor triggers the specific trigger, but without launching any code on the actor it just check if it triggers it."
This is because I could exploit a lot of stuff already done in this module, but I found the api unintuitive, but maybe that's my problem... to make it more "standard" I created a separate API class and the three methods I could exploit in theory for my use case.
Specifically I would need your opinion on the code for the
_processUpdate
method which I have separated into two functions_prepareUpdate
and_processUpdate
.