Code:
if (tagis[SkillBonus.?] <> 0) then
expr = tagids[SkillBonus.?, " | "]
foreach pick in hero from Skill where expr
perform eachpick.field[trtBG].modify[+,2,""]
nexteach
endif
The line of code I've outlined in red is why your only seeing a +2 bonus applied. You're telling the software that for any SkillBonus tag it should apply a +2 bonus via the modify part of this script. If you are using the SkillBonus tag group to determine the value of the bonus, you need to rig it up to apply the proper bonus.
Also, the foreach loop might not even be necessary, you could rig this in an eval script on the skills component and cut the foreach loop out of the equation completely.
For example, using if () then statements to cycle through your tags...
If (tagis[SkillBonus.1] <> 0) then
perform eachpick.field[trtBG].modify
[+,1,""]
elseif (tagis[SkillBonus.2] <> 0) then
perform eachpick.field[trtBG].modify
[+,2,""]
endif
You can cycle through all your Skill Bonus tags, telling hero lab to apply the bonus based on the presence of a specific tag within your foreach statement. This should fix the issue of only applying a +2 bonus.
Also, the foreach loop is possibly completely unnecessary. If you rig hero lab to forward SkillBonus tags to the skills themselves you can have an eval script on your skill component that does all the trait modifications without needing that foreach loop.
You can do this by rigging a skill linkage and having your background traits establish the linkage. Then in an eval script use linkage[basis].setfocus and perform focus.assign[SkillBonus.X] to the skill directly...