How do I make a highlighted choice set a variable?

I'm trying to create a show choice plugin that changes a variable depending on which choice is highlighted.
The closest thing I've found was Galv's Choice Pictures, which makes a different picture appear depending on which choice is highlighted. I tried to do some tampering with it but I can't get it to actually affect the variable. Does anybody know a workaround?


[EDIT] Solved.

In the Galv_PictureChoices.js I added $gameVariables.setValue(obj.x, obj.y); underneath the line Galv.CPICS.showPic = function(obj) {
Setting the variables to obj.x, obj.y means that whenever I add <p:imageName,x,y> to the choice display options, it'll refresh variable x to value y in real time! I took out the code that made the picture appear. I don't plan to use the plugin for its intended purpose so it works for me!
you want to set a variable AFTER the player makes the choice? Why not just use a Show Choices event command and do a Control Variables inside each option?
I'm trying to create a show choice plugin that changes a variable depending on which choice is highlighted.

hook up a refresh routine to the selection routine.
start by locating the button handler (that detects the pressing of the button) and work your way down.
from the button press, to the choice selection, to the picture update.
you want to set a variable AFTER the player makes the choice?
Nope. What I wanted to do was make it so the choice display refreshes a variable in real time.

...and work your way down.
You wanna know what my mistake was? I started from the bottom up. I was fooling with the "Window Choice" section when my solution was found in the "Code Stuff" section.

So here was my solution:
In the Galv_PictureChoices.js I added $gameVariables.setValue(obj.x, obj.y); underneath the line Galv.CPICS.showPic = function(obj) {
Setting the variables to obj.x, obj.y means that whenever I add <p:imageName,x,y> to the choice display options, it'll refresh variable x to value y in real time!

There's probably a simpler way to do this, but since I don't intend to use the plugin for its intended purpose, it works for me!

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-make-a-highlighted-choice-set-a-variable.90178/