Scripting help: Dialogue without blocking script?

Started by GazingAbyss, Thu 02/01/2014 22:53:40

Previous topic - Next topic

GazingAbyss

The basic problem: I'm trying to make a game that imitates real time, with certain events only happening at specific times, but dialogue always makes it crash.

I've got the game keeping track of time using a counter that's in the global script, under repeatedly_execute, like so:

Code: ags

Seconds++;
  if(Seconds == 100){
    OneMinutes++;
    Seconds = 0;
  }
  if(OneMinutes == 10){
    TenMinutes++;
    OneMinutes = 0;
  }
  if(TenMinutes == 6){
    Hours++;
    TenMinutes = 0;
  }
// If you're curious, the OneMinutes/TenMinutes thing (rather than just Minutes) was so that 
// the time displays correctly if the player checks a clock
  if(Hours == 12){
    if(AnteMeridian == false){
       Seconds = 0;
       TenMinutes = 0;
       OneMinutes = 0;
       Hours = 7;
       AnteMeridian = true;
       PartOfDay = "AM";
       NewDay = true;
       DayCount++;
    }
    else{
      PartOfDay = "PM";
    }
  }
  if(Hours == 13){
    if(AnteMeridian == true){
       Seconds = 0;
       TenMinutes = 0;
       OneMinutes = 0;
       Hours = 1;
       AnteMeridian = false;
    }
  }


It works pretty well so far, but now I'm trying to have an NPC enter a room at a specific time (which works), and then say something (which doesn't). The problem is that dialogue is a blocking event, and it's making the whole game crash if I put the command to have the NPC speak under repeatedly_execute_always, but if I put it under repeatedly_execute, it just seems to skip over the command entirely.

I've read through the description of the Display command and a few other questions on the forums, so I know there's no non-blocking version of Display, but is there some kind of work-around I can use? IIRC, I'm pretty sure at least one adventure game I've played had text pop up to indicate sounds effects without interrupting the gameplay... Any suggestions?

Secret Fawful

There are a few QueuedSpeech modules out there. The one I use is by monkey_05_06.

You can find it here.

Khris

Is it deliberate that a minute has 100 seconds?


GazingAbyss

@Secret Fawful:

Thanks! I'll try that out!

@Khris:
Yes and no... Technically, each 'second' is only 1/40th of a second on normal speed, since the Second++ command happens once per cycle. Right now I just have it set to something short enough that I don't have to sit around waiting for hours when I'm play testing, and I'll set it to take longer once the game actually works, but I still don't want each 'day' of game time to take a literal day.

Khris

I'm not really trusting my brain at this hour of the night, but wouldn't using 60 seconds make game time pass even faster...?

GazingAbyss

@Khris:
It would, but for what I'm trying to figure out right now, I need a little extra time to interact with a few different objects and hotspots to make sure it's all working the way I want it to. I'm pretty much constantly adjusting it based on what I'm doing at the moment.

SMF spam blocked by CleanTalk