insert file into array?

  • Russkie
  • Newbie
  • Newbie
  • Russkie
  • Posts: 9

Post 3+ Months Ago

Hey everyone, new person with old stupid questions....
i know this stuff is elementary but truthfully i dont know much in this area but here goes...

im making a hangman game, well no, im changing someone elses game to learn some stuff. so what this guy did is he created a ton of arrays for different dictionaries in the game (e.g. music, animals, blah blah blah).
now his coding looks like this:

Code: [ Select ]
var dict2 = new Array("rabbit", "koala", "kangaroo");
var dict3 = new Array("grapefruit", "celery", "cabbage");
  1. var dict2 = new Array("rabbit", "koala", "kangaroo");
  2. var dict3 = new Array("grapefruit", "celery", "cabbage");

and when u select which dictionary in the game he does later:

Code: [ Select ]
words = dictX;

(x being the number of dictionary)

now my probelm:
i dont want the array in the game, i need it in a text file for easy manipulation. so im looking around for ways to do it and this is what i got:

Code: [ Select ]
dict1Data = new LoadVars();
allWords = dict1Data.dict1;
dict1 = new Array();
dict1 = allWords.split("||");
  1. dict1Data = new LoadVars();
  2. dict1Data.load("C:/kindercomp/games/words.txt");
  3. allWords = dict1Data.dict1;
  4. dict1 = new Array();
  5. dict1 = allWords.split("||");

and the length is defined later on...
so what the ......? it does not have the words in there... i assume so becasue otherwise the game should pick them up no? no new variables interefere with the games current ones, the essential value of dict1 shuold be the same as the original new array style of just listing them in the ()...

any insight would be much appreciated ty.
  • Russkie
  • Newbie
  • Newbie
  • Russkie
  • Posts: 9

Post 3+ Months Ago

furthermore after playing with it for a while

what i realized was that if i made "dict1" into "word" and then did:

Code: [ Select ]
var dict1 = new Array(word[1], word[2]);

it still would not accept the values as words, but
Code: [ Select ]
value returned the proper amount of "objects" in the array...?!?

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 11 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum

© 1998-2017. Ozzu® is a registered trademark of Unmelted, LLC.