Wintermute Engine Forum

Wintermute Engine => Scripts, plugins, utilities, goodies => Topic started by: metamorphium on January 29, 2012, 09:19:47 PM

Title: Letter by letter writing
Post by: metamorphium on January 29, 2012, 09:19:47 PM
For J.U.L.I.A. I wrote a little method, which after you supply string and time does the following:

1. it writes letter by letter the specified and localized string
2. it waits for a specified time and then the text disappear

So how does it work?

1. create a script and call it system_writer.script

Code: WME Script
  1. #include "scripts/base.inc"
  2.  
  3. method Initialize()
  4. {
  5.         var win = Game.CreateWindow();
  6.         this.win = win;
  7.         win.Visible = false;
  8.         win.X = 0;
  9.         win.Width = 1024;
  10.         win.Y = 374;
  11.         win.Height = 20;
  12.         var edit = win.CreateStatic();
  13.         edit.Height = 20;
  14.         edit.Width = 1024;
  15.         edit.X = 0;
  16.         edit.Y = 0;
  17.         edit.SetFont("fonts\tahoma.font");
  18.         edit.TextAlign = TAL_LEFT;
  19.         this.edit = edit;
  20. }
  21.  
  22. method Write(textToWrite, time)
  23. {
  24.          var win = this.win;
  25.          var ed = this.edit;
  26.          win.Y = 374;
  27.                 
  28.          ed.Text = Game.ExpandString(textToWrite);
  29.         ed.SizeToFit();
  30.    
  31.        ed.X = 512 - ed.Width / 2;
  32.    
  33.      
  34.         
  35.          ed.Text = "";
  36.          win.Visible = true;
  37.          var str = new String(Game.ExpandString(textToWrite));
  38.  
  39.  
  40.          for (var a = 0; a<str.Length; a=a+1)
  41.          {
  42.                        ed.Text = str.Substr(0,a+1);
  43.                         ed.SizeToFit();
  44.                        
  45.                        Sleep(100);
  46.          }            
  47.          Sleep(time);
  48.         
  49.          ed.Text = "";
  50.          win.Visible = false;
  51.         
  52. }
  53.  

2. in scripts/base.inc add

global writer;

3. in scripts/game.script add the following:

Code: WME Script
  1. writer = new Object("scripts\system_writer.script");
  2. writer.Initialize();
  3.  

4. now whenever you want to use it, try:

Code: WME Script
  1. writer.Write("Testing letter by letter writer.", 1500);
  2.  


Hope this helps. :)
Title: Re: Letter by letter writing
Post by: piere on January 30, 2012, 12:18:48 AM
Thanks for the code ! would be cool if you posted different fun code samples too. I hope to see more stuff from J.U.L.I.A. soon !
Title: Re: Letter by letter writing
Post by: shuin on January 30, 2012, 09:42:43 PM
Very useful. Thank you!
Title: Re: Letter by letter writing
Post by: Chaos on February 15, 2012, 11:36:44 AM
Thank you a lot, Meta!  :) This is very useful indeed...I'm sure I'll be using such a cool feature very soon.
Title: Re: Letter by letter writing
Post by: keybone on February 24, 2012, 07:31:51 PM
tk for share your script:)
Title: Re: Letter by letter writing
Post by: binary1 on September 22, 2013, 12:40:12 AM
Very cool and useful!  Works like a charm!  Thanks.