How to use iuplua in MUSH?

Posted by Applehoo on Sun 28 Nov 2010 11:58 AM — 8 posts, 39,458 views.

China #0
in lua5.1

require("iuplua")

file: hbox.wlua running ok..

but using it in luascript of Mush 4.43or higher.

Error:

Run-time error
World: pkuxkx_path
Immediate execution
[string "Script file"]:7: module 'iuplua' not found:
no field package.preload['iuplua']
no file '.\iuplua.lua'
no file 'D:\MUSHCL~1\lua\iuplua.lua'
no file 'D:\MUSHCL~1\lua\iuplua\init.lua'
no file 'D:\MUSHCL~1\iuplua.lua'
no file 'D:\MUSHCL~1\iuplua\init.lua'
no file 'D:\Lua\5.1\lua\iuplua.luac'
no file '.\iuplua.dll'
no file 'D:\MUSHCL~1\iuplua.dll'
no file 'D:\MUSHCL~1\loadall.dll'
stack traceback:
[C]: in function 'require'
[string "Script file"]:7: in main chunk
------------1.How to Use Iuplua in mush??-------
------------2.OR,How to use wxlua in mush-------
Thanks for your help!
Amended on Sun 28 Nov 2010 12:07 PM by Applehoo
China #1
After you download all iuplua's dlls from iuplua project website, don't use require() statement, just use following code to load it.


assert (package.loadlib ("iuplua51.dll", "luaopen_iuplua")) ()


USA #2
Since it's a dll...


print (package.cpath)

and make sure the iuplua51.dll is in that path before you require it.

MushClient will inherit the system's LUA_CPATH variable too, if you wish so set one through the control panel.


Loadlib has been deprecated after lua 4.0 in favor of require, and it's usage isnt recommended.
Australia Forum Administrator #3
IupLua looks very interesting, however I'm not sure you will get it to work in MUSHclient (nor wxlua).

The reason is that as these are graphical front-ends they will have their own event loops, processing mouse events, keyboard events and screen-draw events.

However MUSHclient also has an event loop. Which event loop eventually "gets control" is likely to lock out the other one.

To do graphics inside MUSHclient, I recommend the miniwindows, see:

http://mushclient.com/mw

An alternative could be to make a separate application using IupLua (or wxLua) and then "talk" to it using COM or via TCP/IP (or UDP) to send it information you want drawn graphically.
Australia Forum Administrator #4
In particular I found this sentence in their documentation:


IUP can also work together with other interface toolkits. The main problem is the IupMainLoop function. If you are going to use only Popup dialogs, then it is very simple. But to use non modal dialogs without the IupMainLoop you must call IupLoopStep from inside your own message loop. Also it is not possible to use Iup controls with dialogs from other toolkits and vice-versa.


Lua scripts in MUSHclient don't have access to the main MUSHclient message loop (effectively it is the driving force behind the entire GUI interface). Thus it would be hard to call IupLoopStep, and thus you would effectively by stuck inside IupMainLoop until such time as you closed all the IUP windows, probably not something you want.
USA #5
Nick Gammon said:

In particular I found this sentence in their documentation:


IUP can also work together with other interface toolkits. The main problem is the IupMainLoop function. If you are going to use only Popup dialogs, then it is very simple. But to use non modal dialogs without the IupMainLoop you must call IupLoopStep from inside your own message loop. Also it is not possible to use Iup controls with dialogs from other toolkits and vice-versa.


Lua scripts in MUSHclient don't have access to the main MUSHclient message loop (effectively it is the driving force behind the entire GUI interface). Thus it would be hard to call IupLoopStep, and thus you would effectively by stuck inside IupMainLoop until such time as you closed all the IUP windows, probably not something you want.


You could approximate a very slow loop by using the OnPluginTick callback, however.
function OnPluginTick()
  IupLoopStep()
end
Amended on Sun 28 Nov 2010 09:42 PM by Twisol
China #6
I have done a few testings on IUPLua, it provide a method to close the iup.MainLoop, after the iup's dialog was closed. (I don't think wxLua has similar method)


...
...
...
dlg:showxy(iup.RIGHT, iup.CENTER)
iup.MainLoop()

dlg:destroy()
iup.Close()


But, when the iup.MainLoop running, some of MUSHclient's function will not working, such as command history, arrow key recalls partial command ...

After iup.Close(), MUSHclient will back to normal.
USA #7
And this is why:

Nick Gammon said:
IupLua looks very interesting, however I'm not sure you will get it to work in MUSHclient (nor wxlua).

The reason is that as these are graphical front-ends they will have their own event loops, processing mouse events, keyboard events and screen-draw events.

However MUSHclient also has an event loop. Which event loop eventually "gets control" is likely to lock out the other one.