Author Topic: MODULE: TypedText 0.7.0  (Read 5688 times)

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
MODULE: TypedText 0.7.0
« on: 12 Feb 2017, 22:53 »
DOWNLOAD TypedText 0.7.0 (beta version) MODULE PACK
Archive contains modules: TypedText, TypedTextHelper and TypedTextDrawing.
DOWNLOAD Demo Game

Latest source code may be found here
Git cloning address: https://ivan-mogilko@bitbucket.org/ivan-mogilko/ags-script-modules.git
Demo Game git cloning address: https://ivan-mogilko@bitbucket.org/ivan-mogilko/ags-script-demos.git

Module supports AGS 3.2.1 and higher


Introduction

TypedText module provides means for displaying continiously typed text, also known as typewriter style display. Letter appears by letter with certain delay in between.

A while ago I was scripting a typing text animation for a game project; later I found out that there is already Phemar's Typewriter module, but it did not allow the kind of behavior that the project required, so I continued with my own script.
Now I found some free time to rewrite that script in a cleaner way and make an actual script module of it. But I also copied few things from Phemar's module, to make TypedText suitable for the needs of people who used Phemar's module before.

The general peculiarity of this module, and also what makes it different from existing one, is that it is based on a Type (struct), and objects of that type, instead of a Function. This leads to following effects:
1. You can have multiple typed text animations simultaneously.
2. Since objects keep their states in them, you may have both blocking and non-blocking typed texts.
3. Having an object with exposed interface (public functions and properties) make it possible to alter its behavior on fly, as well as override it, and use it to create your own custom typewriters.


Using an object may be more complicated than using a single function, and require time to study it, so I added TypedTextHelper module with number of "helper" functions to make it easier to start using TypedText in your project. Also those functions may be just what you need if standart behavior is enough. This is why I will explain their use before going into detail about TypedText itself.

But first I need to quickly clarify on some concepts.


TypedText concepts

TypedText simulates continious text typing, letter by letter. When doing so it passes several states:

Inactive - this is when it has no text set whatsoever.
Typing text - this is when it is in process of typing text.
Waiting for reader - this is when all text was fully typed and displayed on screen, but settings demand TypedText to wait a little longer to give human an opportunity to finish reading the text.
Idling - this is when typing and waiting is complete, and TypedText is not going to do anything else.

NOTE: Helper functions, such as those that display TypedText on Overlays, rely on "waiting for reader" state to know when typed text should be removed from screen.

TypedText has a concept of the flashing caret. Depending on setup, it may flash last typed letter, or draw certain symbol behind typed text (like '_', for example).
The caret, if enabled, commences to flash whenever delay between two typed letters is greater than caret's waiting timer. This timer resets when next letter is typed. This also means that when all  the text was already typed, caret will then flash endlessly (so long as TypedText is on screen).

Keeping the above in mind, TypedText relies on following parameters:

Typing delay - how many game ticks to wait after each typed letter.
Typing delay style - this concept is copied from Phemar's module, and defines delay behavior for spaces and caret-returns in the text (are they same, slower than usual or faster than usual),
Caret depiction - is the caret is depicted anyway, and how: this may be flashing last letter, or specific string drawn in the end, or even a sprite - for the advanced TypedText implementations.
Caret flash times - how long caret stays on screen and stays hidden when it flashes.
Text reading time - how much time, in game ticks, is spent on reading 1 letter: this parameter is used to calculate average reading time of a text.

Finally, extended variants of TypedText also support sound that is played whenever next letter was typed.


Using TypedTextHelper

TypedTextHelper module requires TypedText module to present above it in the modules list.

It provides a number of functions to run typed text blocking or non-blocking, in a number of ways: on a Button, on a Label, or on an Overlay.

Because TypedText has a significant number of parameters, many of which are supposed to stay same for the most of the time in game, I thought it would be very inconvenient to put all of those parameters into functions. Instead, TypedTextHelper has a special preset system.
This works pretty simple actually: you setup least changing properties as a preset under certain ID, and then use that preset ID when starting typed text on Label, or Overlay; this makes all of that preset's parameters to be used for that instance of text typing.

Following are preset functions you may use:

Code: Adventure Game Studio
  1. /// Set general parameters for the specified preset
  2. TypewriterPreset.SetGeneral(int preset, int delay_min, int delay_max, TypedDelayStyle style, int read_time = 12);
  3. /// Set caret parameters for the specified preset
  4. TypewriterPreset.SetCaret(int preset, int flash_on_time, int flash_off_time, TypedCaretStyle style, String caret_str, int caret_sprite = 0);
  5. /// Set sound parameters for the specified preset
  6. TypewriterPreset.SetSounds(int preset, AudioClip *type_sound, AudioClip *caret_sound, AudioClip *end_sound);
  7. TypewriterPreset.SetSoundArray(int preset, AudioClip *type_sounds[], int type_sound_count,
  8.                                  AudioClip *caret_sound, AudioClip *end_sound);
  9.  

Maximal number of presets is determined with TYPEDTEXTHELPER_MAXPRESETS constant in the module header. It is 8 by default, but you may increase it if you need more.
Maximal number of sounds that you may assign for preset and each typewriter is determined with TYPEDTEXTRENDER_MAXSOUNDS contant.

Best place to set preset's parameters is "game_start" function, but you may change them anytime by using same preset ID.

After you set up at least one preset, you may begin using helper functions. All of them are made as extender functions, which means you first type object (Button, Label, Character) pointer name, then call the function from it, like:

Code: Adventure Game Studio
  1. // NOTE: preset is optional, and will be 0 if you don't type anything
  2. /// Print TypedText as a text on button
  3. SomeButton.Typewriter(String text, BlockingStyle bs, int preset = 0);
  4. /// Print TypedText as a text on label
  5. SomeLabel.Typewriter(String text, BlockingStyle bs, int preset = 0);
  6.  

The only difference is Overlay static extender (static extenders is a new thing since AGS 3.4.0), where you do not use overlay's pointer, but just "Overlay" word:
Code: Adventure Game Studio
  1. // NOTE: preset is optional, and will be 0 if you don't type anything
  2. /// Print TypedText as a text on created overlay
  3. Overlay.Typewriter(int x, int y, int color, FontType font, String text, BlockingStyle bs, int preset = 0);
  4.  
If you are working in pre-3.4.0, you will have to use non-extender function for overlays, called TypewriteOnOverlay, but it works essentially same, and has same parameters (except it is not called from Overlay).


If you run these functions with eBlock, they will display typed text inside of them, and return when typing (and waiting) state has finished.
If you run them with eNoBlock, they will return back immediately, but typed text will work on a background, updated from repeatedly_execute inside the module.

You may run only one blocking typed text at the same time.
Maximal simultaneous non-blocking typed texts is determined by TYPEDTEXTHELPER_MAXTYPEWRITERS constant in the module header. It is 8 by default, but you may increase it if you need more.


Each of those helper functions return unique ID of typewriter. If you want to control that typewriter, such as detect when it stops typing, or be able to cancel it, store this ID in a variable for later. You may then use this ID with TypewriterRunners static functions and properties:

Code: Adventure Game Studio
  1. /// Get number of currently running typewriters
  2. int TypewriterRunners.ActiveCount;
  3. /// Get number of maximal supported typewriters that can run simultaneously
  4. int TypewriterRunners.MaxCount;
  5. /// Get whether given typewriter ID is currently running (use unique ID as an array index)
  6. bool TypewriterRunners.IsActive[];
  7. /// Get whether given typewriter ID is blocking (use unique ID as an array index)
  8. bool TypewriterRunners.IsBlocking[];
  9. /// Stop typewriter under given ID
  10. void Cancel(int id);
  11.  

The principal example:
Code: Adventure Game Studio
  1. int tw_id = SomeButton.Typewriter(text, eNoBlock);
  2.  
  3. <... later ...>
  4.  
  5. if (TypewriterRunners.IsActive[tw_id])
  6.   TypewriterRunners.Cancel(tw_id); // interrupt typewriter if it was still running
  7.  


Using TypedText directly

If above helper functions do not do what you like, you may create and use objects of TypedText struct, or any derived structs, directly.

TypedText struct's purpose is to calculate timing and  basic state of the text. It does not draw anything on screen on its own, but calculates and tells how the text should look like at any given moment, letting you to use that information as you see fit. In other words, it tells what is happening, but does not tell you how it should look (and sound) like.


Setting up TypedText is fairly straighforward, here are its configuration properties:
Code: Adventure Game Studio
  1. /// Base delay (in ticks) between every typing event
  2. import attribute int              TypeDelay;
  3. /// Bounds for random base delay
  4. import attribute int              TypeDelayMin;
  5. import attribute int              TypeDelayMax;
  6. import attribute TypedDelayStyle  TypeDelayStyle;
  7. /// Time (in ticks) the caret stays shown
  8. import attribute int              CaretFlashOnTime;
  9. /// Time (in ticks) the caret stays hidden
  10. import attribute int              CaretFlashOffTime;
  11. /// Time (in ticks) given to read one text character
  12. import attribute int              TextReadTime;
  13.  
  14.  
  15. /// Whitespace/caret-return delay style defines relation of special case
  16. /// delays to the base type delay.
  17. /// Idea is conforming to the Phemar's Typewriter module.
  18. enum TypedDelayStyle
  19. {
  20.   /// wait for the same amount of time as after regular letters
  21.   eTypedDelay_Uniform = 0,
  22.   /// wait twice as long after whitespaces
  23.   eTypedDelay_LongSpace,
  24.   /// wait twice as less after whitespaces
  25.   eTypedDelay_ShortSpace,
  26.   /// randomly choose a style every time
  27.   eTypedDelay_Mixed
  28. };
  29.  


And its control methods are:
Code: Adventure Game Studio
  1.  
  2. /// Gets/sets paused state
  3. import attribute bool             Paused;
  4.  
  5. /// Clears all text and resets all timers
  6. import void                       Clear();
  7. /// Sets new string, resets all timers and commences typing
  8. import void                       Start(String text);
  9. /// Skips all the remaining typing
  10. import void                       Skip();
  11.  
  12. /// Update typed text state, advancing it by single tick
  13. import void                       Tick();
  14.  


Since you are using TypedText yourself, you need to be continiously checking its state in repeating function:
Code: Adventure Game Studio
  1. /// Full string that has to be typed
  2. readonly import attribute String  FullString;
  3. /// Part of string that is supposed to be shown at current time
  4. readonly import attribute String  CurrentString;
  5. /// Part of string that was 'typed' during latest update
  6. readonly import attribute String  LastTyped;
  7.  
  8. /// Tells whether TypedText has active content to process or display
  9. readonly import attribute bool    IsActive;
  10. /// Tells whether TypedText is in process of typing text
  11. /// (return FALSE if either no text is set, or text is already fully typed)
  12. readonly import attribute bool    IsTextBeingTyped;
  13. /// Tells whether TypedText is waiting for the text to be read by player
  14. /// (return FALSE when reading timer has ran out, regardless of other states)
  15. readonly import attribute bool    IsWaitingForReader;
  16. /// Tells whether TypedText is currently idling, either not having a content,
  17. /// or after finishing all the required actions (typing & waiting for reader)
  18. readonly import attribute bool    IsIdle;
  19. /// Tells whether caret should be currently displayed
  20. readonly import attribute bool    IsCaretShown;
  21.  
  22. /// Gets if the new character was just typed
  23. readonly import attribute bool    EvtCharTyped;
  24. /// Gets if the text has just ended being typed
  25. readonly import attribute bool    EvtFinishedTyping;
  26.  


One of the simpliest examples for using TypedText is this:
Code: Adventure Game Studio
  1. // in GlobalScript.asc
  2. TypedText my_tt;
  3.  
  4. function game_start()
  5. {
  6.     // Config typed text to your liking
  7.     my_tt.TypeDelay = 4;
  8.     my_tt.CaretFlashOnTime = 4;
  9.     my_tt.CaretFlashOffTime = 4;
  10. }
  11.  
  12. // Calling TypeSay will start typed text
  13. function TypeSay(string s)
  14. {
  15.     my_tt.Start(s);
  16. }
  17.  
  18. function repeatedly_execute()
  19. {
  20.     if (my_tt.IsIdle)
  21.     {
  22.         my_tt.Clear(); // clear the text, stop timers ticking, etc
  23.     }
  24.     else if (my_tt.IsActive)
  25.     {
  26.         my_tt.Tick(); // update TT
  27.         String text_to_show = my_tt.CurrentString;
  28.         if (my_tt.IsCaretShown)
  29.             text_to_show = text_to_show.Append("_"); // append caret symbol to the end of the text
  30.         player.Saybackground(text_to_show); // print TT's current text as a player's background speech
  31.     }
  32. }
  33.  


Using TypewriterRender and its subtypes

There is a number of extended types provided by the module, which add bit more functionality. First is struct TypewriterRender, which extends TypedText, and other structs extend TypewriterRender further.

As was mentioned above, TypedText does not draw anything on its own, only calculates the text's state. TypewriterRender does not do much too, but it adds few more properties and serves rather like a base class for actual visualizing:
Code: Adventure Game Studio
  1. /// Caret display style
  2. import attribute TypedCaretStyle CaretStyle;
  3. /// A string (or single character) that represents typewriter caret
  4. import attribute String          CaretString;
  5.  
  6. /// The only sound to play when a character is typed
  7. import attribute AudioClip *     TypeSound;
  8. /// Array of sounds to choose at random when a character is typed
  9. readonly import attribute AudioClip *TypeSounds[];
  10. /// Number of typing sounds registered
  11. readonly import attribute int    TypeSoundCount;
  12. /// Sound to play when the line break is met
  13. import attribute AudioClip *     CaretSound;
  14. /// Sound to play when the typewriter finished typing text
  15. import attribute AudioClip *     EndSound;
  16.  
  17. /// Sets the array of sounds to play at random when character is typed
  18. import void                      SetRandomTypeSounds(AudioClip *sounds[], int count);
  19.  
  20.  
  21. /// Style of the caret displayed during typing
  22. enum TypedCaretStyle
  23. {
  24.   /// No caret display
  25.   eTypedCaret_None = 0,
  26.   /// Flash last character
  27.   eTypedCaret_LastChar,
  28.   /// Draw separate caret at the next assumed character location
  29.   eTypedCaret_Explicit
  30. };
  31.  


The actual workers are inheriting types: TypewriterButton, TypewriterLabel, TypewriterOverlay. They have respective properties to set up an object they will print text on (or from which perspective), as well as their own overwritten Clear, Start and Tick methods.

Using them you will avoid necessity to draw text yourself:
Code: Adventure Game Studio
  1. // in GlobalScript.asc
  2. TypewriterLabel my_tt_label;
  3.  
  4. function game_start()
  5. {
  6.     my_tt_label.TypeOnLabel = lblTypewriter; // put your actual label's name here
  7.     my_tt_label.TypeDelay = 4;
  8.     my_tt_label.CaretFlashOnTime = 4;
  9.     my_tt_label.CaretFlashOffTime = 4;
  10.     my_tt_label.CaretStyle = eTypedCaret_LastChar; // make last char flash
  11.     my_tt_label.TypeSound = aTypewriterTyping; // set sound to play
  12. }
  13.  
  14. // Calling TypeOnLabel will start typed text
  15. function TypeOnLabel(string s)
  16. {
  17.     my_tt_label.Start(s);
  18. }
  19.  
  20. function repeatedly_execute()
  21. {
  22.     if (my_tt_label.IsIdle)
  23.         my_tt_label.Clear(); // remove text when done typing & waiting for the reader
  24.     else if (my_tt_label.IsActive)
  25.         my_tt_label.Tick(); // update text
  26.     // notice that you do not need to point where to print the text anymore,
  27.     // TypewriterLabel already knows that and does printing for you
  28. }
  29.  


Using TypedTextDrawing

TypedTextDrawing is an advanced struct, extending TypewriterRender, that lets you draw typed text on DrawingSurface. This means you may have typewriter text on literally anything that can give drawing surfaces or have assigned image: room and GUI backgrounds, objects, character frames even (crazy).
Besides, TypedTextDrawing is the only one of the provided types that can draw caret as a sprite.

TypedTextDrawing is located in its own separate module (of same name) and requires TypedText module to work (but not TypedTextHelper).

Setting TypedTextDrawing up is very similar to setting other TypedText subtypes, but you also need to set up its position on DrawingSurface, text color and font, and optionally background color.

What is more important to remember, you must explicitly call Draw function, because you need to pass DrawingSurface pointer to its drawing. It cannot store DrawingSurface once for use later, because that goes against rules of using drawing surfaces (they have to be released right after every use).

Here is some example, that draws typed text on a room's backround
Code: Adventure Game Studio
  1. // in GlobalScript.asc
  2. TypedTextDrawing tt_draw;
  3. DynamicSprite *roomBkg; // will keep saved room background
  4.  
  5. function game_start()
  6. {
  7.     tt_draw.TypeDelay = 4;
  8.     tt_draw.CaretFlashOnTime = 4;
  9.     tt_draw.CaretFlashOffTime = 4;
  10.     tt_draw.CaretStyle = eTypedCaret_Explicit; // draw caret
  11.     tt_draw.CaretSprite = 1010; // put your sprite number here
  12.     tt_draw.TypeSound = aTypewriterTyping; // set sound to play
  13.    
  14.     tt_draw.X = 40;
  15.     tt_draw.Y = 40;
  16.     tt_draw.Width = Room.Width - 80;
  17.     tt_draw.Height = Room.Height - 80;
  18.     tt_draw.Font = eFontText;
  19.     tt_draw.TextAlign = eAlignCentre;
  20. }
  21.  
  22. function RestoreRoomBkg()
  23. {
  24.     // Restore original room background
  25.     DrawingSurface *ds = Room.GetDrawingSurfaceForBackground();
  26.     ds.DrawImage(0, 0, roomBkg.Graphic);
  27.     ds.Release();
  28. }
  29.  
  30. // Calling TypeOnDS will start typed text
  31. function TypeOnDS(string s)
  32. {
  33.     if (roomBkg == null)
  34.     {
  35.         roomBkg = DynamicSprite.CreateFromBackground();
  36.     }
  37.     else
  38.     {
  39.         RestoreRoomBkg();
  40.     }
  41.     tt_draw.Start(s);
  42. }
  43.  
  44. function repeatedly_execute()
  45. {
  46.     if (tt_draw.IsIdle)
  47.     {
  48.         tt_draw.Clear();
  49.         RestoreRoomBkg();
  50.     }
  51.     else if (tt_draw.IsActive)
  52.     {
  53.         tt_draw.Tick(); // update TT
  54.         DrawingSurface *ds = Room.GetDrawingSurfaceForBackground();
  55.         tt_draw.Draw(ds);
  56.         ds.Release();
  57.     }
  58. }
  59.  




Other script modules by me:
DragDrop module
KeyListener
« Last Edit: 10 Mar 2017, 18:22 by Crimson Wizard »

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: MODULE: TypedText 0.6.0 (ready for testing)
« Reply #1 on: 12 Feb 2017, 22:59 »
Uhm... you give me weird ideas with the module. :-D
Thanks a bunch for the hard work! Sure will try it, if I need the functionality of a typewriter. (nod)
There are those who believe that life here began out there...

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: MODULE: TypedText 0.6.5 (ready for testing)
« Reply #2 on: 17 Feb 2017, 22:04 »
Next beta version: 0.6.5
Download: https://bitbucket.org/ivan-mogilko/ags-script-modules/downloads/TypedText_0.6.5.zip
A little demo-game (compiled files only for now) just to quickly demonstrate how this thing works: https://bitbucket.org/ivan-mogilko/ags-script-modules/downloads/TypedTextDemo%200.6.5.zip


What has changed since 0.6.0:

1. Most importantly, I realized that there is no way to know when typing animation finished if you run non-blocking helper. So I added whole new static struct to the TypedTextHelper module:
Code: Adventure Game Studio
  1. #define NO_TYPEWRITER 0
  2.  
  3. struct TypewriterRunners
  4. {
  5.   /// Get number of currently running typewriters
  6.   readonly import static attribute int  ActiveCount;
  7.   /// Get number of maximal supported typewriters that can run simultaneously
  8.   readonly import static attribute int  MaxCount;
  9.   /// Get whether given typewriter ID is currently running
  10.   readonly import static attribute bool IsActive[];
  11.   /// Get whether given typewriter ID is blocking
  12.   readonly import static attribute bool IsBlocking[];
  13.  
  14.   /// Stop typewriter under given ID
  15.   import static void Cancel(int id);
  16. };
  17.  

To put it simply, each Typewriter helper function (like Button.Typewriter, Overlay.Typewrite, etc) now returns unique typewriter ID, that then can be used to retrieve information, or interrupt typing, like this:
Code: Adventure Game Studio
  1. int tw_id = SomeButton.Typewriter(text, eNoBlock);
  2.  
  3. <...later...>
  4.  
  5. if (TypewriterRunners.IsActive[tw_id])
  6.   TypewriterRunners.Cancel(tw_id);
  7.  

2. Made modules compatible with AGS 3.2.1, in case people still using that version. (I know some still use 2.72, but I do not feel like going there)
Before AGS 3.4.0 you need to use "TypewriteOnOverlay" instead of "Overlay.Typewriter".

3. Renamed helper extenders from TypewriterPrint to just Typewriter, so they are now Button.Typewriter, and so on.

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: MODULE: TypedText 0.6.5 (ready for testing)
« Reply #3 on: 25 Feb 2017, 23:42 »
Next beta version: 0.7.0
Download: https://bitbucket.org/ivan-mogilko/ags-script-modules/downloads/TypedText_0.7.0.zip
Finally a Demo Game with proper source: https://bitbucket.org/ivan-mogilko/ags-script-demos/downloads/TypedTextDemo_0.7.0.zip


What has changed since 0.6.5:

1. First of all, I completely removed TypewriterSpeech class and related helper function. It did not do anything very useful anyway at this point.
When it comes to speech there is a lot of things that need to be taken care about (animation, voice-over, etc), and I feel that currently TypedText module is at such stage where the priority is to make its basic intended behavior to work well.
It is still very much possible to create speech using TypewriterOverlay class; in fact the example of such speech (combined with Phylactere's module bubble) is featured in the Demo Game.

2. I fixed (hopefully) an issue that caused some words to begin appear at one line and then suddenly jump to another. This was related to difference in how TypedText and built-in AGS classes I print text to manage their contents. Fixing this problem allowed me to correctly detect when the new line starts, which helped in implementing CaretSound (see below).

3. More sound options are available now for TypewriterRender and all its descendants (TypewriterButton, *Label and *Overlay).
 - Instead of having only one sound for typing, you can now supply your typewriter with an array of audio clips to choose at random when every next letter gets typed. Since I am supporting pre-3.4.0 versions of AGS, which did not allow dynamic arrays in structs, the TYPEDTEXTRENDER_MAXSOUNDS macro is defining how many typing sounds max each typewriter may have. You may increase or decrease this value if you wish. An array of clips is added using SetRandomTypeSounds function.
 - CaretSound property lets you define a sound to play when typing starts at the next line (or rather when previous line ended?).
 - EndSound property lets you define a sound to play when text finished typing.

4. Fixes in TypedTextDrawing:
 - Some properties were missing their implementation.
 - There were few mistakes related to wrapped lines alignment.


Make sure to check the DemoGame out, and click on everything you see there (not much, but fun, I hope) :).
Personally, I think the module works pretty solid now. There are couple of more things I'd like to add in the future, but that may not be too soon.
« Last Edit: 25 Feb 2017, 23:48 by Crimson Wizard »

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #4 on: 09 Mar 2017, 14:05 »
Okay, this seems way more complex to use than I initially thought it would...
I'm trying to do something very simple, which is basically type the text non-blocking while some other blocking speech is running... but I'm basically drawing a blank... :( In other words, nothing is being typed, while the rest of my code runs perfectly, once it ends and shows the menu GUI, I get a square white box that will type my text, letter by letter, every time I click my mouse... twice. 8-0
Not exactly what I had in mind.

Thought it would be easier to work with, like add the settings to the start of the script, and then used TypedText(text) to show the lines... :-[
There are those who believe that life here began out there...

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #5 on: 09 Mar 2017, 16:05 »
I'm trying to do something very simple, which is basically type the text non-blocking while some other blocking speech is running...
Hmm... doing something non-blocking while blocking speech is running, is probably not possible, because these typewriters are updated in repeatedly_execute.

Try opening TypedTextHelper.asc and changing "repeatedly_execute" function to "repeatedly_execute_always", and see if that works for you.

I guess I need to add an option for either running these typewriters in "always" or normal repeating function.
« Last Edit: 09 Mar 2017, 16:18 by Crimson Wizard »

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #6 on: 09 Mar 2017, 17:41 »
Managed to get it to display on the room now, but the text doesn't get typed unless I press the mouse button or the enter key. Plus, there's still a white box displaying, instead of the background.

Maybe you can figure out what I'm doing wrong here? I removed the code for the BG video and speech for now.
EDIT: I put the code in Room 1, since it's the only room that I'll be using for all the text. Not sure if that makes a difference or not.
Code: Adventure Game Studio
  1. // text script for room
  2. TypedTextDrawing tt_draw;
  3. DynamicSprite *roomBkg; // will keep saved room background
  4.  
  5. function game_start()
  6. {
  7.     tt_draw.TypeDelay = 4;
  8.     tt_draw.CaretFlashOnTime = 4;
  9.     tt_draw.CaretFlashOffTime = 4;
  10.     tt_draw.CaretStyle = eTypedCaret_Explicit; // draw caret
  11.     tt_draw.CaretSprite = 1010; // put your sprite number here
  12.     //tt_draw.TypeSound = aTypewriterTyping; // set sound to play
  13.    
  14.     tt_draw.X = 40;
  15.     tt_draw.Y = 40;
  16.     tt_draw.Width = Room.Width - 80;
  17.     tt_draw.Height = Room.Height - 80;
  18.     tt_draw.Font = eFontGalactican;
  19.     tt_draw.TextAlign = eAlignCentre;
  20. }
  21.  
  22. function RestoreRoomBkg()
  23. {
  24.     // Restore original room background
  25.     DrawingSurface *ds = Room.GetDrawingSurfaceForBackground();
  26.     ds.DrawImage(0, 0, roomBkg.Graphic);
  27.     ds.Release();
  28. }
  29.  
  30. // Calling TypeOnDS will start typed text
  31. function TypeOnDS(string st)
  32. {
  33.     if (roomBkg == null)
  34.     {
  35.         roomBkg = DynamicSprite.CreateFromBackground();
  36.     }
  37.     else
  38.     {
  39.         RestoreRoomBkg();
  40.     }
  41.     tt_draw.Start(st);
  42. }
  43.  
  44. D3D_Video* video;
  45. TypedText my_text;
  46.      
  47. function repeatedly_execute_always()
  48. {  
  49.     if (tt_draw.IsActive)
  50.     {
  51.         tt_draw.Tick(); // update TT
  52.         if (tt_draw.IsIdle)
  53.         {
  54.             tt_draw.Clear();
  55.             RestoreRoomBkg();
  56.         }
  57.         else
  58.         {
  59.             DrawingSurface *ds = Room.GetDrawingSurfaceForBackground();
  60.             tt_draw.Draw(ds);
  61.             ds.Release();
  62.         }
  63.     }
  64.         if (my_text.IsActive)
  65.         {
  66.                 my_text.Tick(); // update TypedText
  67.                 if (my_text.IsIdle)
  68.                 {
  69.                         my_text.Clear(); // clear the text
  70.                 }
  71.                 else
  72.                 {
  73.                         String text_to_show=my_text.CurrentString;
  74.                         if (my_text.IsCaretShown)
  75.                         {
  76.                                 text_to_show=text_to_show.Append("_"); // append carret symbol to the end of the text
  77.                         }
  78.                         DisplayAt(140, 113, 500, text_to_show); // print typedText's current text
  79.                 }
  80.         }
  81. }
  82.  
  83. function room_Load()
  84. {
  85.         // Config typed text
  86.         my_text.TypeDelay=4;
  87.         my_text.CaretFlashOnTime=4;
  88.         my_text.CaretFlashOffTime=4;
  89.         // End config of type text
  90.        
  91.         /*      SetViewport(0, 0);
  92.                 cShuttle.Transparency=100;
  93.                 cShuttle.Baseline=288;
  94.                 cShuttle.ChangeRoom(1, 199, 139);
  95.         */
  96. }
  97.  
  98. function TypeSay(String st)
  99. {
  100.         my_text.Start(st);
  101. }
  102.  
  103.  
  104.  
  105. void Cutscene_Intro()
  106. {      
  107.  
  108.          TypeSay("An AGS game by Sandra T. Almeida");
  109. }
  110.  
  111.  
  112. function room_AfterFadeIn()
  113. {
  114.         if (Game.DoOnceOnly("Play Intro")) Cutscene_Intro();
  115. }
  116.  

PS - I changed the sting from s to st, as the s was giving me a parse error. ???
« Last Edit: 09 Mar 2017, 17:54 by Cassiebsg »
There are those who believe that life here began out there...

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #7 on: 09 Mar 2017, 18:02 »
You are calling DisplayAt from repeatedly_execute_always, and it blocks your game completely until you press key or click mouse.

What are your intentions for typed text? TypedText class is not really meant for simple cases, it is for more complex cases when you need a custom behavior.

« Last Edit: 09 Mar 2017, 18:04 by Crimson Wizard »

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #8 on: 09 Mar 2017, 18:05 »
oh, right, forgot that display blocks. :-[ I put displayAt so I got possition the text, but now that I'm looking at the code, I think I spot where I should change that.

Let me so try with sayBG, brb.

EDIT: Okay, that worked. :) Well, almost, since for some reason didn't used my font nor it printed the last letter.
Also, why is the text scrolling to the left? I wanted it to start at one position and write to the right.

EDIT: Seems to be completely ignoring the settings at game start (I realize it game start wasn't doing anything in the room, and moved it to room_load) but seems to still be ignoring it.
« Last Edit: 09 Mar 2017, 18:23 by Cassiebsg »
There are those who believe that life here began out there...

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #9 on: 09 Mar 2017, 18:15 »
EDIT: Okay, that worked. :) Well, almost, since for some reason didn't used my font nor it printed the last letter.
Also, why is the text scrolling to the left? I wanted it to start at one position and write to the right.

You have "tt_draw.TextAlign = eAlignCentre;" probably you need eAlignLeft.
Not sure about the font...


EDIT:
Oh and about the last letter, I think there is a mistake in my example, the update code should be something like:

Code: Adventure Game Studio
  1.     if (tt_draw.IsIdle)
  2.     {
  3.         tt_draw.Clear();
  4.         RestoreRoomBkg();
  5.     }
  6.     else if (tt_draw.IsActive)
  7.     {
  8.         tt_draw.Tick(); // update TT
  9.         DrawingSurface *ds = Room.GetDrawingSurfaceForBackground();
  10.         tt_draw.Draw(ds);
  11.         ds.Release();
  12.     }
  13.  

The "IsIdle" part is only necessary if you want it to remove text automatically as soon as finished waiting for reader. You can change reading speed with tt_draw.TextReadTime. Or remove text by your own method.
« Last Edit: 09 Mar 2017, 18:22 by Crimson Wizard »

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #10 on: 09 Mar 2017, 18:25 »
Seems to be completely ignoring the settings at game start (I realized that game start wasn't doing anything in the room, and moved it to room_load) but seems to still be ignoring it.

Okay, I'll change that code, but I solved that problem by just adding [ at the end of the text. ;)
There are those who believe that life here began out there...

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #11 on: 09 Mar 2017, 18:33 »
Seems to be completely ignoring the settings at game start (I realized that game start wasn't doing anything in the room, and moved it to room_load) but seems to still be ignoring it.
Well... there might be something very simple, like room_load not entered on events panel, or something like that.

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #12 on: 09 Mar 2017, 20:25 »
No, it is linked, that's why I moved the code there.
I have other code in there that is being initialized in the room.
There are those who believe that life here began out there...

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #13 on: 09 Mar 2017, 20:33 »
Can you show the final code, please?

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #14 on: 09 Mar 2017, 20:56 »
Code: Adventure Game Studio
  1. // text script for room
  2. TypedTextDrawing tt_draw;
  3. DynamicSprite *roomBkg; // will keep saved room background
  4.  
  5.  
  6. function RestoreRoomBkg()
  7. {
  8.     // Restore original room background
  9.     DrawingSurface *ds = Room.GetDrawingSurfaceForBackground();
  10.     ds.DrawImage(0, 0, roomBkg.Graphic);
  11.     ds.Release();
  12. }
  13.  
  14. // Calling TypeOnDS will start typed text
  15. function TypeOnDS(string st)
  16. {
  17.     if (roomBkg == null)
  18.     {
  19.         roomBkg = DynamicSprite.CreateFromBackground();
  20.     }
  21.     else
  22.     {
  23.         RestoreRoomBkg();
  24.     }
  25.     tt_draw.Start(st);
  26. }
  27.  
  28. function repeatedly_execute()
  29. {
  30. }
  31.  
  32. D3D_Video* video;
  33. TypedText my_text;
  34.      
  35. function repeatedly_execute_always()
  36. {  
  37.     if (tt_draw.IsActive)
  38.     {
  39.         tt_draw.Tick(); // update TT
  40.         if (tt_draw.IsIdle)
  41.         {
  42.             tt_draw.Clear();
  43.             RestoreRoomBkg();
  44.         }
  45.         else
  46.         {
  47.             DrawingSurface *ds = Room.GetDrawingSurfaceForBackground();
  48.             tt_draw.Draw(ds);
  49.             ds.Release();
  50.         }
  51.     }
  52.     if (my_text.IsActive)
  53.     {
  54.         my_text.Tick(); // update TypedText
  55.         if (my_text.IsIdle)
  56.         {
  57.             my_text.Clear(); // clear the text
  58.         }
  59.         else
  60.         {
  61.             String text_to_show=my_text.CurrentString;
  62.             if (my_text.IsCaretShown)
  63.             {
  64.                 text_to_show=text_to_show.Append(""); // append carret symbol to the end of the text
  65.             }
  66.             cNarrat.SayBackground(text_to_show); // print typedText's current text
  67.         }
  68.     }
  69. }
  70.  
  71. function room_Load()
  72. {
  73.     tt_draw.TypeDelay = 4;
  74.     tt_draw.CaretFlashOnTime = 4;
  75.     tt_draw.CaretFlashOffTime = 4;
  76.     tt_draw.CaretStyle = eTypedCaret_Explicit; // draw caret
  77.     tt_draw.CaretSprite = 1010; // put your sprite number here
  78.     //tt_draw.TypeSound = aTypewriterTyping; // set sound to play
  79.        
  80.     tt_draw.X = 500;
  81.     tt_draw.Y = Room.Height / 2;
  82.     tt_draw.Width = 500 ;
  83.     tt_draw.Height = Room.Height / 2 ;
  84.     tt_draw.Font = eFontGalactican;
  85.     tt_draw.TextAlign = eAlignLeft;
  86.     // Config typed text
  87.     my_text.TypeDelay=4;
  88.     my_text.CaretFlashOnTime=4;
  89.     my_text.CaretFlashOffTime=4;
  90.     // End config of type text
  91.        
  92.     //  SetViewport(0, 0);
  93.     cShuttle.Transparency=100;
  94.     cShuttle.Baseline=288;
  95.     cShuttle.ChangeRoom(1, 199, 139);
  96. }
  97.  
  98. function TypeSay(String st)
  99. {
  100.     my_text.Start(st);
  101. }
  102.  
  103.  
  104.  
  105. void Cutscene_Intro()
  106. {      
  107.     //bool Esc_CutScene=false;
  108.     //D3D Plugin - playing background video with Theora-------------
  109.     //Required for autoplay
  110.     D3D.SetLoopsPerSecond( GetGameSpeed() );
  111.    
  112.     // Open video file
  113.     video = D3D.OpenVideo( "Intro_Opening_v1.ogv" );
  114.    
  115.     if ( video )
  116.     {
  117.         // Use room coordinates
  118.         video.relativeTo = eD3D_RelativeToRoom;
  119.        
  120.         // Anchor point to top left corner
  121.         video.SetAnchor( -0.5, -0.5 );
  122.        
  123.         // Play!
  124.         video.Autoplay();
  125.     }
  126.     else
  127.     {
  128.         player.SayBackground( "Couldn't open video." );
  129.        
  130.     }
  131.     //END OF D3D plugin video---------------------------------------
  132.     play_Music(Intro);
  133.     StartCutscene(eSkipESCOnly);
  134.     //  oGal.Visible=true;
  135.     // oGal.SetView(60);
  136.     TypeSay("An AGS game by Sandra T. Almeida[");
  137.          
  138.     cNarrat.SayAt(6, 261, 500, "&1 There are those who believe");  
  139.     cNarrat.SayAt(6, 261, 500, "&2 that life here began out there,");
  140.     TypeSay("a fan game based on Battlestar Galactica[");
  141.     cNarrat.SayAt(6, 261, 500, "&3 far across the universe,");
  142.     cNarrat.SayAt(6, 261, 500, "&4 with tribes of humans");
  143.     cNarrat.SayAt(6, 261, 500, "&5 who may have been the forefathers of the Egyptians");
  144.     cNarrat.SayAt(6, 261, 500, "&6 or the Toltecs or the Mayans.");
  145.     //  oGal.Animate(0, 1, eOnce, eNoBlock, eForwards);
  146.     cNarrat.SayAt(6, 261, 500, "&7 Some believe that there may yet be brothers of man");
  147.     cNarrat.SayAt(6, 261, 500, "&8 who even now fight to survive");
  148.     cNarrat.SayAt(6, 261, 500, "&9 somewhere beyond the heavens.");
  149.     play_Music(Main);
  150.     while (video.NextFrame())
  151.     {
  152.         if (IsKeyPressed(eKeyEscape)) break;
  153.         else Wait(1);
  154.     }
  155.     EndCutscene();
  156.     video=null;
  157.     CloseM.Visible=false;
  158.     gMenu.Visible=true;
  159. }
  160.  
  161. function room_AfterFadeIn()
  162. {
  163.     if (Game.DoOnceOnly("Play Intro")) Cutscene_Intro();
  164. }
  165.  
  166. void Cutscene_Start()
  167. {      
  168.     //D3D Plugin - playing background video with Theora-------------
  169.     // Required for autoplay
  170.     D3D.SetLoopsPerSecond( GetGameSpeed() );
  171.    
  172.     // Open video file
  173.     video = D3D.OpenVideo( "test.ogg" );
  174.    
  175.     if ( video )
  176.     {
  177.         // Use room coordinates
  178.         video.relativeTo = eD3D_RelativeToRoom;
  179.        
  180.         // Anchor point to top left corner
  181.         video.SetAnchor( -0.5, -0.5 );
  182.        
  183.         // Play!
  184.         video.Autoplay();
  185.     }
  186.     else
  187.     {
  188.         Display( "Couldn't open video." );
  189.         //return;
  190.     }
  191.         //END OF D3D plugin video---------------------------------------
  192.        
  193.     SetGameSpeed(25); // you don't need to use the same fps as the video like this, but it's easiest this way*/
  194.        
  195.        
  196.     cAthena.ChangeRoom(1, 1024, 0);
  197.     cNarrat.ChangeRoom(1, -5, 0);
  198.     cNarrat.SpeechView=97;
  199.     cShuttle.SetAsPlayer();
  200.     //cAthena.SpeechView=18;
  201.     //oGal.StopAnimating();
  202.     Start_Cutscene=false;
  203.     StartCutscene(eSkipESCOnly);
  204.     play_Music(Intro);
  205.     oGal.Graphic=1213;
  206.     oGal.Visible=true;
  207.     oBay.Visible=true;
  208.     cShuttle.Transparency=0;
  209.     cShuttle.Walk(948, 201, eNoBlock, eAnywhere);
  210.     //oShuttle.Visible=true;
  211.     //oShuttle.Move(492, 201, -2, eNoBlock, eAnywhere);
  212.     // oShuttle.SetView(VSHUTTLE);
  213.     //oShuttle.Animate(0, 2000, eOnce, eNoBlock, eForwards);
  214.     //cNarrat.SayAt(6, 261, 500, "&11 What's Starbuck's status?");
  215.     cNarrat.Say("&11 What's Starbuck's status?");
  216.     Wait(10);
  217.     ReleaseViewport();
  218.     //cAthena.SayAt(6, 261, 500, "&45 He's due on the Rising Star at any moment.");
  219.     cAthena.Say("&45 He's due on the Rising Star at any moment.");
  220.     Wait(5);
  221.     cNarrat.Say("&12 I hope we don't have to move him to red before he eats.");
  222.     //oShuttle.Move(939, 142, -2, eNoBlock, eAnywhere);
  223.     cShuttle.Walk(948, 137, eNoBlock, eAnywhere);
  224.     cAthena.Say("&46 Starbuck did ask me to dinner tonight but...");
  225.     cAthena.Say("&47 Well, I do have this duty.");
  226.     cAthena.Say("&48 I guess he'll have to eat alone.");
  227.     cShuttle.Walk(948, 135, eNoBlock, eAnywhere);
  228.     cNarrat.Say("&13 Well, er... perhaps this once we can make an exception, hm?");
  229.     Wait(5);
  230.     cNarrat.Say("&14 You go ahead and join him.");
  231.     cNarrat.Say("&15 I'll handle this with Colonel Tigh.");
  232.     //  oShuttle.Visible=false;
  233.     Wait(60);
  234.     oGal.Visible=false;
  235.     oBay.Visible=false;
  236.     EndCutscene();
  237.     play_Music(Stb);
  238.     cStarb.SetAsPlayer();
  239.     video=null;
  240.     SetGameSpeed(SldSpeed.Value);
  241.     player.ChangeRoom(2, 309, 582);
  242. }
  243.  
  244.  
  245. function room_RepExec()
  246. {
  247.     if (Start_Cutscene) Cutscene_Start();
  248. }
  249.  

EDIT: Indent was out of wack...

EDIT2: Maybe it's the characterSay? And the speech font is being enforced over the settings?
« Last Edit: 09 Mar 2017, 21:05 by Cassiebsg »
There are those who believe that life here began out there...

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #15 on: 09 Mar 2017, 21:29 »
But, you are not even calling TypeOnDS anywhere in your script, which means that SayBackground is the only thing that shows up.

Something I have to clarify, do you realize that you have TWO completely separate typedtexts in your script? And you are starting only one of them, which is called my_text, but not the one called tt_draw?
« Last Edit: 09 Mar 2017, 21:34 by Crimson Wizard »

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #16 on: 09 Mar 2017, 22:01 »
No, I told you I had no idea what I was doing. Not that as easy to use this module. :-[

So, how do I call the tt_draw, then? And how do I call TypeOnDS??

Or: What code should I be using?
There are those who believe that life here began out there...

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #17 on: 09 Mar 2017, 22:26 »
No, I told you I had no idea what I was doing. Not that as easy to use this module. :-[

So, how do I call the tt_draw, then? And how do I call TypeOnDS??

Or: What code should I be using?


It looks like you copied two different code examples into one script.
If you wanted to draw typed text on room background you only need one with TypedTextDrawing.
In your current script simply replace calls to TypeSay with calls to TypeOnDS. This function already exists in your script.


I will see if I am able to rewrite description to make it easier to understand how to use this module.
« Last Edit: 09 Mar 2017, 22:35 by Crimson Wizard »

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #18 on: 09 Mar 2017, 22:59 »
Okay, replacing TypeSay with TypeOnDS rproduces: Erro (line 137): Type mismatch: cannot convert 'const string' to 'string'

I looked at the code, and if I replace function TypeOnDS(string st) with function TypeOnDS(String st)
then it runs, but I can't see the text being printed on screen. :-\
There are those who believe that life here began out there...

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #19 on: 09 Mar 2017, 23:13 »
Sorry, but I think this module is not ready. I am cancelling it until I have time to work more on it.

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: cancelled: TypedText 0.7.0
« Reply #20 on: 10 Mar 2017, 05:19 »
Oh. :~(
And I was enjoying seeing the text printed there... (roll)

Hope you can fix it soon, and sorry for being a pain.
There are those who believe that life here began out there...

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: cancelled: TypedText 0.7.0
« Reply #21 on: 10 Mar 2017, 08:10 »
Sorry, I think it did not work for you because you do not set tt_draw.TextColor, it is black by default, and if your room background is black, that would explain why you do not see anything.

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: Temporary cancelled: TypedText 0.7.0
« Reply #22 on: 10 Mar 2017, 08:44 »
Okay, I figured out why it's not working... seems like it can't render over my BG video?
I "removed" the code for the D3D pluging BG video, and now it's working. (nod) Looks really nice too!
Also thanks for the heads up with the TextColor code. :)
Do you think it's possible to render it over the video, like the speech is? If it's not it's okay, I'll just have to work something else out. Or add the text to the rendered video.

EDIT: Also, think you canceled the module too quick, seems to be working just fine, and that it's just my ineptitude to understand the complex code plus my other messy code that was on the way. ;)
Only real needed change, seem to be in your example code, where you typed string s instead of String s. ;)
« Last Edit: 10 Mar 2017, 08:57 by Cassiebsg »
There are those who believe that life here began out there...

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Temporary cancelled: TypedText 0.7.0
« Reply #23 on: 10 Mar 2017, 09:11 »
Okay, I figured out why it's not working... seems like it can't render over my BG video?

I don't know; that depends on how this video is rendered, which I never tried out myself. Maybe video gets drawn above text?
If video plugin can somehow return drawing surface of its own, you may draw upon it instead.

You may try using TypedTextOverlay or TypedTextLabel instead of TypedTextDrawing, if you have a possibility to use overlay/GUI in your room.


I will repost the module after I fix some errors and write easier explanation on how to use it.
« Last Edit: 10 Mar 2017, 09:21 by Crimson Wizard »

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: Temporary cancelled: TypedText 0.7.0
« Reply #24 on: 10 Mar 2017, 10:04 »
I'll give it a try, can it be a transparent GUI/overlay?

I'm using the D3D plugin by AJA for the video rendering found here: http://www.adventuregamestudio.co.uk/forums/index.php?topic=45348.0
You can probably easily test it your self, if you like, by copy pasting my code into a new game's room, and just replace the video filename with any other ogv movie you might have laying around.

EDIT: No, text gets drawn over the video. At least the speech text does. Had no problem rendering the TextSay over it.

EDIT2: Okay, tried it with a GUI, I imported the footline code from your demo to test, and edited the lines relating to sounds out.
I got it to sorta work. It seems it can render over the video. (nod) Only it doesn't run while the speech is running. (wrong) So, I only get the first line rendered once I hit the start button on the main menu, and my second video starts. ??? Then the next comes first after the game has started (controling the character in a non-blocking way). So my guess right now is, the GUI lbl won't uptade if it's blocked.

Haven't tried overlay yet, since I have never used overlays before, meaning that it's even a bigger mystery for me. (roll)

EDIT3: Now I'm even more confuse... works even in blocked mode, but still not over my first video. This is weird, since the code is the same for both videos, is it not? ??? (EDIT4: And now I'm at a loss... put my 1st video on the cutscene_start and then I get the text typed... with the cutscene_Intro it doesn't run... what is different? ??? )

EDIT5: Okay, got it working with a GUI! :-D :-D :-D Now I just need to change the lines to display my text and fine tune it! (nod)
Thanks, and sorry for being a noob. ;)
And oh, am not sure what was wrong before, I changed 2 things, I moved the NextFootline(); to room_load() and added a variable to fire up my code in rep_exe... which ever of the two "fixes" was, it's working! :-D

EDIT 6: Am I over doing this? Sorry.
Now I'm trying to complicate a simple thing... I am here trying to keep 2 lines on screen, instead of writing one line, clear, and then write a second line. I realized that I can just use the [ to break a line into 2, and I would do that, if I didn't want to use a smaller font on the 1st line and a bigger on the second. (roll)
I've managed to do it, by writing 2 lines simultaneous (though I would prefer to write one at a time), but the first line is still removed before the second. Is there a simple setting I can change, or this is not possible without some complicated rewrite?
« Last Edit: 10 Mar 2017, 20:59 by Cassiebsg »
There are those who believe that life here began out there...

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #25 on: 11 Mar 2017, 12:40 »
EDIT 6: Am I over doing this? Sorry.
Now I'm trying to complicate a simple thing... I am here trying to keep 2 lines on screen, instead of writing one line, clear, and then write a second line. I realized that I can just use the [ to break a line into 2, and I would do that, if I didn't want to use a smaller font on the 1st line and a bigger on the second. (roll)
I've managed to do it, by writing 2 lines simultaneous (though I would prefer to write one at a time), but the first line is still removed before the second. Is there a simple setting I can change, or this is not possible without some complicated rewrite?


If you want to have 2 different fonts then you will have to use 2 different objects, because right now TypedTextDrawing does not support changing font when typing, and Labels, Buttons and Overlays do not support multiple fonts on their own (and my module cannot make them do). So yes, you will need 2 Labels and TypewriterLabel objects, linked to each other. You actually did that, if I understand right?

If you want first line to stay you need to tell it not to clear text at all, or keep it for a long time. That depends on what function you use to run it.

If you are manually managing TypewriterLabel, then simply do not call "Clear" function for it.

If you are using Label.Typewriter extender function, then I realized that I did not provide option to keep it forever until you say to remove it, but there is a trick you can use: when you set up its properties with TypewriterPreset.SetGeneral, last parameter is "reading time". Simply set that reading time to some very big number (you may actually do same if you are using TypewriterLabel object yourself).
« Last Edit: 11 Mar 2017, 12:42 by Crimson Wizard »

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #26 on: 11 Mar 2017, 12:56 »
Yes, I'm actually using 6 labels in the GUI, because I wanted the text to be displayed in different places on screen, and thought it would be easier to print each line to a new label... (roll)
I'm pretty happy the way it's working now, except for the top label with the smaller font and the bottom label with the bigger font are printed at the same time.
I would love it to print the fist line, not clear the line, then type the second line, and then clear the two lines simultanoues when I move to print line 3 and 4.

I tried to figure where the clear was in the code, but failed to see it. :-[

Here's the code I'm currently using:
Code: Adventure Game Studio
  1. #define footline_TYPEWRITER_PRESET 1
  2.  
  3. String footlines[];
  4. int footline_count;
  5. int footline_index;
  6. int footline_tw;
  7.  
  8. function game_start()
  9. {
  10.   footline_count = 7;
  11.   footlines = new String[footline_count];
  12.   footlines[0] = "A fan game by     [";
  13.   footlines[1] = "Sandra T. Almeida [";
  14.   footlines[2] = "Made with             [";
  15.   footlines[3] = "Adventure Game Studio [";
  16.   footlines[4] = "based on the original TV show: [";
  17.   footlines[5] = "Battlestar Galactica           [";
  18.   footlines[6] = " ";
  19.   footline_index = 0;
  20.   footline_tw = NO_TYPEWRITER;
  21.  
  22.   //lblTypedText1.TextColor = 64960;
  23.   //lblFootline.Font = eFontGalactican;
  24.   lblTypedText1.Text = "";
  25.   lblTypedText1t.Text = "";
  26.   lblTypedText2.Text = "";
  27.   lblTypedText2t.Text = "";
  28.   lblTypedText3.Text = "";
  29.   lblTypedText3t.Text = "";
  30.  
  31.   TypewriterPreset.SetGeneral(footline_TYPEWRITER_PRESET, 2, 4, eTypedDelay_LongSpace, 10);
  32.   //TypewriterPreset.SetCaret(footline_TYPEWRITER_PRESET, 2, 4, eTypedCaret_Explicit, " ");
  33.   //AudioClip *type_clips[] = new AudioClip[3];
  34.   // type_clips[0] = aKeyboard;
  35.   //type_clips[1] = aKeyboard2;
  36.  // type_clips[2] = aKeyboard3;
  37.  // TypewriterPreset.SetSoundArray(footline_TYPEWRITER_PRESET, type_clips, 3, null, aKeyboard_beep);
  38. }
  39.  
  40. void NextFootline()
  41. {
  42.   if (!playingCredits)
  43.   {
  44.     if (footline_tw != NO_TYPEWRITER)
  45.     {
  46.       TypewriterRunners.Cancel(footline_tw);
  47.     }
  48.   }
  49. }
  50.  
  51. function repeatedly_execute_always()
  52. {
  53.   if (!playingCredits)
  54.   {
  55.     if (footline_tw != NO_TYPEWRITER)
  56.     {
  57.       if (!TypewriterRunners.IsActive[footline_tw])
  58.         footline_tw = NO_TYPEWRITER;
  59.     }
  60.     if (footline_tw == NO_TYPEWRITER)
  61.     {
  62.       if (Game.DoOnceOnly("1st intro line"))
  63.       {
  64.         lblTypedText1t.Font = eFontOptimus;
  65.         footline_tw = lblTypedText1t.Typewriter(footlines[footline_index], eNoBlock, footline_TYPEWRITER_PRESET);
  66.         //lblTypedText1="";
  67.         footline_index++;
  68.         footline_tw = lblTypedText1.Typewriter(footlines[footline_index], eNoBlock, footline_TYPEWRITER_PRESET);
  69.       }
  70.       else if (Game.DoOnceOnly("2nd intro line"))
  71.       {
  72.         lblTypedText1t.Text="";
  73.         footline_tw = lblTypedText2t.Typewriter(footlines[footline_index], eNoBlock, footline_TYPEWRITER_PRESET);
  74.         footline_index++;
  75.         footline_tw = lblTypedText2.Typewriter(footlines[footline_index], eNoBlock, footline_TYPEWRITER_PRESET);
  76.       }
  77.         else if (Game.DoOnceOnly("3rd intro line"))
  78.       {
  79.         lblTypedText2t.Text="";
  80.         footline_tw = lblTypedText3t.Typewriter(footlines[footline_index], eNoBlock, footline_TYPEWRITER_PRESET);
  81.         footline_index++;
  82.         footline_tw = lblTypedText3.Typewriter(footlines[footline_index], eNoBlock, footline_TYPEWRITER_PRESET);
  83.       }
  84.       footline_index++;
  85.       if (footline_index == footline_count || footlines[footline_index] == null)
  86.       {
  87.         lblTypedText3.Text="";
  88.         footline_index = 6;
  89.       }
  90.     }
  91.   }
  92. }
  93.  

The label ending in t is the top line with the smaller font.

But don't go out of your way if making it work slightly different is too much of a pain. It's just a little fine tune to make it 1% better (in my eyes, that is). (laugh)

EDIT: Fixed the indent... seems like the forum doesn't like my copy/pastes from the editor (I'm using tab for indent there...)
« Last Edit: 11 Mar 2017, 13:07 by Cassiebsg »
There are those who believe that life here began out there...

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #27 on: 11 Mar 2017, 13:47 »
The first error in this script is that you are remembering all typewriter indexes in same variable, and since some of them run simultaneously or have to stay on screen for some time, it gets overwritten every time and you loose control over previous ones.
Also, you are starting two lines at the same time, that's why... they are typing at same time.

Instead of "int footline_tw" you need "int footline_tw[N]", where N is the number of labels you have, or at least the number of simultaneous typewriters, whichever is more convenient.

As I mentioned earlier, you need to set read time to some big number to prevent automatic removal of a text.

Code: Adventure Game Studio
  1. TypewriterPreset.SetGeneral(footline_TYPEWRITER_PRESET, 2, 4, eTypedDelay_LongSpace, 1000); // notice 1000
  2.  

The code may look something like:
Code: Adventure Game Studio
  1. function repeatedly_execute_always()
  2. {
  3.   if (footline_tw[0] == NO_TYPEWRITER) // first typewriter was not started yet
  4.   {
  5.     if (Game.DoOnceOnly("1st intro line SMALL FONT"))
  6.     {
  7.       // start first line
  8.       footline_tw = lblTypedText1t.Typewriter(footlines[footline_index], eNoBlock, footline_TYPEWRITER_PRESET);
  9.       footline_index++;
  10.     }
  11.   }
  12.   if (footline_tw[0] != NO_TYPEWRITER && !TypewriterRunners.IsActive[footline_tw[0]]) // first typewriter has started and finished typing
  13.   {
  14.     if (Game.DoOnceOnly("1st intro line BIG FONT"))
  15.     {
  16.       // start second line
  17.       footline_tw[1] = lblTypedText1.Typewriter(footlines[footline_index], eNoBlock, footline_TYPEWRITER_PRESET);
  18.       footline_index++;
  19.     }
  20.   }
  21.   if (footline_tw[1] != NO_TYPEWRITER && !TypewriterRunners.IsActive[footline_tw[1]]) // second typewriter has started and finished typing
  22.   {
  23.     if (Game.DoOnceOnly("2nd intro line SMALL FONT"))
  24.     {
  25.       // Remove first two lines
  26.       TypewriterRunners.Cancel(footline_tw[0]);
  27.       TypewriterRunners.Cancel(footline_tw[1]);
  28.       // Start third line
  29.       footline_tw[2] = lblTypedText2t.Typewriter(footlines[footline_index], eNoBlock, footline_TYPEWRITER_PRESET);
  30.       footline_index++;
  31.     }
  32.   }
  33.   if (footline_tw[2] != NO_TYPEWRITER && !TypewriterRunners.IsActive[footline_tw[2]]) // third typewriter has started and finished typing
  34.   {
  35.     if (Game.DoOnceOnly("2nd intro line BIG FONT"))
  36.     {
  37.       // start fourth line
  38.       footline_tw[3] = lblTypedText3.Typewriter(footlines[footline_index], eNoBlock, footline_TYPEWRITER_PRESET);
  39.       footline_index++;
  40.     }
  41.   }
  42.  
  43.   // and so on...
  44. }
  45.  

There should be more optimal way to do this, but my brain is not working well right now.
« Last Edit: 11 Mar 2017, 13:51 by Crimson Wizard »

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #28 on: 11 Mar 2017, 14:06 »
Yes, I knew why they were writing simultaneous, just not how to stop the first line from being removed. ;)
I'll give a try, and thanks bunch for the help and the module! (nod)


EDIT: Been trying this but now the second line (or any other after the 1st) never starts... :( Not sure what I did wrong, probably the arrays?
« Last Edit: 13 Mar 2017, 21:43 by Cassiebsg »
There are those who believe that life here began out there...

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #29 on: 17 Mar 2017, 12:29 »
EDIT: Been trying this but now the second line (or any other after the 1st) never starts... :( Not sure what I did wrong, probably the arrays?

Can you post your current code again?

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #30 on: 17 Mar 2017, 14:49 »
Sure, though it's quiet a mess atm, since I started testing other ways in the hopes to figure this out.

Code: Adventure Game Studio
  1.  
  2. #define introline_TYPEWRITER_PRESET 2
  3.  
  4. String introlines_Small[];
  5. String introlines_Big[];
  6. int introline_Small_count;
  7. int introline_Small_index;
  8. int introline_Big_count;
  9. int introline_Big_index;
  10. int introline_Big_tw[1]; // Number of typewriters
  11. int introline_Small_tw[1]; // Number of typewriters
  12.  
  13. function game_start()
  14. {
  15.   introline_Big_count = 4;
  16.   introlines_Big = new String[introline_Big_count];
  17.   introlines_Big[0] = "Sandra T. Almeida [";
  18.   introlines_Big[1] = "Adventure Game Studio [";
  19.   introlines_Big[2] = "Battlestar Galactica           [";
  20.   introlines_Big[3] = " ";
  21.   introline_Big_index = 0;
  22.        
  23.        
  24.   introline_Small_count = 4;
  25.   introlines_Small = new String[introline_Small_count];
  26.   introlines_Small[0] = "A fan game by     [";
  27.   introlines_Small[1] = "Made with             [";
  28.   introlines_Small[2] = "based on the original TV show: [";
  29.   introlines_Small[3] = " ";
  30.   introline_Small_index = 0;
  31.        
  32.   introline_Big_tw[0] = NO_TYPEWRITER;
  33.   introline_Small_tw[0] = NO_TYPEWRITER;
  34.  
  35.   //lblTypedText1.TextColor = 64960;
  36.   //lblintroline.Font = eFontGalactican;
  37.   lblTypedText1.Text = "";
  38.   lblTypedText1t.Text = "";
  39.   lblTypedText2.Text = "";
  40.   lblTypedText2t.Text = "";
  41.   lblTypedText3.Text = "";
  42.   lblTypedText3t.Text = "";
  43.  
  44.   TypewriterPreset.SetGeneral(introline_TYPEWRITER_PRESET, 2, 4, eTypedDelay_Mixed, 200); // long reading time so it stays on screen
  45.   //TypewriterPreset.SetGeneral(introline_TYPEWRITER_PRESET, eTypedDelay_Mixed, 20); // long reading time so it stays on screen
  46.   //TypewriterPreset.SetCaret(introline_TYPEWRITER_PRESET, 2, 4, eTypedCaret_Explicit, " ");
  47.   //AudioClip *type_clips[] = new AudioClip[3];
  48.  // type_clips[0] = aKeyboard;
  49.   //type_clips[1] = aKeyboard2;
  50.  // type_clips[2] = aKeyboard3;
  51.  // TypewriterPreset.SetSoundArray(introline_TYPEWRITER_PRESET, type_clips, 3, null, aKeyboard_beep);
  52. }
  53.  
  54. void NextIntroline()
  55. {
  56.         /*if (!playingCredits)
  57.         {
  58.                 if (introline_tw[0] != NO_TYPEWRITER)
  59.                 {
  60.                         TypewriterRunners.Cancel(introline_tw[introline_index]);
  61.                 }
  62.                 if (introline_tw[1] != NO_TYPEWRITER)
  63.                 {
  64.                         TypewriterRunners.Cancel(introline_tw[introline_index]);
  65.                 }
  66.         }*/
  67. }
  68.  
  69. function repeatedly_execute_always()
  70. {
  71.         if (!playingCredits)
  72.         {
  73.     /*if (introline_tw[0] != NO_TYPEWRITER)
  74.     {
  75.       if (!TypewriterRunners.IsActive[introline_tw[0]])  
  76.                         {
  77.                                 introline_tw[0] = NO_TYPEWRITER;
  78.                         }
  79.     }
  80.     else if (introline_tw[1] != NO_TYPEWRITER)
  81.                 {
  82.       if (!TypewriterRunners.IsActive[introline_tw[1]])  introline_tw[1] = NO_TYPEWRITER;
  83.     }*/
  84.                 //if (introline_tw[0] != NO_TYPEWRITER && !TypewriterRunners.IsActive[0]) gHelp.Visible=true;
  85.                
  86.                 if (introline_Small_tw[0] == NO_TYPEWRITER) // first typewriter was not started yet
  87.                 {
  88.                         player.SayBackground("test");
  89.                         if (Game.DoOnceOnly("1st intro line SMALL FONT"))
  90.                         {
  91.                                 // start first line
  92.                                 introline_Small_tw[0] = lblTypedText1t.Typewriter(introlines_Small[introline_Small_index], eNoBlock, introline_TYPEWRITER_PRESET);
  93.                                 introline_Small_index++;
  94.                         }
  95.                 }
  96.                 if (introline_Small_tw[0] != NO_TYPEWRITER && !TypewriterRunners.IsActive[0]) // first typewriter has started and finished typing
  97.                 {
  98.                         if (Game.DoOnceOnly("1st intro line BIG FONT"))
  99.                         {
  100.                                 // start second line
  101.                                 introline_Big_tw[0] = lblTypedText1.Typewriter(introlines_Big[introline_Big_index], eNoBlock, introline_TYPEWRITER_PRESET);
  102.                                 introline_Big_index++;
  103.                         }
  104.                 }
  105.                 /*if (introline_tw[1] != NO_TYPEWRITER && !TypewriterRunners.IsActive[introline_tw[1]]) // second typewriter has started and finished typing
  106.                 {
  107.                         if (Game.DoOnceOnly("2nd intro line SMALL FONT"))
  108.                         {
  109.                                 // Remove first two lines
  110.                                 TypewriterRunners.Cancel(introline_tw[0]);
  111.                                 TypewriterRunners.Cancel(introline_tw[1]);
  112.                                 // Start third line
  113.                                 introline_tw[2] = lblTypedText2t.Typewriter(introlines[introline_index], eNoBlock, introline_TYPEWRITER_PRESET);
  114.                                 introline_index++;
  115.                         }
  116.                 }
  117.                 if (introline_tw[2] != NO_TYPEWRITER && !TypewriterRunners.IsActive[introline_tw[2]]) // third typewriter has started and finished typing
  118.                 {
  119.                         if (Game.DoOnceOnly("2nd intro line BIG FONT"))
  120.                         {
  121.                                 // start fourth line
  122.                                 introline_tw[3] = lblTypedText3.Typewriter(introlines[introline_index], eNoBlock, introline_TYPEWRITER_PRESET);
  123.                                 introline_index++;
  124.                         }
  125.                 }*/
  126.                 if (introline_Big_index == introline_Big_count || introlines_Big[introline_Big_index] == null)
  127.                 {
  128.                         lblTypedText3.Text="END";
  129.                         introline_Big_index = 4;
  130.                 }
  131.         }
  132. }
  133.  

Even tried to test that the code was detecting the introline_tw[0] != NO_TYPEWRITER && !TypewriterRunners.IsActive[0] by opening a GUI, but instead of opening the GUI after it finished typing, it opened it immediately after the 1st letter was written. ???
Also tried to separate the lines into Small and Big, but didn't helped either.

If I put 1000 in the reading delay, it'll hang forever in the 1st line and never start the second, as it is now, it's still writing both lines at the same time.

EDIT: Any help here? I've also tried now to create 2 different typewriters (but module seems to ignore this, and use the last line as setting for both lines), by separating the #Define, made one for the small and one for the big, created 2 lines of TypeWriterPreset, one for the small and one for the big... yet I still only get the same result.  ???
It's like it doesn't really detect when the first line is done writing, and thus only starts writing the next once the first is removed from screen. Wich results if I put 10 in the reading speed it types the first, removes it and then writes the second line. If I put 1000, like you suggest, it writes the 1st line and will never write the second line before the sequence is over.  8-0

Also tried variants on the second if condition and still all I get is either both at the same time, or the 2nd after the 1st got removed.  :~(
« Last Edit: 25 Mar 2017, 21:14 by Cassiebsg »
There are those who believe that life here began out there...

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #31 on: 26 Mar 2017, 18:39 »
My suggestion does not work because IsActive returns true until automatic typewriter clears text, and you do not need the text to be cleared until some other time.
You could use timer instead to know when start next typewriter.

But I think best way for now is to use one manual typewriter and just switch label it prints on. This will leave text on previous label until you explicitly tell it to clear.

Code: Adventure Game Studio
  1.  
  2. String introlines[];
  3. int introline_index;
  4. int introline_count;
  5. bool playingCredits;
  6.  
  7. TypewriterLabel twl;
  8.  
  9. function game_start()
  10. {
  11.   introline_count = 7;
  12.   introlines = new String[introline_count];
  13.   introlines[0] = "A fan game by     [";
  14.   introlines[1] = "Sandra T. Almeida [";
  15.   introlines[2] = "Made with             [";
  16.   introlines[3] = "Adventure Game Studio [";
  17.   introlines[4] = "based on the original TV show: [";
  18.   introlines[5] = "Battlestar Galactica           [";
  19.   introlines[6] = " ";
  20.   introline_index = 0;
  21.  
  22.   lblTypedText1.Text = "";
  23.   lblTypedText1t.Text = "";
  24.   lblTypedText2.Text = "";
  25.   lblTypedText2t.Text = "";
  26.   lblTypedText3.Text = "";
  27.   lblTypedText3t.Text = "";
  28.  
  29.   twl.TypeDelayMin = 2;
  30.   twl.TypeDelayMax = 4;
  31.   twl.TypeDelayStyle = eTypedDelay_Mixed;
  32.   twl.TextReadTime = 5;
  33. }
  34.  
  35. function repeatedly_execute_always()
  36. {
  37.         if (!playingCredits)
  38.         {
  39.                 if (twl.IsActive)
  40.                   twl.Tick();
  41.          
  42.                 if (introline_index == 0) // typewriter has not start to type the first line yet
  43.                 {
  44.                         // start first line
  45.                         twl.TypeOnLabel = lblTypedText1t;
  46.                         twl.Start(introlines[introline_index]);
  47.                         introline_index++;
  48.                 }
  49.                 else if (introline_index == 1 && twl.IsIdle) // typewriter finished typing first line
  50.                 {
  51.                         // start second line
  52.                         twl.TypeOnLabel = lblTypedText1;
  53.                         twl.Start(introlines[introline_index]);
  54.                         introline_index++;
  55.                 }
  56.                 else if (introline_index == 2 && twl.IsIdle) // typewriter finished typing second line
  57.                 {
  58.                         // clear previous
  59.                         lblTypedText1.Text = "";
  60.                         lblTypedText1t.Text = "";
  61.                         // start third line
  62.                         twl.TypeOnLabel = lblTypedText2t;
  63.                         twl.Start(introlines[introline_index]);
  64.                         introline_index++;
  65.                 }
  66.                 else if (introline_index == 3 && twl.IsIdle) // typewriter finished typing 3rd line
  67.                 {
  68.                         twl.TypeOnLabel = lblTypedText2;
  69.                         twl.Start(introlines[introline_index]);
  70.                         introline_index++;
  71.                 }
  72.                 else if (introline_index == 4 && twl.IsIdle) // typewriter finished typing 4th line
  73.                 {
  74.                         // clear previous
  75.                         lblTypedText2.Text = "";
  76.                         lblTypedText2t.Text = "";
  77.                         twl.TypeOnLabel = lblTypedText3t;
  78.                         twl.Start(introlines[introline_index]);
  79.                         introline_index++;
  80.                 }
  81.                 else if (introline_index == 5 && twl.IsIdle) // typewriter finished typing 5th line
  82.                 {
  83.                         twl.TypeOnLabel = lblTypedText3;
  84.                         twl.Start(introlines[introline_index]);
  85.                         introline_index++;
  86.                 }
  87.                 else if (introline_index == 6 && twl.IsIdle) // typewriter finished typing 5th line
  88.                 {
  89.                         // clear previous
  90.                         lblTypedText3.Text = "";
  91.                         lblTypedText3t.Text = "";
  92.                         twl.TypeOnLabel = null;
  93.                         twl.Clear();
  94.                 }
  95.         }
  96. }
  97.  
  98.  
« Last Edit: 26 Mar 2017, 18:44 by Crimson Wizard »

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #32 on: 26 Mar 2017, 19:10 »
Oh, cool! Thanks for the reply!  (nod)

I'll go ahead and test it right now! If it works I can finally start writing all the credits text.  :-D

EDIT: Cool! It's working!  :-D  :-D  :-D
Gave me an error though on another part of the code, so I'll have to figure it out, and hopefully I can figure it out without having to bother you again.  (nod)

EDIT2: Okay, I managed to solve it, but had to remove this last line at the end twl.Clear();, as it was causing a null pointer reference.
Though, seems to be working just fine without the line.  (nod)

EDIT3 : I moved on to make a credits section (new script, with all introline changed to creditline, and the typewriter is now called twlC, only I can only run the credits once.  8-0 If I put the twl.Clear(); I get the null pointer reference at the end, if I remove it I get the null pointer reference at the start or the second run of credits.  8-0
Think I'll try and see if I can put the line someplace else, outside rep_exe_always and see if that helps.  (roll)

EDIT4: I noticed, after doing a search for the function, that IniFile also had a void Clear()... I changed the name of it, and that solved the problem of the null pointer reference.  :-D
« Last Edit: 26 Mar 2017, 22:10 by Cassiebsg »
There are those who believe that life here began out there...

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #33 on: 30 Mar 2017, 12:24 »
EDIT3 : I moved on to make a credits section (new script, with all introline changed to creditline, and the typewriter is now called twlC, only I can only run the credits once.  8-0 If I put the twl.Clear(); I get the null pointer reference at the end, if I remove it I get the null pointer reference at the start or the second run of credits.  8-0
Think I'll try and see if I can put the line someplace else, outside rep_exe_always and see if that helps.  (roll)

EDIT4: I noticed, after doing a search for the function, that IniFile also had a void Clear()... I changed the name of it, and that solved the problem of the null pointer reference.  :-D

Wait wait... what? Are you saying there is a bug that having two same functions in two types of objects may lead to error when calling it?

TBH I was sure twl.Clear() was causing errors because I did "twl.TypeOnLabel = null;" just before that, and Clear uses TypeOnLabel reference without checking if its null.

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #34 on: 30 Mar 2017, 18:06 »
Guess that's what I'm saying?
At least after I changed the name, the error stopped and all is running just fine.

I was a little more surprised that the AGS allows two void/function be called the same in game. I thought it would complain if the name had already been used.

EDIT:

Ermmm... it's me again...
Is it possible to type more than one line in the same label? First I tried to do something like:

Code: Adventure Game Studio
  1.   introlines[4] = "based on the original TV show: [
  2.                           Battlestar Galactica           [";
  3.  

But it complains with a : undefined symbol 'Battlestar' ...  8-0
I thought that as long as the " was open, it would not complain with such a thing.  :-\ Putting it all into one long line, works up to the point when there's no more space and AGS breaks the line, and then I'm back to the above problem...
Is there maybe an append command? so that the next line starts typing after the previous? Right now if I do

Code: Adventure Game Studio
  1.                 else if (introline_index == 4 && twl.IsIdle) // typewriter finished typing 4th line
  2.                 {
  3.                         // clear previous
  4.                         lblTypedText2.Text = "";
  5.                         lblTypedText2t.Text = "";
  6.                         twl.TypeOnLabel = lblTypedText3t;
  7.                         twl.Start(introlines[introline_index]);
  8.                         introline_index++;
  9.                 }
  10.                 else if (introline_index == 5 && twl.IsIdle) // typewriter finished typing 5th line
  11.                 {
  12.                         twl.TypeOnLabel = lblTypedText3;
  13.                         twl.Start(introlines[introline_index]);
  14.                         introline_index++;
  15.                 }
  16.                 else if (introline_index == 6 && twl.IsIdle) // typewriter finished typing 6
  17.                 {
  18.                         twl.TypeOnLabel = lblTypedText3;
  19.                         twl.Start(introlines[introline_index]);
  20.                         introline_index++;
  21.                 }
  22.  
  23.  

It will type the text on label 3, and then clear it and type the next text on the label.

So right now, I'm thinking that the only option is to make a label for each line?  8-0 ??? Sounds a bit over kill though.  :-\
« Last Edit: 11 Apr 2017, 21:32 by Cassiebsg »
There are those who believe that life here began out there...

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #35 on: 15 Apr 2017, 13:13 »
Cassie, you keep adding updates to the same post after WEEKS, and I do not notice them in time: the main forum page does not display "new posts" icon in this case, so I don't check the thread.

I went here just by luck, because there was a new post in another module topic.


Regarding your question, for some reason AGS script editor does not support multiline strings. You do this instead:
Code: Adventure Game Studio
  1. String s = "Some string";
  2. s = s.Append("Longer string");
  3. s = s.Append("Even more longer string");
  4.  
« Last Edit: 15 Apr 2017, 13:20 by Crimson Wizard »

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #36 on: 15 Apr 2017, 13:40 »
Okay, thanks for the help.  (nod)

Sorry about the editing thing... just not that easy to figure out when it's okay to double post and when it's not.  :-[
And since I found out that it does indeed show "new" in the post topic after an editing, I thought that should then be good enough.
I too would love these "edit new" to show up in the "Show unread posts since last visit." As I often also miss edited posts.

But don't worry, I wasn't getting desperate or anything. Had decided that I could probably solve this by adding a couple more labels, and just add as much in one line as possible.

EDIT: Just saying it works!  (nod) Thanks bunch. Now I just need to format the text so it looks nice.  ;)
« Last Edit: 16 Apr 2017, 21:09 by Cassiebsg »
There are those who believe that life here began out there...

Re: MODULE: TypedText 0.7.0
« Reply #37 on: 21 Dec 2017, 19:54 »
Hi,

I'm trying to utilise this module, however I'm having a slight issue and I'm wondering if anyone can help me?

I'm using the TypewriterLabel function, and have replicated the code above pretty much exactly, however I'm finding that when running the game, the gui label writes out perfectly except for the last word which goes onto a separate line below the rest of the text.

I've tried using different labels of different sizes but it always seems to be the case.

any ideas?

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #38 on: 21 Dec 2017, 20:15 »
Well, you could post the code so we can see if there's something in there causing the line break.

In the mean time, I would say make sure the label is wide enough to fit the text, just try and give it a few pixels more to the sides and see if that helps.
check that you do not have a [ before the last word. Try to add a space to the end of the line, after your last word.
There are those who believe that life here began out there...

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #39 on: 21 Dec 2017, 20:45 »
Yes, the first guess will be that you have '[' character in the string which is used as a linebreak in AGS.

On a side note, I realized there is a functionality limitation in this module that it cannot handle "escaped" linebreaks, e.g. "\\[" will still break line, although it must print '[' character (it does in common functions like Display(...)).
« Last Edit: 21 Dec 2017, 20:48 by Crimson Wizard »

Re: MODULE: TypedText 0.7.0
« Reply #40 on: 24 Dec 2017, 18:43 »
This is really cool, Crimson! Glad to see a more fleshed out version of the typewriter module. Awesome work.

Re: MODULE: TypedText 0.7.0
« Reply #41 on: 27 Dec 2017, 22:21 »
Hi apologies with the delayed response...

No there's certainly no [ in the text - however adding a space after the final word has seemed to resolve the issue.

Thank you for your assistance.

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #42 on: 27 Dec 2017, 23:01 »
No there's certainly no [ in the text - however adding a space after the final word has seemed to resolve the issue.

Could you give an example of text that caused this? Does this happen with any text or particular one? Depends on font? This information would be very useful to prevent this error in the future.

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: MODULE: TypedText 0.7.0
« Reply #43 on: 28 Dec 2017, 17:04 »
Uhm, I think it happens with all text in the module, maybe?
I remember adding the space on my lines, cause I was experiencing the same problem with the line breaking (which is why I suggested the space at the end).
I didn't thought much about it at the time. I was using ttf font if that makes a difference.
There are those who believe that life here began out there...