Create an interactive computer in the game?

Started by essaywrite7, Sat 28/05/2022 21:55:05

Previous topic - Next topic

essaywrite7

Hello,
I have been racking my brain about how to have the character in the game walk up to a computer terminal and be able to interact with a Computer menu system on the screen and search for key words, select menu options, and have text files open on the screen and things like that etc.

Can anyone think of how to create an interface like that?

Thank you

eri0o

#1
it all depends on what you want to achieve with this computer screen. Invest just as much time in this as you need to your game, properly scope what you need.

You can make it up with GUIs, just cohesively draw your UI to make up your interface. It doesn't have to be complicated. I recommend playing The Shivah because it features some really simple and minimal but also functional GUIs, and playing it, it's pretty obvious how they were implemented.

Using GUIs with labels, buttons and listboxes you should be able to do a fair amount of interfaces.

Below is an example in (one of my many...) unfinished games, in here I used a mix of GUIs and a plugin:

Video of it working

I also have a script module that allows to make up some stuff (but it may be a bit slow when the UI has too much stuff): https://www.adventuregamestudio.co.uk/forums/index.php?topic=58842.0

Here's an example FS simulation with search, this is what I made in the above video.
Fake FS Header
Spoiler
Code: ags
// new module header
#define MAX_RESULTS 5
#define MAX_STORAGE 50

enum FileType {
  eFT_TextFile = 0, 
  eFT_ImageFile, 
  eFT_EmailFile, 
  eFT_SoundFile, 
};

enum IconResSprite {
  eIRS_TextFile = 20, 
  eIRS_ImageFile = 30, 
  eIRS_EmailFile = 24, 
  eIRS_SoundFile = 23,
  
};

struct Search {
  import static bool Do(String term);
  import static bool HasNewResult();
  import static int GetResultCount();
  import static int GetResultFileIndexByIndex(int index);
};


struct ResultFile {
  import static String GetPath(int index);
  import static FileType GetType(int index);
  import static IconResSprite GetIconSprite(int index);
  import static String GetTextContent(int index);
  import static AudioClip* GetAudioClip(int index);
  import static int GetSpriteImage(int index);
  
  
  import static String GetEmail_From(int index);
  import static String GetEmail_To(int index);
  import static String GetEmail_Subject(int index);
  import static String GetEmail_Content(int index);
  
  import static bool IsFavorite(int index);
  import static void SetFavorite(int index, bool b);
};

import void ClearAllFileFavorites();
[close]

Fake FS Script
Spoiler
Code: ags
// new module script
String _result_msg;
bool _has_new_result;
int _result_count;
String _fs_tags[MAX_STORAGE];
String _fs_textContent[MAX_STORAGE];
String _fs_path[MAX_STORAGE];
FileType _fs_type[MAX_STORAGE];
IconResSprite _fs_spriteIfImage[MAX_STORAGE];
AudioClip* _fs_audioClip[MAX_STORAGE];
int _fs_imageSprite[MAX_STORAGE];
String _fs_email_from[MAX_STORAGE];
String _fs_email_to[MAX_STORAGE];
String _fs_email_subject[MAX_STORAGE];
String _fs_email_content[MAX_STORAGE];
bool _fs_isFavorite[MAX_STORAGE];

int result_indexes[MAX_RESULTS];

void _ClearResults(){
  for(int i=0; i<MAX_RESULTS; i++){
    result_indexes[i] = -1;
  }
  _result_msg = "";
  _has_new_result = false;
  _result_count = 0;
}

static bool Search::Do(String term){
  _ClearResults();
    
  if(term == null){
    _result_msg = "";
    return false;
  }
  
  if(term.Length <= 3){
    _result_msg = "Your search has to be more than three characters long";
    return false;
  }
  
  for(int i=0; i<MAX_STORAGE; i++){
    if(_fs_tags[i] != null && 
       _fs_tags[i].Length > 2 &&
       _fs_tags[i].IndexOf(term) >=0){
         
      result_indexes[_result_count] = i;
      _result_count++;
      continue;
    }
    if(_fs_textContent[i] != null && 
       _fs_textContent[i].Length > 2 &&
       _fs_textContent[i].IndexOf(term) >=0){
         
      result_indexes[_result_count] = i;
      _result_count++;
      continue;
    }  
    if(_fs_email_subject[i] != null && 
       _fs_email_subject[i].Length > 2 &&
       _fs_email_subject[i].IndexOf(term) >=0){
         
      result_indexes[_result_count] = i;
      _result_count++;
      continue;
    }  
    if(_fs_email_content[i] != null && 
       _fs_email_content[i].Length > 2 &&
       _fs_email_content[i].IndexOf(term) >=0){
         
      result_indexes[_result_count] = i;
      _result_count++;
      continue;
    }  
  }
  
  _has_new_result = true;  
}

static bool Search::HasNewResult(){
  if(_has_new_result){
    _has_new_result = false;
    return true;
  }
  return false;
}

static int Search::GetResultCount(){
  return _result_count;
}

static int Search::GetResultFileIndexByIndex(int index){
  if(index < MAX_RESULTS){
    return result_indexes[index];
  }
  return -1;
}

static String ResultFile::GetPath(int index){
  if(index < MAX_STORAGE){
    return _fs_path[index];
  }
}

static FileType ResultFile::GetType(int index){
  return _fs_type[index];
}

static IconResSprite ResultFile::GetIconSprite(int index){
  if(index < MAX_STORAGE){
    return _fs_spriteIfImage[index];
  }  
}

static String ResultFile::GetTextContent(int index){
  if(index < MAX_STORAGE){
    return _fs_textContent[index];
  }  
}

static AudioClip* ResultFile::GetAudioClip(int index){
  if(index < MAX_STORAGE){
    return _fs_audioClip[index];
  }  
}

static int ResultFile::GetSpriteImage(int index){
  if(index < MAX_STORAGE){
    return _fs_imageSprite[index];
  }  
}

static String ResultFile::GetEmail_From(int index){
  return _fs_email_from[index];
}

static String ResultFile::GetEmail_To(int index){
  return _fs_email_to[index];
}

static String ResultFile::GetEmail_Subject(int index){
  return _fs_email_subject[index];
}

static String ResultFile::GetEmail_Content(int index){
  return _fs_email_content[index];
}

static bool ResultFile::IsFavorite(int index){
  return _fs_isFavorite[index];
}

static void ResultFile::SetFavorite(int index, bool b){
  _fs_isFavorite[index] = b;
}

void ClearAllFileFavorites(){
  for(int i=0; i<MAX_STORAGE; i++){
    _fs_isFavorite[i]=false;  
  }

}

void game_start(){
  _ClearResults();  
  
  _fs_path[0] = "C:/Users/user/Documents/notes.txt";
  _fs_type[0] = eFT_TextFile;
  _fs_spriteIfImage[0] = eIRS_TextFile;
  _fs_textContent[0] = "Hi!\nExample text content.";
  
  // just add more files...  
}
[close]

essaywrite7

#2
Thank you for this direction. I did go back to try the use of GUIs again, and that did give me the breakthrough I was looking for. I just had to apply them in nonconventional ways, but it ended up doing what I needed. Thank you again for the suggestion!


Khris

Please do not uselessly quote the entire previous post. There's a Reply button at the bottom of the thread.

SMF spam blocked by CleanTalk