Help streamlining loadVars code
Posted: Mon Oct 10, 2011 6:12 pm
I am looking to have the computer come up with a random number and load a file based on that number. However I will have between 500 and 1000 files to choose from. Here is what my code looks like...
Done like this, it comes out to be about 6,000 lines long and I need it to run 12 times per game. Can anyone let me know of a more streamlined way of doing this using arrays or concatenation or anything?
- Code: Select all
if (randcatloader == 1) {
loadVars("qfile_001.jqf", "Category");
loadVars("qfile_001.jqf", "Question1");
loadVars("qfile_001.jqf", "Question2");
loadVars("qfile_001.jqf", "Question3");
loadVars("qfile_001.jqf", "Question4");
loadVars("qfile_001.jqf", "Question5");
} else if (randcatloader == 2) {
loadVars("qfile_002.jqf", "Category");
loadVars("qfile_002.jqf", "Question1");
loadVars("qfile_002.jqf", "Question2");
loadVars("qfile_002.jqf", "Question3");
loadVars("qfile_002.jqf", "Question4");
loadVars("qfile_002.jqf", "Question5");
.
.
.
} else if (randcatloader == 999) {
loadVars("qfile_999.jqf", "Category");
loadVars("qfile_999.jqf", "Question1");
loadVars("qfile_999.jqf", "Question2");
loadVars("qfile_999.jqf", "Question3");
loadVars("qfile_999.jqf", "Question4");
loadVars("qfile_999.jqf", "Question5");
}
Done like this, it comes out to be about 6,000 lines long and I need it to run 12 times per game. Can anyone let me know of a more streamlined way of doing this using arrays or concatenation or anything?