#Hunger buffs

1 messages ยท Page 1 of 1 (latest)

modest hawk
#

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});
}
candid monolith
#

I guess what it does in other words "if the buff called full is active, then" right?

modest hawk
#

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

muted relic
#

I'd recommend using full.isActive instead

candid monolith
#

Yeah see my way was the noob way ๐Ÿ˜„

modest hawk
#

That's a good point, you can also use await famished.setActive(true); instead of the longhanded update method

muted relic
#

Yeah, setActive() is preferable too. Avoids needing to know the internal data structure, since it does differ with some items.

candid monolith
#

Okay so change full.system.active to full.setActive(true) right?

modest hawk
#

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);
}
candid monolith
#

Oh right

#

yeah

#

Thanks ๐Ÿ˜„

modest hawk
#

Ok I think that one above should be correct. That would be a toggle script on "Hungry"

candid monolith
#

Yeah, I'll make adjustments based on this for each case ๐Ÿ™‚