WindowRectOp (win, 2, 0, 0, 0, 0, ColourNameToRGB("sandybrown"))
WindowRectOp (win, 2, 12, 20, 185 * math.floor((tonumber(stat["H"]["current"]) / tonumber(stat["H"]["max"]))), 40, ColourNameToRGB("darkred"))
WindowRectOp (win, 1, 12, 20, 186, 40, ColourNameToRGB("black"))
WindowText(win, "fn", "Health:" .. stat["H"]["current"] .. "/" .. stat["H"]["max"], 14, 24, 0, 0, ColourNameToRGB("black"), false);
this code purpose is to display the bar that show the percent of a certain stat by painting the bar to correct percentage of full size of the bar.
It would be this math formula for above in peusdo code as example:
bar_right_size * (current_hp / max_hp)
When i try to test the bar by set it to 50% as test. however, i saw that does not correctly split bar in neat half. I realized that I should offset the bar's left size. SO how can I do that? thanks!