Yanfly Absorption Barrier Based on Variable?

There doesn't seem to be a way to create a barrier based on a variable value but there must be a way using the custom barriers that you put in the note section. The problem is I don't know java script so I have no idea how I could make a custom barrier using variables.
I have this for one of my skills to make a custom barrier and it seems to work fine, I just don't know how I could edit this to use a variable instead of damage taken:

<Custom User Barrier>
user.clearAbsorptionBarrier();
user.gainBarrier(user.hp/2, 3);
user._result.hpDamage = -user.hp/2;
</Custom User Barrier>
The statement to get the value of a Game Variable is:
Code:
$gameVariables.value(x)
Where x is the id of the variable you want to use.
The statement to get the value of a Game Variable is:
Code:
$gameVariables.value(x)
Where x is the id of the variable you want to use.

Wow.. I actually knew that but I didn't know what to do with it. I just edited it into my old formula and it worked fine.. Thanks ^.^

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-absorption-barrier-based-on-variable.89345/