Jump to content


  • Content Count

  • Donations

    0.00 GBP 
  • Joined

  • Last visited

  • Days Won


xardion last won the day on July 6 2017

xardion had the most liked content!

Community Reputation

3 Neutral

About xardion

  • Rank
  1. I mostly just threw this out as a "it's possible to do this if you need it" because I had done it for my own purposes (IRC bridge). I haven't touched it in months, mainly because I haven't had time and it works for what I needed it for. My suggestion is to just spin up a Linux VM (VirtualBox is free and works perfectly) and test it with that. That said, if you can't do that, feel free to shoot me what you have and I'll take a look when I can.
  2. Eluna IRC Bridge Have you ever wanted to bridge your in-game guild chat with an IRC channel? If so, you're in luck, because that's exactly what this script does. It allows your Eluna-enabled server to connect to a single IRC server, and bridge chat between specific channels and guild chats. PREREQUISITES: Your Eluna-enabled server must have LuaSocket support either compiled-in or available for dynamic loading. Instructions for that can be found here. You will also need to have LuaIRC installed in your Lua library path (NOT the script path) for Eluna. If your IRC server requires SSL, you will also need LuaSec compiled into your Lua engine. However, this is beyond the scope of this release, as LuaSec isn't compatible with the newest version of LuaSocket that I detail in the other post, and has its own version bundled with it. Attempt this at your own risk. INSTRUCTIONS The code can be found here. The SQL needs to be run against your characters db, in order to create the necessary tables for the bot to operate, and the Lua script should be dropped into your Eluna script path. The patch file needs to be applied to LuaIRC after you've put it in your library path. It adds a couple new hooks required by the bot. The package.path at the top of the script assumes that you have created a lua_lib directory in your server bin path to contain your LuaSocket and LuaIRC files. Change this as necessary. After doing this, you will need to create the necessary entries in the tables for your bridge. The tables are fairly self-explanatory, but some fields require elaboration: irc_config table: The nick, username, and realname fields are used by the bot when connecting (username and realname are just for whois purposes), as are the host, port, secure, and password fields. The password is not required, and do NOT set secure unless you have LuaSec. The connect_modes field contains the modes that the IRC server sets on users after connecting. This is used by the bot to detect when the user has fully connected UNLESS NickServ is being used. Then this field is ignored. The add_modes and rem_modes are the list of user modes that the bot will add and remove from itself after connecting. The nickserv field contains the name of the NickServ service (defaults to NickServ), and the nickserv_password contains the password for the nick used by the bot. This should be left NULL if NickServ isn't being used. There should only be one row in this table, as the bot currently only supports connecting to a single IRC server. irc_prefixes table: This table is used to define specific prefixes to use when sending IRC messages from specific nicknames, instead of just using the nickname. This is typically for other bots in the channels, and is also used to override the default prefix. The nick field contains the nickname the prefix applies to. Leaving this defaulted to an empty string is how you override the default prefix (IRC) and color (11 - light cyan). The prefix contains the prefix text itself, and the color field contains the mIRC color code (0 to 15) to use for the prefix. irc_channels table: This table contains the mappings of which IRC channel is used for a given in-game Guild chat (if any). The guildid contains the internal Guild ID of the guild being mapped, and the channel is the name of the IRC channel.
  3. This isn't that trivial to implement. You would need to keep track of every PvP kill on your server made per player, possibly clearing their kill count if they kill someone else. Also, you may need to clear it out if that player logs out, or possibly keep a timestamp with each kill. It depends on what your definition of "in a row" means.
  4. Unless you've modified your core, the Eluna integration for Trinity doesn't yet fire the BG events. It that's what you meant by "implemented the OnBattlegroundEnd hook myself", so be it. When your code calls OnBGEnd, it should be passing the instance ID, and the winner as the last two params. The issue you're going to run into with winner is that Eluna defines that as a Team, when really (at least for Trinity), it should be a TeamId or a BattlegroundTeamId, as those map directly to Eluna's TeamId (Alliance = 0, Horde = 1, Neutral = 2). The Team enum defines Alliance as 469, and Horde as 67. You'll have to manually map those to the team IDs used by GetPlayersInMap.
  5. I don't think you're going to see a more specific or straightforward error message than this, ever. It's telling you that the call to SendNotification on line 10 has a bad argument, that it is nil, when it expects a string. The argument there is the variable named 'message', which isn't defined anywhere in this script, hence the reason you're getting this error.
  6. xardion

    Lua problem

    I recommend checking out the Eluna API Documentation. Do a search for gossip, you'll find what you need. Pretty much all of your function calls are going to change, because Eluna is substantially different from arcemu's Lua engine.
  7. DISCLAIMER: For reasons of stability and security, adding socket support to the Eluna engine is not recommended. If that does not deter you, by all means proceed. This started for me when I wanted to set up an IRC bridge, but there are plenty of other reasons why you may want or need to open a socket in a Lua script. Obviously, just installing LuaSocket through the usual means (downloading the source & make install, luarocks, etc) isn't going to work because those approaches are intended for a system install of Lua. Eluna has its own built-in Lua engine, so LuaSocket has to be installed with that in mind. Additionally, LuaSocket has native components written in C, so just adding the library paths to the package.path will likely be insufficient, with one caveat: if your MaNGOS/cMaNGOS/Trinty server is built with dynamic script support, you may actually be able to do exactly that. However, I didn't test this, so I'm not certain of its efficacy. These instructions assume that you're compiling with statically built scripts, with no dynamic library loading support. If your core is compiled with dynamic library support and you want to try that approach, skip to STEP 4 (specifically where it mentions dynamic library support in bold) after installing LuaSocket on your server (build it against Lua 5.2 if you do this). I did this with ElunaTrinityWotlk and LuaSocket 3.0rc1 on Linux, you'll have to modify this if you're on Windows or OS X, or if you want to use the latest LuaSocket master as the module names have changed slightly, and additional ones have been added. YMMV on cMaNGOS and MaNGOS, but as they all use cmake, it should work with them as well. If you aren't using your own fork of the appropriate (cMaNGOS/MaNGOS/Trinity)+Eluna codebase, or at the very least using your own branch, you should do this before proceeding. This will involve making code changes to the lualib in the core, and keeping up with updates after doing this will be difficult if you aren't using your own fork or branch. STEP 1: Copy the C source and header files (src/*.[ch]) from LuaSocket into the dep/lualib directory in your server source root, and then remove the inappropriate platform specific files: wsocket.[ch] if you're on Linux/OSX (since these files are for Windows), usocket.[ch] for Windows. You COULD alter the next step to be platform-aware instead, but this seems like overkill. STEP 2: Add the following lines to the bottom of dep/lualib/CMakeLists.txt: add_definitions(-DLUASOCKET_NODEBUG) add_definitions(-DLUA_COMPAT_MODULE) add_definitions(-DLUA_USE_POSIX) add_definitions(-DLUASOCKET_API='__attribute__\(\(visibility\(\"default\"\)\)\)') add_definitions(-DUNIX_API='__attribute__\(\(visibility\(\"default\"\)\)\)') add_definitions(-DMIME_API='__attribute__\(\(visibility\(\"default\"\)\)\)') This is Linux specific, OS X and Windows require different definitions here. You can glean these from the LuaSocket Makefiles. STEP 3: Apply the following patch at the root of your source tree (it only changes dep/lualib/linit.c): diff --git a/dep/lualib/linit.c b/dep/lualib/linit.c index c1a3830..12e6c1e 100644 --- a/dep/lualib/linit.c +++ b/dep/lualib/linit.c @@ -20,6 +20,8 @@ #include "lualib.h" #include "lauxlib.h" +#include "mime.h" +#include "luasocket.h" /* @@ -45,6 +47,8 @@ static const luaL_Reg loadedlibs[] = { ** these libs are preloaded and must be required before used */ static const luaL_Reg preloadedlibs[] = { + {"mime.core", luaopen_mime_core}, + {"socket.core", luaopen_socket_core}, {NULL, NULL} }; You'll probably need to apply this using patch -p1 , or you could make the changes by hand. It's just adding 4 lines. STEP 3: Build your server. STEP 4: Create a .lib directory in your Eluna.ScriptPath (on Windows you'll also want to set the hidden attribute) if you want to keep all of your Lua code and libraries in the script path. Eluna doesn't automatically load scripts in hidden directories. Or, you could use a path external to your script path. Your choice. Either way, you'll need to copy the .lua files from the LuaSocket source into this directory, with socket.lua, mime.lua, and ltn12.lua the directory itself, and all of the other .lua files in a socket subdirectory within the library directory you used. Again, this will be slightly different if you're using the LuaSocket master branch instead of 3.0rc1, and you'll need to look at the Makefile to see how to place those files. In either case, any Lua scripts that need to use LuaSocket will have to have their path modified before doing a require("socket"). Add the following to the top of the script: package.path = package.path .. ';lua_scripts/.lib/?.lua;lua_scripts/.lib/?/init.lua' Change lua_scripts/.lib if appropriate. If you installed LuaSocket on your system and are using a core with dynamic library support, you'll want to use this instead: package.path = package.path .. ';/usr/local/share/lua/5.2/?.lua;/usr/local/share/lua/5.2/?/init.lua;/usr/local/lib/lua/5.2/?.lua;/usr/local/lib/lua/5.2/?/init.lua' This assumes you're on Linux or OS X and are using the default prefix. If you're on Windows, or you're using a different prefix, these paths will obviously be different. Modifying the package.path in this fashion will also allow you to use other Lua libraries without putting them in your Eluna.ScriptPath. This is desirable when using libraries that assume a specific require order and throw errors when Eluna tries to autoload every Lua file it finds in the Elnua.ScriptPath.
  8. xardion


    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).
  9. xardion


    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
  10. xardion


    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.
  11. xardion


    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.

Contact Us

To contact us click here
You can also email us at [email protected]

Privacy Policy | Terms & Conditions


The Link to the master list
of MaNGOS repositories:
Copyright © getMaNGOS. All rights Reserved.

This website is in no way associated with or endorsed by Blizzard Entertainment®
  • 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