Blocking functions in repeatedly_execute_always() - problem with workaround

Started by paolo, Fri 22/02/2008 08:09:39

Previous topic - Next topic

paolo

My scenario is this - I want an action to happen after a set time has elapsed, and this action will involve blocking functions, specifically, Display() and/or Say().

I have got this partially working as follows:

* Set timer in room A script, and set a boolean to false.
* In repeatedly_execute_always() in the global script (because the timer can expire in either of two rooms, A and B), if the timer has expired, set the boolean to be true.
* In the scripts for room A and room B, whenever X happens (see below), call a function that checks whether the boolean is true and then carries out the action accordingly. As this is function is not called from repeatedly_execute_always(), the AGS engine is happy.

This is pretty much the standard workaround, as I understand it, and it works just fine, except for one thing. My "X" in "whenever X happens" above is that the mouse moves over any hotspot on the screen. I have ensured that the whole screen is made up of hotspots, so that no matter where I am on the screen, as soon as the boolean is set to true, the action gets triggered automatically. (I also set the boolean back to false in the first line of the function, otherwise it would be triggered multiple times, which I don't want.)

The problem is that I have a GUI at the bottom of each of the two rooms, and GUIs receive the mouse focus when the mouse is over them. So the hotspot or part of a hotspot below the GUI will not detect the "Mouse moves over hotspot" event. Furthermore, a GUI does not itself have a "Mouse moves over hotspot" event. The best I am able to do is to pick up when the user clicks on a GUI.

So the difficulty I have is that if the user moves the mouse over the GUI and leaves it there, the action is not triggered when the boolean becomes true.

Hence what I need is either a means of processing a mouse-over event for a GUI (which doesn't seem to be possible, at least, not in 2.71), or an alternative method of causing my action to happen as soon as my boolean is set to true, irrespective of what the player happens to be doing at the time, and not within repeatedly_execute_always().

I'm sure this problem must have been solved before. Anyone have a solution? Thanks very much.

paolo

Khris

I'm not sure if it's me or you who's missing something, but why don't you skip the boolean part and put your IsTimerExpired-block into repeatedly_execute()?
It's fine to call blocking functions in there.

SSH

12

paolo

D'oh, I thought that neither of those functions could handle blocking functions.

OK, that makes everything much simpler, then. Come to think of it, I'm sure I must have put blocking stuff in repeatedly_execute() before now.

Thanks, guys.

SMF spam blocked by CleanTalk