#save dropdown values in modalforms?
1 messages · Page 1 of 1 (latest)
I meant like, do you want to use a scoreboard, some sort of database, dynamic properties, ect, but dynamic properties would probably be easiest for this
I'll just drop my approach here:
let options = player.getDynamicProperty("savedOption");
options = options ? JSON.parse(options) : []
const ui = new ModalFormData()
.dropdown('Label1',["blue","red","green"],options?.[0]??0)
.dropdown('Label2',["water","fire","wind"],options?.[1]??0)
.show(player).then(response=>{
player.setDynamicProperty("savedOption",JSON.stringify(response.formValues));
//other code
})
Oh, let's hear your approach then. Maybe using a scoreboard is another way to avoid getting reset by /reload
Or you know... you can just save it to different properties as integers.
alright fine, decimal.
Or Number
Which one do you like?
fair enough.
I was just gonna say do player.setDynamicProperty("chatColorIndex", data.formValues[3]) to save the value
and then to get it to set the default use player.getDynamicProperty("chatColorIndex") ?? null 🤷♂️
that's the basic idea of how my approach is tho.
Yeah, it just doesn't save everything in formValues, they didn't need that 🤷♂️
It should yes
I mean with that approach, you can avoid using the hasTag and stuff...
Oh well, anything works in the end. So it doesn't matter.
Yeah, they could refactor there code to not use tags, but even if they do it'd probably make more sense to save each number as it's own dynamic property than to save one json string dynamic property 🤷♂️ this is their code though so they're free to do it how they like
Sweet
Hm?
I don't follow?
What are you considering the default value the dropdowns reset to?