Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - papste

#1
I have disabled the control btnWalk "btnWalk.Enabled = false;" which is connected to the SetCursorMode (mode 0). However the button gets enabled automatically every time the character changes room. Is there a way to avoid this? I want the button to stay permanently disabled until i decide to re-enable it.

Having to program the command  "if (condition == true) btnWalk.Enabled = false" at room load (Before fade in) would not be a desired solution, meaning i have to add it to the script for every single room individually.

(edit): I am using version AGS 3.1.2 SP1
#2
Long explanation of the problem at hand included so please bare with me until the end:)

Due to the text parser limitation of allowing only 1500 entries i have created my own module including a text parser that reads vocabulary entries from a text file and fills an array. The reading is done at game start at a special room that i call "loading screen". The whole process used to take not more than 1 second to read around 2500 entries from the file and fill my array which worked fine for me. I would like to keep this module even if the parser limitation was raised, because its much easier for me to edit the text file and insert/remove words from it, rather than have to enter them in the parser one by one.

However during the game when the user inputs some text, my module splits the sentence into words and compares each word individually with the 2500 entries in the array deciding whether the word exists in the vocabulary whether it is a noun, adjective, verb, etc, and whether it is an ignored word or not. This process slows down the game as the user has to wait 2-5 seconds (depending on the machine's speed) after the text is entered for the calculations to take place. Also the background music which is playing tends to "tatter" during the calculation time.

So i came up with an idea to sort the array alphabetically in order to make it easier to find words in the array and not have to go all over the 2500 vocabulary entries multiple times for every word that the user enters. I have thus created a function that uses the bubble sort method and i have assigned the function to run at the loading screen, just after the array is read from the text file.

My problem is that the sorting procedure takes around 2-3 minutes and the user is forced to wait at the loading screen, which i find too much for a text adventure and is very annoying. The computer that i use is a fast one and i suspect the problem will be far too obvious on slower machines.

Following is the code that i used for the sorting. I had to use the noloopcheck command in order to achieve this. If anyone can help achieve faster sorting times i would be grateful for the help. The custom parser module that i created has solved a lot of problems for me. I would hate to have to throw it away just because the sorting takes too much time. My other option was to pre-sort the vocabulary file in Excel, but i would like to avoid this.

Code: ags

textParser.ash
------------------

#define MAX_WORDS_IN_VOCAB 5000

struct vocab {
  int groupId;
  String word;
  String attributes;
};

import vocab vocabEntry[MAX_WORDS_IN_VOCAB];

textParser.asc
-------------------

vocab vocabEntry[MAX_WORDS_IN_VOCAB];
export vocabEntry;

static function noloopcheck text_parser::sort_vocab() {
  bool swapped = true;
  vocab tempEntry;
  int loopCount = 0;
  while (swapped) {
    int i;
    swapped = false;
    while ((i <= MAX_WORDS_IN_VOCAB - 2) && (!String.IsNullOrEmpty(vocabEntry[i + 1].word))) {
      if (vocabEntry[i].word.CompareTo(vocabEntry[i + 1].word) > 0) {
        tempEntry.groupId = vocabEntry[i].groupId;
        tempEntry.word = vocabEntry[i].word;
        tempEntry.attributes = vocabEntry[i].attributes;
        vocabEntry[i].groupId = vocabEntry[i + 1].groupId;
        vocabEntry[i].word = vocabEntry[i + 1].word;
        vocabEntry[i].attributes = vocabEntry[i + 1].attributes;
        vocabEntry[i + 1].groupId = tempEntry.groupId;
        vocabEntry[i + 1].word = tempEntry.word;
        vocabEntry[i + 1].attributes = tempEntry.attributes;
        swapped = true;
      }
      i++;
    }
  }
// End of function.
}


I also figured i should include a part describing the text file structure in order to make it easier to understand how the array is set. So this is a small sample of the file containing only a few lines. The line is read and split into 3 parts (groupId, word, and attributes) and is passed into the vocab struct array.

vocab.txt
------------

1 the article
2 a article
3 an article
4 el article
5 la article
6 los article
50 and conjuction
51 or conjuction
52 nor conjuction
54 if conjuction
55 but conjuction
100 it pronoun
101 this pronoun
102 these pronoun
103 that pronoun
104 those pronoun
105 them pronoun
...
#3
After having carefully checked the manual and forums, i couldn't find anywhere the maximum number of text parser words. However the specific game that i was trying to develop gives me the error message that i have used too many words. It would help to know the correct number so that i can manage my game better and remove the unnecessary words. Also is there any chance of increasing the limit or any other way to overcome this obstacle? 
SMF spam blocked by CleanTalk