Running script only while blocking [solved!]

Started by Vince Twelve, Mon 16/07/2007 07:17:16

Previous topic - Next topic

Vince Twelve

Maybe it's my lack of sleep, but in my head this was easy...

I have a batch of code that I want to run ONLY while the game is in the middle of some blocking function (walking, animating, wait();, etc).  My original plan was to stick this code in the repeatedly_execute_always:

if(mouse.Mode==eModeWait){
  //execute this batch of code
}

But it doesn't do anything when the game is blocking.  So, I change eModeWait to eModeWalkTo, and it works perfectly as long as the cursor mode is walk to, even if the cursor is set to walk to and then a blocking cutcene starts (thus changing the cursor to the wait cursor's graphic), and even when I change back and forth between modes in the middle of a blocking function.  It seems to work with every mode except wait, the one mode I want it to work with...

Does a blocking function not actually change the cursor to the wait mode?  It seems like it only changes the mouse's graphic.

So, my next thought was to run the script based on the cursor's graphic, but there's no mouse.graphic or some such variable (correct me if I'm wrong).

But this may all be pointless if there's a better way to run a block of script only when the game is blocking.  Help?

Khris

Try mouse.GetModeGraphic(mouse.Mode), not sure if it'll work though.

Vince Twelve

It doesn't... it constantly returns the graphic of the mouse mode used before the blocking function started.  Thanks, though!

Any more ideas?

Khris

Here's something that might help:

Code: ags
int repcycles;
int repacycles;

function repeatedly_execute_always() {
  if (repacycles>repcycles) {

    // blocking-only code

    lbl.Text=String.Format("X: %4d", Random(2000));
  }
  repacycles++;
  if (repacycles==32000) {
    repacycles=1;
    repcycles=0;
  } 
}

#sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
  // put anything you want to happen every game cycle here
  repcycles=repacycles;
}
#sectionend repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE


Works during a blocked walk and while player is saying dialog lines.
Doesn't work while a Display window or Dialog choice GUI is displayed.

Vince Twelve

I thought about using something like that, but it just seemed so... inelegant for such a simple effect that I'm trying to add in.  But I may end up using this.  Thanks!

I still wonder why the mouse doesn't actually change to the wait mode when blocking, though.

strazer

Quote from: Vince Twelve on Mon 16/07/2007 07:17:16Does a blocking function not actually change the cursor to the wait mode?  It seems like it only changes the mouse's graphic.

Exactly.

Vince Twelve

Ah.  I see.  I guess I can understand why.  Thanks for the confirmation strazer!

For now, Khris' workaround is working around!

Scorpiorus

By the way, there is the IsInterfaceEnabled() function to help you check for a blocking situation:

Code: ags

function repeatedly_execute_always() {

    if ( ! IsInterfaceEnabled() )
    {
        // your code here
    }

}


Vince Twelve

Beautiful!  That's the elegant solution I was looking for.  I had never seen this function before and hadn't found it because I thought that I could find a blocking state based on the mouse, not the interface.  Thank you Scorp!

Scorpiorus

No prob, and yeah it's rather hard to spot that function to have something to do with blocking -- I just happened to code a similar situation back in the old days of pre-object-oriented scripting in AGS, and so I shared.

:)

SMF spam blocked by CleanTalk