Thread:Jens Ingels/@comment-24416108-20141128155015/@comment-24416108-20141203223209

Well, It's all pretty much functional by now. There's still one little bug I'm trying to smash, but I don't think that'll take to long. I've tried the switch checking for the upgrades, but in the end I made it a single if statement that checks both whether a upgrade is specified, and whether the unit in question is actually qualified to receive the upgrade. I'll admit to using some blocks of code to show/hide the abilities, and it put the total to almost 400 lines, but it's the best way I can see.

There is one more thing I was hoping to ask you. The current version work nicely, but only on the first unit displayed on the page. Would you happen to know a good way to package this function in a loop such that it could work for more units on the same page? I was thinking about maybe a while loop that checks if a unit-template exists, and if true, then makes a new one. I guess unit0 would become the place to insert the instance ID. It's just the location calls that need updating, since the rest could basically use a common variable (the healthCalc and family for example). Could you give a basic advice on how to accomplish this?