Hi
I think most people are aware of the limitations of SayBackground.
SayBackground is Non blocking yet does not take displaying variables (countdown).
I have a scenario whereby a timer starts counting down and an object (oblood) lowers a bit after it's Timer has expired and Timer gets reset untill counter=0. Once the counter=0 the next lot of events happen. This does work in the way I have it at the moment.
I hope coding below is formatted correctly.
function room_RepExec()
{
if (IsTimerExpired(1))
{
oblood.Move(oblood.X-0, oblood.Y+6, 2, eNoBlock, eAnywhere);
countdown=(countdown-1);
SetTimer(1, 80);
}
}
Now, I could use a GUI to show the countdown Timer. I indeed do have this and it works perfectly.
I decided it would be better if a NPC SayBackground counted down (oghost2 animates eNoBlock each time the counter lowers by 1.) Of course Say works but is a blocking function.
In the Rep Exec
function room_RepExec()
{
if (IsTimerExpired(1))
{
oblood.Move(oblood.X-0, oblood.Y+6, 2, eNoBlock, eAnywhere);
countdown=(countdown-1);
oghost2.SetView(80);
oghost2.Animate(0, 4, eOnce, eNoBlock);
//cChar4.SayBackground("%d",countdown); // SayBackgound does not work with variable countdown
//gcountdown.X=cChar6. x +0; May need screen X Y
// gcountdown.Y=cChar6. y -100; May need screen X Y
SetTimer(1, 80);
}
if (countdown <=0 && Game.DoOnceOnly("Timer"))
{
gcountdown.Visible=false;
SetTimer(1, 0);
oblood.Graphic=1338;
Wait(30);
oblood.Graphic=1339;
Wait(30);
oblood.Graphic=1340;
Wait(30);
oblood.Graphic=1341;
Wait(30);
oblood.Graphic=1342;
Wait(30);
ob4.Graphic=1348;
of2.Graphic=1344;
ob5.Graphic=1346;
of1.Graphic=1350;
Wait(30);
of2.Graphic=1345;
ob5.Graphic=1347;
ob4.Graphic=1349;
of1.Graphic=1351;
Display("You are too late! Those children have been drained of thier blood!!");
}
}
function repeatedly_execute_always()
{
Ltimer.Text = String.Format("%d",countdown);
}
I have tried positioning the GUI to position it with NPC, this is a non go.
I probably need Screen X Y rather than Room X Y.
Hope you can understand this gobble and can lend your help and advice to find the best way around this.
I'll step back and wait for the hammer to fall :-[
SayBackground does not take variable parameters, that is true, but nothing prevents you from creating a formatted string and passing to SayBackground:
cChar4.SayBackground(String.Format("%d",countdown));
Or in a more verbose, but comprehendable way:
String s = String.Format("%d",countdown); // create a formatted text
cChar4.SayBackground(s); // use text in SayBackground
Thank you Crimson Wizard for your quick response and solution.
Works as I wanted 8-)
cheers
slasher