Jewill, I haven't encountered this function before; I need to test it. The idea is promising, except for one point: why track when the window is closed? If we can't determine which window it is, then there isn't much point in the action...
-- Define variables somewhere, preferably separately for each player. --
WINDOW_CLOSED = nil;
WINDOW_NAME = "";
-------------------------------------------------------------------------
Trigger(OBJECT_TOUCH_TRIGGER,"mine_name","myCallback")
----------Let's assume we triggered a system message somewhere. -----------------
----------For example, by approaching a mine. In principle, you don't have to attach the trigger to a specific name. -------
----------------- I wrote this just as an example. -------------
--In general, since each building that triggers pop-ups (or any interactive windows) has a TYPE,---------
----you can attach this script to all buildings on the map in a separate file. ----
---- I'm not talking about custom windows; it's obvious how to handle them. ----
---- As for the city, that's a dark forest where I'm not very knowledgeable, and I'm not very interested either. But this principle won't work there. ---.
function myCallback(heroname,obj) -- Callback function, one for any of the buildings, because all it does is start another code.
local player = detectInteractor(heroname) -- Here, we simply determine the player based on the hero. (I invented the function; it's very easy to implement.)
WINDOW_NAME = "MINE_WINDOW"
startThread(checkWindowState,player);
end;
function checkWindowState(player)
while(CanShowPlayer(player) == nil) do
sleep(2);
end;
WINDOW_CLOSED = not nil;
end;
function windowClosed()
while(1) do
sleep(3);
if(WINDOW_CLOSED ~= nil) then
--------Iterate through calls based on WINDOW_NAME --------
if(WINDOW_NAME == 'MINE_WINDOW') then
--- Call the corresponding function, and start the thread to close the window again in it.----
--- In this same function, reset our variables before starting the thread. -----
break;
end;
end;
end;
end;
startThread(windowClosed);
Будь яростней пред ночью всех ночей,
Не дай погаснуть свету своему!
Хоть мудрый знает – не осилишь тьму
Во мгле словами не зажжёшь лучей –
Не уходи безропотно во тьму.