Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populating / Caching the available attributes so they can be used in disconnected items #248

Closed
draconas1 opened this issue Oct 11, 2022 · 1 comment

Comments

@draconas1
Copy link
Contributor

Currently there is a problem in that because the item-use attribute selector is a drop down box, the value must come from the box. The possible values for the box are calculated off the owning actor.

This means that items that are created separately can't have one selected, and items that are dragged from an actor to a free-floating item lose theirs as soon as they are opened. (We do I believe sidestep this with the example compendium ones, because they are read only, and the "loss" only happens when the item is opened in an updatable UI that updates based on the value in the dropdown. We dragged the potions directly from character -> compendium. so provided you drag them back compendium -> character they work, but go compendium -> item -> character they will loose their attribute if you open them as an item)

Trying to consider a way this can be unlinked from a specific actor and a generic list of actor attributes can be populated at system startup time (so we don't have to remember to update it when modifying the system) and then that is fed to the dropdown instead.

I am ruminating on this problem, as initially there are no actors in the system to use, so I need to think of a way to get all the relevant attributes of the actor without actually having an actor. I will look at the code on how the system is doing this in the first place at some stage, but for now am putting down thought experiment comments on possible solution.

@draconas1
Copy link
Contributor Author

Storyguide on discord has this useful snippet that may get us where we want: Object.keys(foundry.utils.flattenObject(game.system.model.Item))

draconas1 added a commit to draconas1/dnd4eBeta that referenced this issue Oct 29, 2022
Rejigged the _getItemConsumptionTargets method:

'attribute' is now first, because attributes can now function separately.
If there is an attached actor, function as before.
If there is no actor grab the Player Character model and use that.

If you've not asked for an attribute and are not attached to an actor, then return nothing as before, the others all need a backing actor.

Items with attribute backing can now be created in the items tray and copied backa nf forth between characters and items so long as they are using default model.
EndlesNights added a commit that referenced this issue Oct 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants