Hi, I was trying to create my own function to write the speech on a gui, this function works perfect drawing the text on the gui, but the only problem is that the player can walk while and interact while the speech is draw in the gui (something like SayBackground) and the speech can't be skipped. Searching in the help menu of ags I found that you can use GUI.AsTextWindow but I can't get to work it. I use the thumbleweed script and the AGS version is the latest version.
I tried to add a timer to "Block" the interactions while the speech is on screen but doesn't work.
Code: ags
I tried to add a timer to "Block" the interactions while the speech is on screen but doesn't work.
// new module script
DynamicSprite*messagetext;
#define GWIDTH 300
#define GHEIGHT 30
#define GTIMER 1
#define TEST 1
void MySay(this Character*, String message) {
if (messagetext == null) messagetext = DynamicSprite.Create(GWIDTH, GHEIGHT);
DrawingSurface*ds = messagetext.GetDrawingSurface();
ds.Clear();
ds.DrawingColor = this.SpeechColor;
int w = GWIDTH - 20;
int wt = GetTextWidth(message, Game.SpeechFont) + 5;
if (wt < w) w = wt;
gSpeech.Width = w + 20;
gSpeech.X = (Screen.Width - w - 20) / 2;
int y = (GHEIGHT - GetTextHeight(message, Game.SpeechFont, w)) / 2;
ds.DrawStringWrapped(10, y, w, Game.SpeechFont, eAlignCenter, message);
ds.Release();
gSpeech.BackgroundGraphic = messagetext.Graphic;
gSpeech.Visible = true;
SetTimer(TEST, (message.Length / game.text_speed));
SetTimer(GTIMER, ((message.Length / game.text_speed) + 1) * GetGameSpeed());
}
function repeatedly_execute() { //this was supposed to work like "Blocking" but don't work
if (gSpeech.Visible) {
Wait(TEST);
}
}
function repeatedly_execute_always() {
GUI*g = gSpeech;
gBlack.Visible = g.Visible;
if (g.Visible) {
gBlack.SetPosition(g.X, g.Y);
gBlack.SetSize(g.Width, g.Height);
}
if (IsTimerExpired(GTIMER)) gSpeech.Visible = false;
}