[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  LuaSocket question and one more thing

LuaSocket question and one more thing

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Ircria   (24 posts)  [Biography] bio
Date Wed 09 Feb 2011 09:40 PM (UTC)
Message
Two questions here. First, when I use LuaSocket, it tends to have a delay as the information is grabbed. I tried working around this with Coroutines, but that didn't seem to work. Is there any way to get rid of this delay?

Also, I was wondering about how MUSHclient includes the main lua file. Would there be any issues if I used luac to compile my script file into bytecode?

Thank you.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Wed 09 Feb 2011 09:59 PM (UTC)
Message
I think the default in LuaSocket is to do "blocking" calls, hence your delay. Coroutines, per se, are not going to change that. It depends what you are trying to achieve, I think the library itself allows asynchronous IO, however it can be a little fiddly because MUSHclient itself has a "main loop" where it looks for incoming TCP data, and to have another point (in LuaSocket) where it also looks for TCP data is going to have two "choke points" so to speak.

Ircria said:

Also, I was wondering about how MUSHclient includes the main lua file. Would there be any issues if I used luac to compile my script file into bytecode?


It loads the main Lua file "the usual way". You can precompile it if you want. I just tested that and it worked OK. I'm not sure why you would bother, it makes changing scripts harder, and you don't save much time, but in principle you can do it.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Ircria   (24 posts)  [Biography] bio
Date Reply #2 on Wed 09 Feb 2011 10:17 PM (UTC)
Message
Mm. That makes sense. Thank you. Had a couple of other questions raised in that time.

When Note()ing before a luasocket call, it doesn't display the Note() in the buffer until after the socket function returns. Is there any way to get around this? Also, I was wondering if there was any way for my script to be alerted when the world connects/disconnects.

Thank you again.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Thu 10 Feb 2011 12:35 AM (UTC)
Message
The redrawing of the output window is done once the script completes. Calling Repaint () after the Note might help. Otherwise try SetStatus and keep an eye on the status line.

As for the connect/disconnect add a function name to the scripting "World Events" connect/disconnect boxes. You will need a script file to be active, and then provide a suitable function (one that takes no arguments) to display messages or otherwise react.

In a plugin you can use a plugin callback to do a similar thing.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


11,486 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]