So I want to make the progress bar to change colour when charging and change when discharging

I cant find out how to make the progress bar change colour from the script when charging and discharging.

$if (bi(charging)=1,“charging color”, “normal color” )$