#Prof_dresser macro assistance
1 messages ยท Page 1 of 1 (latest)
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.
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.
Er, it's console.log(args) in that context. I used log as a shortcut. ๐
Are you actually feeding args to your macro call?
๐ Yeah, I remembered that while I was in the shower. Thanks.
No, I'm not feeding it any args.
That'll be your problem, as args implies arguments. ๐
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...
What type of object is the caster, though? A token? An actor?
If it's an actor, args[0].actor is not valid.
Yeah, it is an actor.
There's your problem.
I was copying code from similar macros
You also don't need to get the actor if you already have the actor.
So, I could call on the 'tactor' instead?
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.
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.
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.
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
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.
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.
Exactly.
Okay, so, you should have what you need now!