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
arcanistzed
arcanistzedOP•4y ago
🧵 myActor + "['data']" doesn't return myactor['data']. Instead, it returns "myactor['data']"
Calego
Calego•4y ago
helpers - Foundry Virtual Tabletop Developer API
Documentation for the client-side JavaScript API in Foundry Virtual Tabletop.
Calego
Calego•4y ago
Where is your input being created? a Dialog?
arcanistzed
arcanistzedOP•4y ago
A form application I think that's the solution, thanks!
Leo The League Lion
Leo The League Lion•4y ago
@arcanistzed gave vote LeaguePoints™ to @calego (#1 • 1086)
Calego
Calego•4y ago
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 nameed inputs in the <form> element of the formAppliation
arcanistzed
arcanistzedOP•4y ago
I'm going to take a look at how that works in case I ever want to do this outside of Foundry
Calego
Calego•4y ago
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.....)
arcanistzed
arcanistzedOP•4y ago
Ah, nice trick with Array reduce

Did you find this page helpful?