#Hunger buffs
1 messages ยท Page 1 of 1 (latest)
This should do it
if (state) return;
const full = actor.items.getName("Full");
const famished = actor.items.getName("Famished");
if (!full.system.active) {
await famished.update({"system.active": true});
}
if (full.system.active) is this boolean? I just want to make sure I understand how this works
I guess what it does in other words "if the buff called full is active, then" right?
Correct, it's reading full's system's active property which is a boolean (though in javascript an if condition can be anything and doesn't have to be a boolean)
It's the same property you're setting in your update method
I'd recommend using full.isActive instead
Yeah see my way was the noob way ๐
That's a good point, you can also use await famished.setActive(true); instead of the longhanded update method
Yeah, setActive() is preferable too. Avoids needing to know the internal data structure, since it does differ with some items.
Okay so change full.system.active to full.setActive(true) right?
no you got those mixed up
if (state) return;
const full = actor.items.getName("Full");
const famished = actor.items.getName("Famished");
if (!full.isActive) {
await famished.setActive(true);
}
Ok I think that one above should be correct. That would be a toggle script on "Hungry"
Yeah, I'll make adjustments based on this for each case ๐