Need help triggering script when cursor is in Wait mode

Started by BlackBaron, Sun 20/04/2003 20:29:47

Previous topic - Next topic

BlackBaron

I want to activate some script when the cursor goes to Wait mode, so I tried adding in the function repeatedly_execute() the following


 if (GetCursorMode()==7) {
   ...some code...
 }
 else {
   ...some code...
 }


But that isn't working, it seems that what's inside that if never triggers.
I also tried using this:

 if (IsInterfaceEnabled()==0) {
   ...some code...
 }
 else {
   ...some code...
 }


and I tried this too:

 if (IsGamePaused()==1) {
   ...some code...
 }
 else {
   ...some code...
 }


But I had the same results, the code inside the ifs never triggers.

I figured that while the cursor is in Wait mode, the interface is disabled and the engine doesn't call the function repeatedly_execute() at all. Is this true?

Is there an easy way to do that?

Because the only alternative I can imagine is defining a couple of functions that do the necesary code and calling them before and after every single time I call a function that I know will turn the cursor into Wait mode, but that would be REALLY inefficient and may not work sometimes (like when is the engine itself that pauses the game).

Thanks for the help.

"Do you thirst for knowledge no matter the cost?"
            -Watrik, master glassblower

scotch

well if the game is in wait mode it's being blocked.. so any script is going to halt too.
don't know why you'd need to do this anyway.
not sure if I'm right but it could be that..

BlackBaron

I need to do that because I want that when the game is paused the GUI remains unchanged but I don't want the picture of the buttons to change when the cursor is over them.
"Do you thirst for knowledge no matter the cost?"
            -Watrik, master glassblower

Pumaman

What you ask is interesting, because I'm not sure if it's actually possible to do. I'll see about adding an option for "GUI unchanged but disabled" or something.

BlackBaron

Thanks a lot, that will really help.  ;D

Anyway, at least for now, I think I solved the problem, I took a different aproach, I disabled all "Mouseover Images" and added some code that checks if the game isn't paused and then "turn on" the appropiate button if the mouse is over it.

Now, this whole problem gave me what I think would be a cool idea, couldn't there be a fucntion that's called every time the game is paused (something similar to other on_even functions), that way minor details like that could be easyly fixed.  :)
"Do you thirst for knowledge no matter the cost?"
            -Watrik, master glassblower

Scorpiorus

Actually if the game is paused (not blocked) the repeatedly_execute() function is still being called:

function repeatedly_execute() {
 if(IsGamePaused()) {
   Display("inside repeatedly");
 }
}

If you pop up upper menu the game is paused but you see display message as well.

If you need special wait function which blocks the script but still calls repeatedlty_execute I suppose you may use the next one:


//main script:
function SpecialWait(int time) {
 int i=0;
 while (i<time) {
   repeatedly_execute();
   Wait(1);
   i++;
 }
}

//script header:
import function repeatedly_execute();
import function SpecialWait(int);

-Cheers

Pumaman

Yep, that's a clever trick. The problem is that it won't be used when the engine automatically blocks the game, eg. inside MoveCharacterBlocking.

BlackBaron

#7
Quote from: Scorpiorus on Mon 21/04/2003 11:31:33function repeatedly_execute() {
 if(IsGamePaused()) {
   Display("inside repeatedly");
 }
}

As I said in my first post, I already tried that (and if (IsInterfaceEnabled()==0)) and it didn't work (at least it didn't when the game was paused because DisplaySpeech was used).

Thanks a lot anyway.
"Do you thirst for knowledge no matter the cost?"
            -Watrik, master glassblower

Scorpiorus

Quote from: BlackBaron on Mon 21/04/2003 18:10:16
Quote from: Scorpiorus on Mon 21/04/2003 11:31:33function repeatedly_execute() {
 if(IsGamePaused()) {
   Display("inside repeatedly");
 }
}

As I said in my first post, I already tried that (and if (IsInterfaceEnabled()==0)) and it didn't work (at least it didn't when the game was paused because DisplaySpeech was used).

Thanks a lot anyway.
BlackBaron: I think it's because the game was blocked (wait mode). But the pausing only doesn't block the repeatedly_execute(). ;)

QuoteYep, that's a clever trick. The problem is that it won't be used when the engine automatically blocks the game, eg. inside MoveCharacterBlocking.
CJ: Yep, that is. The solution would be to write special variant of each blocking function, for example:

//main script

function repeatedly_execute() {
......................
... some code here ...
......................
}

function MoveCharacterBlocking2(int CharID, int x, int y, int direct) {
 if (direct) MoveCharacterDirect(CharID, x, y);
 else        MoveCharacter(CharID, x, y);
 while(character[CharID].walking) { //block the script...
   repeatedly_execute(); //...except repeatedly_execute()
   Wait(1);
 }
}

//script header:
import function MoveCharacterBlocking2(int, int, int, int);



... and replace MoveCharacterBlocking() with MoveCharacterBlocking2() where needed.

-Cheers

BlackBaron

I already thought on that, but that isn't efficiente enough, that would require rewriting every function I need and almost ignore all what the engine does for me... (not that I couldn't do it, but if I were, I'd simply use a more complicated but more free engine, as I always say).

Anyway, the only problem I've face until know with that was already solved. I used your aproach of doing my own code, but insead of dealing tih the "wait" code I dealed with the source of the problem itself, the MouseOver button images, as I said,  I disabled them all and added some code that checks if the game isn't paused before "turn on" the appropiate button if the mouse is over it.

Again, thanks a lot for your help.
"Do you thirst for knowledge no matter the cost?"
            -Watrik, master glassblower

BlackBaron

Of course, I'll always be glad to hear more efficient suggestions  ;)
"Do you thirst for knowledge no matter the cost?"
            -Watrik, master glassblower

SMF spam blocked by CleanTalk