...have you tried entering a number like 0, and looking at the values of the variables?
As mentioned earlier, if you're not sure what value a variable has, use the "Write a Value to the Event Log" action to check. This is one of the most basic principles of debugging.
The "EDDI ship loadout compartments" integer variable should contain the amount of "compartments", so if that number is 5, indices 0 to 4 should be valid.
E.G. if you then have a look at the value of the "EDDI ship loadout compartments 0 module name" text variable, that should be the name of the first module.