Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 05-15-2013, 12:18 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by JohnnyChimpo View Post
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.0temp.LANGUAGE_COUNTtemp.++) {
    
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.0temp.8temp.++) {
    
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");
  }

__________________
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:07 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.