First of all scripts are case sensitive, `Var` will not compile it need be `var`.
Second, how match it to unit? One solution is add copy of this script to unit data like:
armors:
- type: PARROT_ARMOR
drawingRoutine: 4
scripts:
recolorUnitSprite: |
#text there
Each unit can have it own script (it will be call with offset `0`)
Next is global script:
extended:
scripts:
recolorUnitSprite:
- offset: 1 #if you set `-1` it will call before script set in `armors`
code: |
#code there
But this will call for every unit in game, one way to change it it alter logic to check for custom tags that enable this behavior:
extended:
tags:
RuleArmor:
LUKE_MOD_HEALTH_BAR: int
scripts:
recolorUnitSprite:
- offset: 1 #if you set `-1` it will call before script set in `armors`
code: |
var int recolor;
unit.getTag recolor Tag.LUKE_MOD_HEALTH_BAR;
if and gt recolor 0 eq current_color new_pixel;
set_color new_pixel 4; #green color
end;
return new_pixel;
armors:
- type: STR_NONE_UC
tags:
LUKE_MOD_HEALTH_BAR: 16 #definition of tag in each armor that should use it, default have `0`
Another import thing is test if your mod work correctly, you can add debug lines to see what happens exacly using:
debug_log 10; #will print 10 to `openxcom.log`
debug_log recolor; #will current value of this to `openxcom.log`
debug_log 111 unit; #will print 111 and some basic info about unit to `openxcom.log`
debug_log 1 2 3 4 5; #it can have multiple values pass