
Originally Posted by
Galuhad
I found a possible solution in coroutines, but keep getting the message, "attempt to yield across metamethod/C-call boundary". Are coroutines disabled in Lotro?
I haven't tried using co-coroutines in lotro, but that message you might get from trying to "yield" in a section of your code that wasn't being run in a co-routine, and that would indicate to me that co-routines are enabled.
Still, co-routines won't help you, if you do not return from your script, then the runtime cannot dispatch events, even a "busy wait loop" wouldn't work, Button.Click() would never be called. No parallel execution.
You are going to have to handle things in an asynchronous way, as Garan suggested.
Using Update() along with some sort of state automaton might be unnecessary complicated for what you are trying to do, a simplistic asynchronous way of doing something akin to :
Code:
...
if MessageBox() == Affirmative then
-- do something
else
-- do something else
end
Might be
Code:
function affirmativeCase()
-- do something
end
function negativeCase()
-- do something else
end
OpenMessageBox( { <whatever list of windows you want to 'block'> }, affirmativeCase, negativeCase )
with a rough version of a message box being:
Code:
local function SetWindowsEnabled( windows, enabled )
for _,window in pairs( windows ) do
window:SetEnabled( enabled );
end
end
local MessageBox = class(Turbine.UI.Window);
function MessageBox:Constructor( windows, affirmativeCase, negativeCase )
Turbine.UI.Lotro.Window.Constructor(self);
self.affirmativeButton = Turbine.UI.Lotro.Button();
self.affirmativeButton:SetParent( self );
...
self.affirmativeButton.Click = function( sender, args )
EnableWindows( windows );
self:Close();
affirmativeCase();
end
self.negativeButton = Turbine.UI.Lotro.Button();
self.negativeButton:SetParent( self );
...
self.negativeButton.Click = function( sender, args )
EnableWindows( windows );
self:Close();
negativeCase();
end
self:SetVisible( true );
DisableWindows( windows );
end
function OpenMessageBox( windows, affirmativeCase, negativeCase )
messageBoxSingleton = MessageBox( windows, affirmativeCase, negativeCase );
end
Two tricks here being to disable your other windows so they do not receive user input, and to keep the message box in a global variable so that it does not get garbage collected right away. Come to think about it though, I've never tried disabling an entire window, I assume that works.