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
#include
"scripts/base.inc"
method
Initialize
(
)
{
var
win =
Game
.
CreateWindow
(
)
;
this
.
win
= win;
win.
Visible
=
false
;
win.
X
=
0
;
win.
Width
=
1024
;
win.
Y
=
374
;
win.
Height
=
20
;
var
edit = win.
CreateStatic
(
)
;
edit.
Height
=
20
;
edit.
Width
=
1024
;
edit.
X
=
0
;
edit.
Y
=
0
;
edit.
SetFont
(
"fonts\tahoma.font"
)
;
edit.
TextAlign
= TAL_LEFT;
this
.
edit
= edit;
}
method
Write
(
textToWrite, time
)
{
var
win =
this
.
win
;
var
ed =
this
.
edit
;
win.
Y
=
374
;
ed.
Text
=
Game
.
ExpandString
(
textToWrite
)
;
ed.
SizeToFit
(
)
;
ed.
X
=
512
- ed.
Width
/
2
;
ed.
Text
=
""
;
win.
Visible
=
true
;
var
str =
new
String
(
Game
.
ExpandString
(
textToWrite
)
)
;
for
(
var
a =
0
; a<str.
Length
; a=a
+1
)
{
ed.
Text
= str.
Substr
(
0
,a
+1
)
;
ed.
SizeToFit
(
)
;
Sleep
(
100
)
;
}
Sleep
(
time
)
;
ed.
Text
=
""
;
win.
Visible
=
false
;
}
2. in scripts/base.inc add
global writer;
3. in scripts/game.script add the following:
Code: WME Script
writer =
new
Object
(
"scripts\system_writer.script"
)
;
writer.
Initialize
(
)
;
4. now whenever you want to use it, try:
Code: WME Script
writer.
Write
(
"Testing letter by letter writer."
,
1500
)
;
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.