#Prof_dresser macro assistance

1 messages ยท Page 1 of 1 (latest)

ruby cipher
#

There may be an issue with the argument. If you can't read ._id it probably means that the argument isn't a valid target.

#

Log args[0] and check it's what you think it is.

normal quail
#

Where would be the best place to put the "Log" command in the macro. I tried just slapping it in, but it didn't like it.

ruby cipher
#

Er, it's console.log(args) in that context. I used log as a shortcut. ๐Ÿ™‚

#

Are you actually feeding args to your macro call?

normal quail
#

๐Ÿ˜› Yeah, I remembered that while I was in the shower. Thanks.
No, I'm not feeding it any args.

ruby cipher
#

That'll be your problem, as args implies arguments. ๐Ÿ™‚

normal quail
#

So it says that the caster is arg[0], which is what I wanted... hm... I'm checking something.

#

I have one other "_id":

    let castItem = tactor.data.items.find(i => i.name === "Dragon's Breath (attack)" && i.type === "weapon");
    if(castItem) await tactor.deleteOwnedItem(castItem._id)```
I wouldn't think that'd be it, because it's in the version where I'm not calling the spell DC and it doesn't throw any errors then...
ruby cipher
#

What type of object is the caster, though? A token? An actor?

#

If it's an actor, args[0].actor is not valid.

normal quail
#

Yeah, it is an actor.

ruby cipher
#

There's your problem.

normal quail
#

I was copying code from similar macros

ruby cipher
#

You also don't need to get the actor if you already have the actor.

normal quail
#

So, I could call on the 'tactor' instead?

ruby cipher
#

No, I mean if args[0] is the actor, you don't need:
const actorD = game.actors.get(args[0].actor._id);

Because args[0] is already the actor.

#

The code there only works for real actors, too.

#

As synthetic actors (i.e. ones on tokens without 'link' checked) don't exist in the game's actor list.

normal quail
#

I've only been targeting linked actors (thought that's good to know for the future).

#

Do you have any advice on how to pull the spellDC? That seems to be the real stumbling block.

ruby cipher
#

I don't know anything about the structure of D&D5e, but it's probably a matter of finding the specific item representing the spell and doing something with its data.

#

Print the actor to the console to read its data structure. Items are stored in the actor.data.items structure, usually.

normal quail
#

I'm trying to get the data off of the caster first and then apply it to the item.
actor.data.data.attributes.spelldc
actor.data.data.items.data.save.dc

ruby cipher
#

Ahh, I see.

#

So where are you coming unstuck? What do you mean by 'pull the spell DC'?

#

You can just get it by referring to actor.data.data.attributes.spelldc I assume.

normal quail
#

Sorry my terminology is not the best. Yes, I want to copy the caster's spellcasting DC onto the item because otherwise it tries to pull it from the actor who is receiving the item.

#

Essentially, I want to make actor.data.data.attributes.spelldc into a variable.

ruby cipher
#

Yes.

#

Then apply that variable to the new item.

normal quail
#

Exactly.

ruby cipher
#

Okay, so, you should have what you need now!

normal quail
#

?

#

Well, I have to get going. I'll hit my head against it some more tomorrow. Thank you very much for all your help. Even without this, the macro is really great.