PDA

View Full Version : Script help - how add a pause.



1lokos
Sep-07-2017, 15:59
Before all, I am "Script illiterate" - just do cut & past of existing scripts. So "Linux style" advice will sound "Greek" for me. :D

I want use a script at end of mission to give a instruction for player.

With scripts I can play recorded voice messages (Speech folder) - but due limitation of this messages* I need mix their sound and on screen text.



* Rant ON: around 30% of recorded messages of Speech folder is for use in that disastrous Tiger Moth Flight School, and as CloD "It's CloD!" some messages names don't match with you hear.

For example: Return_to_base_I_repeat_return_to_home_base.ogg say "Get out there man, save yourself". :doh:

Seems that besides the voices in Speech folder are more locked files (SFS), named wrong.

Rant OFF :D


I manage to make a script that play voice and text message based on trigger.


public override void OnTrigger(int missionNumber, string shortName, bool active)
{
base.OnTrigger(missionNumber, shortName, active);

if ("trigger1".Equals(shortName) && active)
{
airc1.SayToGroup(airc1.AirGroup(), "Good_job1");
GamePlay.gpHUDLogCenter("Return to base");
GamePlay.gpGetTrigger(shortName).Enable = false;
GamePlay.gpGetTrigger("trigger2").Enable = false;
}
if ("trigger2".Equals(shortName) && active)
{


But I want to make a pause between the "Good job" - besides the sound that phrase is write in screen - and the "Return to base".
Without pause the "Good job" and "Return to base" is write simultaneous on screen, awkward.

In this code - for play sound messages (work OK), are a pause between two:




public override void OnTickGame() {
if (Time.tickCounter() == 50) {
double initTime = 0.0;
airc1.SayToGroup(airc1.AirGroup(), "My_engine_s_dead");
});
Timeout(initTime += 2.0, () => {
airc1.SayToGroup(airc1.AirGroup(), "Mayday_Mayday_I_m_going_down");
});
}


But I don't manage do add this pause in the first script. What do do?

BTW - I try record a specific message with online voice generator, save in .OGG, but CLoD play that sound very low (sound good in Desktop) and beside this I need use some of the existing message name for trigger this new, and now what you (barely) hear don't match with the text on screen... Not good idea.

I notice that game engine can tie 2 or more voice messages in one, e.g. "Vector + 1 + five zero", but don't discover how do this in script.

ATAG_Colander
Sep-07-2017, 17:17
Thread.Sleep(milliseconds);

1lokos
Sep-07-2017, 17:55
If this is not "Linux code"... creo que entendí la broma... :thumbsup:

ATAG_Colander
Sep-07-2017, 18:00
Is not a joke...
You are asking how to add a pause. Sleep is a pause.

1lokos
Sep-07-2017, 19:17
OK. Thank you, but is in "LINUX code" form, because if I add that line the script became broken.

ATAG_Colander
Sep-07-2017, 20:12
Try this:
System.Threading.Thread.Sleep(MILLISECONDS);

Where:
MILLISECONDS = a number.

For example, to wait one second:
System.Threading.Thread.Sleep(1000);

1lokos
Sep-07-2017, 21:01
Well, work. But instead pause betweem messages.... pause the game for X seconds... :-P



public override void OnTrigger(int missionNumber, string shortName, bool active) {
if ("trigger1".Equals(shortName) && active)
{
airc1.SayToGroup(airc1.AirGroup(), "Good_job1");
System.Threading.Thread.Sleep(6000);
GamePlay.gpHUDLogCenter("Return to base.");
GamePlay.gpGetTrigger(shortName).Enable = false;
GamePlay.gpGetTrigger("shipsunk").Enable = false;
}

ATAG_Colander
Sep-07-2017, 21:11
What you want is more like this:



public override void OnTrigger(int missionNumber, string shortName, bool active) {
if ("trigger1".Equals(shortName) && active)
{
airc1.SayToGroup(airc1.AirGroup(), "Good_job1");
Timeout( 6.0, () => {
GamePlay.gpHUDLogCenter("Return to base.");
}
GamePlay.gpGetTrigger(shortName).Enable = false;
GamePlay.gpGetTrigger("shipsunk").Enable = false;
}


Basically say "good job" then start a timer that will say "return to base".

1lokos
Sep-07-2017, 21:26
No joy. Result the same error that happens when I try use the "tickCounter" (code in OP) - that work OK if don't mix the messages.

https://s26.postimg.org/ebswiqw4p/Script_error.jpg (https://postimages.org/)

ATAG_Freya
Sep-08-2017, 00:28
Don't know if this would be right, but something like it?


private void triggeroneSpeech(AiAircraft aircraft)
{
double initTime = 0.0;

aircraft.SayToGroup(aircraft.AirGroup(), "Good_job1");

Timeout(initTime += 2, () =>
{
aircraft.SayToGroup(aircraft.AirGroup(), "Return to base.");
});
}

1lokos
Sep-08-2017, 01:12
Your scrip is for voice messages only, like in this script (that work OK, with delay).



public override void OnTickGame() {
if (Time.tickCounter() == 50) {
double initTime = 0.0;
airc1.SayToGroup(airc1.AirGroup(), "My_engine_s_dead");
});
Timeout(initTime += 2.0, () => {
airc1.SayToGroup(airc1.AirGroup(), "Mayday_Mayday_I_m_going_down");
});
}


My problem is that the necessary script need that second message be text only, so using:

GamePlay.gpHUDLogCenter("Return to base");

And that text don't appear simultaneous with the voice message (the airc1.SayToGroup(airc1.AirGroup(), "Good_job1"); ) after the trigger1 fire.

ATAG_Freya
Sep-08-2017, 02:06
Hehe, guess I should have read the first post more carefully!

1lokos
Sep-09-2017, 00:35
AHHHHHHHHHHHHHH!:whaa:grrr:

99 trial and error after, :pcguy: and launch the mission 98 times to test :smash: , the thing WORK. :-)



using System;
using System.IO;
using System.Collections;
using maddox.game;
using maddox.game.world;


public class Mission : AMission {

AiActor a1;
AiAircraft airc1;

public override void OnBattleStarted() {
base.OnBattleStarted();
a1 = GamePlay.gpActorByName("0:BoB_RAF_F_92Sqn_Early.000");


if (a1 == null) {
GamePlay.gpLogServer(null, "SCRIPT ERROR: Aircraft not found\n", new object[] { });
}

airc1 = (AiAircraft)a1;
}


public override void OnTickGame() {
if (Time.tickCounter() == 50) {
double initTime = 0.0;
Timeout(initTime += 2.0, () => {
airc1.SayToGroup(airc1.AirGroup(), "My_engine_s_dead");
});
Timeout(initTime += 2.0, () => {
airc1.SayToGroup(airc1.AirGroup(), "Mayday_Mayday_I_m_going_down");
});
}
}
public override void OnTrigger(int missionNumber, string shortName, bool active) {
if ("trigger1".Equals(shortName) && active)
{
double initTime = 0.0;
if (airc1.Person(0) != null &&
airc1.Person(0).Health > 0.6) {
Timeout(initTime += 1.0, () => {
airc1.SayToGroup(airc1.AirGroup(),"Good_job1");
});
{
if (airc1.Person(0) != null &&
airc1.Person(0).Health > 0.6) {
Timeout(initTime += 4.0, () => {
GamePlay.gpHUDLogCenter("Return to base.");
GamePlay.gpGetTrigger(shortName).Enable = false;
GamePlay.gpGetTrigger("trigger2").Enable = false;
});

}
}
}
}
}
}


The "Compile" function in FMB point - vaguely - the lines with errors.

The "funny" is: If I need do this again tomorrow, I don't remember how I did...:doh: