miniwindow initialized earlier than the main window

Posted by Zhenzh on Wed 20 Jun 2018 02:43 PM — 5 posts, 18,562 views.

China #0
I have a miniwindow plugin enabled in my script. It will be loaded each time starting a .MCL script.

The window position is calcuated from the size of main window.

My problem is that the miniwindow can not be located in the specified position.

I find the root cause of the issue is that the main window has not been ready when installing the miniwindow plugin which passed an incorrect window size to the plugin.

I added some debug messages in my plugin install function to proved my guess:


function OnPluginInstall ()
    
    Note(GetInfo(281))  -- get windows width
    DoAfterSepcial(5, "Note(GetInfo(281))", sendto.script)  -- get windows width again after 5 secs

end


I got the first valuse 791 and the second value 1419, which shows when plugin is installed, the main window has not been completely initialized.

How can I force the plugin install staring after main window is ready?
Australia Forum Administrator #1
"DoAfterSepcial" looks like a typo.

You can use DoAfterSpecial to initialize the miniwindow after a couple of seconds (rather than in OnPluginInstall).
China #2
How to get the plugin installed out of OnPluginInstall ?

I tried add DoAfterSpecial within OnPluginInstall function but it doesn't work as some parameters can not be passed.


function OnPluginInstall ()
    
    DoAfterSpecial(5, "tabbed_window.init (context1)", sendto.script)
    DoAfterSpecial(5, "tabbed_window.draw_window (context1, 1)", sendto.script)

end


Quote:

Reason: Executing plugin tabbed_window sub OnPluginInstall
C:\MUSHClient\lua\tabbed_window.lua:240: attempt to perform arithmetic on field 'height' (a nil value)
stack traceback:
C:\MUSHClient\lua\tabbed_window.lua:240: in function 'draw_window'
[string "Plugin: tabbed_window"]:630: in function <[string "Plugin: tabbed_window"]:624>
Australia Forum Administrator #3
Just call a function (eg. DelayedInstall) and then have that do all the work.
China #4
Finially, I get the plugin works by auto-detecting the status of the main window.


function OnPluginInstall ()
    wait.make(function()
        repeat
            if GetInfo(285) == true then
                InstallAfterReady()
                break
            end
            wait.time(0.5)
        until false
    end)
end

function InstallAfterReady()
    context1.window.left = GetInfo(281) - 600
    tabbed_window.init (context1)
    tabbed_window.draw_window (context1, 1)
end