Quote:
Originally Posted by JohnnyChimpo
That worked thank you very much callimuc, i just have one thing to say however. In the whole grand scheme of things isn't quite inefficient to go and add another function call there? This language should accept the form i had written the first time. That and i could be wrong, but it would be a better means of doing it, based on the two.
|
The first way you wrote it didn't define the array.
You could do...
PHP Code:
// create an array with 8 elements and fill them all with the same thing
const LANGUAGE_COUNT = 8;
function onActionServerside() {
temp.filenameArray = new[LANGUAGE_COUNT]; // this is better than callimuc's version
for (temp.i = 0; temp.i < LANGUAGE_COUNT; temp.i ++) {
temp.filenameArray[temp.i] = "levels/translations/server_de.po";
}
}
but it's a bit silly. Is it faster than using
array.add()? Uh, probably, but you'll never notice and there's no reason to over-optimize the code at the expense of readability. I almost never see arrays defined like this (I actually had to look up the syntax to make sure I was right).
PHP Code:
// create an array with 8 elements and fill them all with the same thing
function onActionServerside() {
temp.filenameArray = {};
for (temp.i = 0; temp.i < 8; temp.i ++) {
temp.filenameArray.add("levels/translations/server_de.po");
}
}
I'm not really sure what you're trying to do.
edit: saw this in your other thread, this is better than all of the above:
PHP Code:
function onCreated() {
this.languages = {"de","es","fr","it","ne","no","po","sw"};
this.fileArray = {};
for (temp.lang : this.languages) {
this.fileArray.add("levels/translations/server_" @ temp.lang @ ".po");
}
}