Assigning text to various numbers.

Started by jamesreg, Fri 25/01/2019 00:51:57

Previous topic - Next topic

jamesreg

Here is what I am trying to do I am having a journal/Log Entry system in my game in which at various times a journal entry or log will be made and I want to be able to access this though in an interactive dynamic gui interface. The problem lies is the game will have nearly 500 of these log/journal entries and the game is open ended allowing the player to play any level in any order they want. Each level will have its own journal/log entry. So it is not as simple as level one text is journal entry 1 and so on.

I will have something like this 65.00.00 when the player gets a log/journal message it will change the number to 65.00.01 Imagine this as a date system 65 is years the year number.  The first set of 00 is months it will go to 12. the second set of 00 is days it will go to 30   So 65.00.01 will be the first log entry and it could be one of 500 text that I will need displayed depending on what order the player played the game levels. The player will then access a gui which allows him to click between all the various dates and review the log entries . I need to know how I can store what number I am at and apply the needed text for that number as needed.

Can someone help me figure out or how to do this or get me on the right direction.

Monsieur OUXX

#1
Something like this:

Code: ags

struct AllTexts {
  String text[500];
};
AllTexts allTexts;

void game_start() {

allTexts.text[0] = "This is one possible text.[It's cool.";
allTexts.text[1] = "This is another text.[Still very cool.";
// ...
allTexts.text[499] = "Last possible text.";


}


Now you have your generic texts initialized.

Code: ags


#define MAXLEVELS 100 // maximum number of levels, which is also the maximum number of log entries
struct LogStruct {
   String logEntriesTitles[MAXLEVELS];
   int logEntriesTexts[MAXLEVELS];
};
LogStruct log;
int currentLevel;

void generateNewLogEntry() {

   log.logEntriesTexts[currentLevel] = Random(499);
   log.logEntruesTitles[currentLevel] = String.Format("65.0.%d", currentLevel);
   currentLevel++;
}

void game_start() {
generateNewLogEntry();
}



Now you know how to generate s title for the current level and how to pick a text at random. When the game starts, it does it for current level (level 0).

Code: ags

// Code below is for a GUI containing two labels : LabelTitle and LabelText

void DisplayLog(int currentPage) {
  guiLog.Visible = true;
  LabelTitle.Text = log.logEntriesTitles[currentPage]
  LabelText.Text = allTexrs.text[log.logEntriesTexts[currentPage]];
}



Now you know how to display the title and text of any page, provided current page is between 0 and currentLevel..
Whenever the player reaches the next level, call generateNewLogEntry and then DuspkayLog(currentLevel);

The flaw in this Proof of concept is that Random can pick twice the same text, so you'll have to keep track of which numbers have already been picked for previous log entries.
 

jamesreg

I wanted to say thanks for the help on this.

I have not had a chance to work on it pesky life things get in the way of fun. I have not had a chance try it out yet. But I am about to be on vacation from work so plan to do a lot of work on my game during that time. But I wanted to say thanks and not have got such great help and let it seem I was unappreciative of it.


SMF spam blocked by CleanTalk