Jump to content

Luasocket


xardion

Recommended Posts

So I'm trying to get LuaSocket (3.0rc1) working with Eluna (specifically ElunaTrinityWotlk), and I'm ALMOST there.  I managed to get the luasocket core libraries compiled into lualib statically by dropping the luasocket c and header files right into dep/lualib (except for the wsocket files, I'm on linux), adding the pre-processor directives from the Makefile to dep/lualib/CMakeLists.txt, and modifying linit.c to require the mime.h & luasocket.h headers and adding the libs to loadedlibs[] in that file.  After I got it compiled, I dropped the luasocket lua files into my server's bin/lua_scripts/extensions directory, and everything except socket/http.lua loaded perfectly.  For some reason, I keep getting this when I try to load that: 

lua_scripts/extensions/socket/http.lua:89: attempt to index field 'sourcet' (a nil value)

I also installed LuaSocket on my system in general, to test with the regular lua5.2 install, and it doesn't have this issue.  I'm assuming it's some side-effect of how the engine is automatically loading all scripts it finds in bin/lua_scripts.

Link to comment
Share on other sites

So I figured out the cause, it was because I had added the libs to loadedlibs[] in linit.c, when I should have put them in preloadedlibs[].  Doing this also masked some annoying messages due to how Eluna autoloads, but those are essentially just noise.

Link to comment
Share on other sites

Why not?  I've done it, and it's working just fine.  Implemented an IRC bridge using LuaIRC with Eluna.  There's some obvious caveats with how you have to implement something like this, due to ultimately synchronous nature of how the engine behaves if you aren't using events.  Also, I probably wouldn't do this on a high pop server or with a chatty IRC channel.  Luckily, I'm dealing with a single digit player base :P

Link to comment
Share on other sites

I'd intended to use this instead: https://github.com/TrinityCore/TrinityCore/pull/19491

That isn't ready yet though, and I didn't feel like investing that much time into something that only a few people are going to use. There are also other scenarios where a small script would get the job done in a fraction of the time it would take to write it into the core, if only it could make an external connection. I understand the overall philosophy, it just feels like an arbitrary limitation, especially given the ubiquitous nature of the internet.  I was surprised that Lua itself didn't already have at least optional support for sockets built-in (I can see the need to disable something like that). 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use