periodic / foundryvtt-summoner

A module to help with summoning tokens in the Foundry Virtual Tabletop
MIT License
4 stars 1 forks source link

Uncaught (in promise) Error: Token.fromActor factory method #16

Open Merudo opened 3 years ago

Merudo commented 3 years ago

When I use the Summoner module I get the following error:

Uncaught (in promise) Error: The Token.fromActor factory method has been deprecated in favor of passing the result from Actor#getTokenData to the TokenDocument constructor
    at Function.fromActor (foundry.js:45781)
    at summoner.js:282
    at Generator.next (<anonymous>)
    at summoner.js:7
    at new Promise (<anonymous>)
    at __awaiter (summoner.js:3)
    at createSummonedToken (summoner.js:273)
    at receiveMessage (summoner.js:262)
    at dispatchMessage (summoner.js:247)
    at summoner.js:228
periodic commented 3 years ago

What version of Foundry are you running?

Merudo commented 3 years ago

0.8.8, with D&D 5e 1.3.6.

sean-phyx commented 3 years ago

Also having this issue, There is also warnings for:

The Folder#entities property has been renamed to Folder#contents. Support for the old property name will be removed in 0.9.0 foundry.js:14305:13

The Document#hasPerm method has been deprecated in favor of Document#testUserPermission. Support will be removed in 0.9.0

alxdean commented 3 years ago

Same. Summoner Module not working for me on 0.8.8. I get an option to place sth. but when I do the error pops up in the console. Foundry 0.8.8; D&D5e 1.4.2

periodic commented 3 years ago

Sorry about the delay, everyone. I've been pretty slammed with work this summer and haven't had as much time to invest in Foundry.

If anyone wants to submit a pull request I'll happily get it pushed out to the live version, but at the moment I'm not sure when I can get around to fixing this except if I can claw some time on the weekend.

I guess with two reports I should just get it done so the community can move forward. :smile:

alxdean commented 3 years ago

Don't worry about me. I ended up using the link to the macro you posted as a reply to another thread, modified it heavily, and now have a way for the drakewarden in the group to summon his drake. Macro even lets him chose which flavour and activates the appropriate effects, like fire resistance and extra fire damage for the fire version. So I'll be uninstslling the module again, now that i have a macro solution

Merudo commented 3 years ago

Don't worry about me. I ended up using the link to the macro you posted as a reply to another thread, modified it heavily, and now have a way for the drakewarden in the group to summon his drake. Macro even lets him chose which flavour and activates the appropriate effects, like fire resistance and extra fire damage for the fire version. So I'll be uninstslling the module again, now that i have a macro solution

Could you share that macro with us :) ?

alxdean commented 3 years ago

@Merudo , here you go. I use tabs for my code, so they are all stripped out here. sorry. plus I had to replace some single quotes. hope this version works for you.

//requires a creature named "Drake Companion" in the actor list. Player needs Owner rights as well as game permissions to create tokens, same like for Wildshape. //Drake also needs to have the different active effects available with names like "Acid Type" , "Fire Type" etc. //the active effect has two effects. one for the immunity and one for Bonus Melee Weapon Damage of 2[Acid] or 2[Fire] etc. // the macro does not handle player leveling yet. so when the Proficiency bonus goes up, the drake needs to be upgraded, and each of its active effects. //originally the macro was async, but I was having issues activating the effect at the right time, so the script became synchronous. //Todo: make the Infused Strike of the creature also take on the damage flavour. might do something similar like Midi-quol Spiritual Weapon does and add the Infused Strike weapon to the creature on the fly or modify it.

function selectShape(chosencreature){ let typeDialogOptions = "";
typeDialogOptions += ''; typeDialogOptions += ''; typeDialogOptions += ''; typeDialogOptions += ''; typeDialogOptions += ''; let dialogContent = `

Select your Type

                    <div style="flex:1">Type:<select name="shape">${typeDialogOptions}</select></div>
                    `;

new Dialog({ title: "Drake Companion Type", content: dialogContent, buttons: { accept_button: { label: 'Summon Drake!', callback: async (html) => {
let shapeId = html.find("[name=shape]")[0].value; let creature = game.actors.getName(chosencreature); const effect_name = shapeId + " Type"; const effect = creature.data.effects.contents; for (let i = 0; i < effect.length; i++){ let condition = effect[i].data.label; let effect_id = effect[i].data._id;
if (condition.includes("Type")) { if (condition != effect_name) await creature.updateEmbeddedEntity("ActiveEffect", {"_id": effect_id, "disabled" : true});
else await creature.updateEmbeddedEntity("ActiveEffect", {"_id": effect_id, "disabled" : false});
}
}
results = await spawnActor(canvas.scene,canvas.templates.placeables.map(x=>x).reverse().find(t => t.data.user == game.user.id)?.data || canvas.tokens.get(token.data._id),shapeId); //let draketoken = results[0]; TODO: swap the code to add effect on created token instead of the actor in the compendium. } } }, default: "accept_button" }).render(true); } let chosencreature = "Drake Companion"; //debugger selectShape(chosencreature) /* intended for use with Item Macro. 'item' here is the spell being cast if using outside Item Macro / /* spawns an actor with the same name as the spell at the location of the template / //(async ()=>{ function spawnActor(scene, template,draketype) { let protoToken = duplicate(game.actors.getName(chosencreature).data.token); protoToken.x = template.x; protoToken.name = draketype + " Drake"; protoToken.y = template.y; protoToken.flags.summoner = token.data._id; // Increase this offset for larger summons protoToken.x -= (scene.data.grid/2+(protoToken.width-1)scene.data.grid); protoToken.y -= (scene.data.grid/2+(protoToken.height-1)scene.data.grid);
return canvas.scene.createEmbeddedDocuments("Token",[protoToken]); } //})();`

alxdean commented 3 years ago

here is a clean version of the code in git: https://github.com/alxdean/foundryvtt/blob/master/Macros/Summon%20Drake.js