Dynamically get Object property from user input
Anyone know how I can do this?
I have an Actor (
myactor
) and I'd like to have an input box which the user can use to refer to any of its properties, by typing in a path (i.e. @data.abilities.str.proficiency
).
How can I get that property within my script after they type in the box?
I'm thinking that I could use Autocomplete Inline Properties, but don't know if that does this.9 Replies
🧵
myActor + "['data']"
doesn't return myactor['data']
. Instead, it returns "myactor['data']"
helpers - Foundry Virtual Tabletop Developer API
Documentation for the client-side JavaScript API in Foundry Virtual Tabletop.
Where is your input being created? a Dialog?
A form application
I think that's the solution, thanks!
@arcanistzed gave LeaguePoints™ to @calego (#1 • 1086)
The input's value should be available as part of the
_updateObject
's parameters. One of those is all of the data of all of the name
ed inputs in the <form> element of the formAppliationI'm going to take a look at how that works in case I ever want to do this outside of Foundry
Here's similar from lodash: https://lodash.com/docs/4.17.15#get
Must easier to read than lodash source:
https://youmightnotneed.com/lodash/#get
(welcome to recursion. please make yourself welcome to recursion. please make yourself welcome to recursi.....)
Ah, nice trick with Array reduce