« first day (653 days earlier)      last day (694 days later) » 

10:17 PM
A FoundryVTT macro for the Sorcerer's Flexible Casting feature:
main();

async function main() {
	let actorCopy = duplicate(actor);
	let spells = actorCopy.data.spells;
	let resources = actorCopy.data.resources;

	let actorName = actorCopy.name;

	let spellCosts = [
		{name:"1st Level", spelldata:spells.spell1, buy:2, sell:1},
		{name:"2nd Level", spelldata:spells.spell2, buy:3, sell:2},
		{name:"3rd Level", spelldata:spells.spell3, buy:5, sell:3},
		{name:"4th Level", spelldata:spells.spell4, buy:6, sell:4},
		{name:"5th Level", spelldata:spells.spell5, buy:7, sell:5},
 
that's just javascript
@_@
 
Yep.
 
well
"just"
i'ts like A LOT
 
Well, the upside: anything you know or learn about Javascript will probably apply to this code.
The downside: you have to learn/know Javascript.
🙃
Conceptually, though, there's only three parts to the code above.
1. Setting up the data that the macro will need to use (getting a copy of the actor data, getting aliases to the spell data and resource data, creating an array of required data for each spell level)
2. Creating the UI, which is just a fragment of HTML with some injected values from the javascript (for example, using spellOptions, which is a string used to populate the dropdown menu)
3. Showing the UI in a dialog box, and then responding after the user selects the "OK" button by figuring out what the user selected and applying the necessary data changes.
 
I'm kind of a web developer so I should be able to handle Javascript xD
 

« first day (653 days earlier)      last day (694 days later) »