Hey!
I'd like to make an addon that autokicks warband members who aren't in a discord voice channel - similar to the way Autoband kicks you if you're too far away from the leader for too long.
This will obviously need a Discord bot/api client for which there is a lua library, but the library needs luvit which I imagine is not possible to use with addons.
With this in mind I have already written a small discord api client in Java (my day job language) which can fetch the voice channel members from a server which has the bot installed. My next steps depend on the capabilities of the addons in RoR. I'm hoping someone here can give me a bit more information about them.
My two ideas for going forward are:
1) My preferred idea is to build a small web server which acts as the Discord api client - the addon would then make a request to the server every 5-10 secs to get the list of channel members. This of course requires addons to be able to call external web services... can they?
2) If this isn't possible, I could create a stand alone app that runs on the user's local machine and writes the voice channel members to a file which the addon then reads. Presumably addons can read files on the local machine.
Any help/advice would be really appreciated. You can also @Ogi in game, or @Ogi#6088 on Discord.
Cheers!
Addon Idea - looking for info/advice from developers
Forum rules
Before posting on this forum, be sure to read the Terms of Use
Before posting on this forum, be sure to read the Terms of Use
Ads
Re: Addon Idea - looking for info/advice from developers
Hello there, I think i can answer a few of these questions;M4RXman wrote: ↑Thu Mar 30, 2023 9:14 am Hey!
I'd like to make an addon that autokicks warband members who aren't in a discord voice channel - similar to the way Autoband kicks you if you're too far away from the leader for too long.
This will obviously need a Discord bot/api client for which there is a lua library, but the library needs luvit which I imagine is not possible to use with addons.
With this in mind I have already written a small discord api client in Java (my day job language) which can fetch the voice channel members from a server which has the bot installed. My next steps depend on the capabilities of the addons in RoR. I'm hoping someone here can give me a bit more information about them.
My two ideas for going forward are:
1) My preferred idea is to build a small web server which acts as the Discord api client - the addon would then make a request to the server every 5-10 secs to get the list of channel members. This of course requires addons to be able to call external web services... can they?
2) If this isn't possible, I could create a stand alone app that runs on the user's local machine and writes the voice channel members to a file which the addon then reads. Presumably addons can read files on the local machine.
Any help/advice would be really appreciated. You can also @Ogi in game, or @Ogi#6088 on Discord.
Cheers!
First off: The war API is extremly limited on how it can interact with sources outside the client; Basicly more or less limited to writing/reading to a logfile
(and even this is very iffy, example: trying to read an empty logfile will crash the client),
Possible to do? Probably, with some effort and out of the box thinking, like having the java program you mention checking for a logfile update made by the war api, then fetch the discord name list, write it to another logfile (with the names taken from the discord list) that the war clients read back and do the appropriate action
This will also imply that the discord name is the same as the playername ingame
![Image](http://i.imgur.com/JHEWZtj.png)
![Image](http://www.imgur.com/NRMfhcw.png)
![Image](http://www.imgur.com/bNZ07eK.png)
![Image](http://www.imgur.com/tIC67lR.png)
![Image](http://www.imgur.com/IJ4uOdV.png)
![Image](http://www.imgur.com/ashZHS3.png)
![Image](http://www.imgur.com/zyJWzF0.png)
Re: Addon Idea - looking for info/advice from developers
Thanks for the quick reply!
I was worried that might be the case. I definitely still want to give it a try though. I had thought of mismatching names but as long as either the user's name or nickname on the server matches their in-game name, it shouldn't be an issue.
So in that case I'll probably make a stand alone Java app with a gui where the user enters serverId, channel name and install directory before running in the background and writing the log file which the war API can read when it needs to. Based on what you've said it NEEDS to write something to the log before the client tried to read it. Does the client crash when it tries to read a non-existant logfile, an empty logfile or both?
I also need to check if Discord allows multiple connections from different ips to the same bot...
Where are the log files stored please?
I was worried that might be the case. I definitely still want to give it a try though. I had thought of mismatching names but as long as either the user's name or nickname on the server matches their in-game name, it shouldn't be an issue.
So in that case I'll probably make a stand alone Java app with a gui where the user enters serverId, channel name and install directory before running in the background and writing the log file which the war API can read when it needs to. Based on what you've said it NEEDS to write something to the log before the client tried to read it. Does the client crash when it tries to read a non-existant logfile, an empty logfile or both?
I also need to check if Discord allows multiple connections from different ips to the same bot...
Where are the log files stored please?
Re: Addon Idea - looking for info/advice from developers
a trick you can do is before reading the file in war you can increment it throu the war api with some junk chars that you then ignore when reading it back so it's not empty.
the logs is usually stored in
"Warhammer Online - Age of Reckoning\logs"
the logs is usually stored in
"Warhammer Online - Age of Reckoning\logs"
![Image](http://i.imgur.com/JHEWZtj.png)
![Image](http://www.imgur.com/NRMfhcw.png)
![Image](http://www.imgur.com/bNZ07eK.png)
![Image](http://www.imgur.com/tIC67lR.png)
![Image](http://www.imgur.com/IJ4uOdV.png)
![Image](http://www.imgur.com/ashZHS3.png)
![Image](http://www.imgur.com/zyJWzF0.png)
Re: Addon Idea - looking for info/advice from developers
Rather than absuing log files you can just write the data from the Discord server to a CSV file (how you get and write that data is down to you), and the client has built-in functionality to read CSV files and convert them into LUA tables. The main rules for the CSV files are:
1) The first row of the CSV file is ignored
2) The second row of the CSV file is used for the column header names and map to key names in a LUA table
3) The values (except for the header names) in the first column must be numeric, but they do not need to be contiguous. I do not know if it accepts floating point values but integers are fine. The value of the first column is used as a key for a sub-table (each sub-table is one row), and the other columns in that row are keys in the subtable.
The CSV loading function (BuildTableFromCSV) loads the data into a table specified by name. If that table already has data then the new data is added to the existing table's data which can be useful to incrementally update the table with new or amended fields with repeated calls to BuildTableFromCSV, either with the same filename (with the contents having been modified by your Discord bot thing), or a new filename.
It's also resiliant and handles locked files as well. If you try to tell it to load a file but that file is already open and locked because your Discord bot thing is writing new data to it then BuildTableFromCSV just fails and keeps the existing table data as-is.
The only annoyings about BuildTableFromCSV are:
1) You have to specify the CSV file name via a path relative to the game EXE file so if the user puts your addon in a weird folder name then it won't work. There are ways of working out the folder the addon is installed in but none are intuitive (generate an error and parse it to work out the path of the file which generated the error, and then from that work out the add-on folder). For the PocketPallete addon (which uses CSVs) I just put a giant disclaimer on it saying if the addon folder it not named "PocketPallete" and is not in the main addons folder then it won't work and that's your fault.
2) It is NOT asynchronous. Nothing about the resource loading of the UI appears to be asynchronous, especially loading CSV files. If you use it to load huge amounts of data then the client might microstutter for that frame so try to keep your data compact. If the file was recently written to by your Discord bot then a copy should also be in the Window's file cache in memory which will eliminate any disk-to-memory stutters at least.
I made you a very simple test add-on should get you started. Put it in a folder named "ReloadCSV"
. It dumps the contents of the loaded tables to the debug window. The "warTerminal" addon is a must-have for addon devs and provides a much better debug window as well. It can be found here and can be accessed by "/d" in chat: viewtopic.php?t=44982&start=10
Get the addon here: https://filebin.net/iu8jfcukqufvdnb1/ReloadCSV.zip (the link expires in 6 days, this is the first result on Google for free file hosting).
edit: read the LUA file for instructions and more notes
1) The first row of the CSV file is ignored
2) The second row of the CSV file is used for the column header names and map to key names in a LUA table
3) The values (except for the header names) in the first column must be numeric, but they do not need to be contiguous. I do not know if it accepts floating point values but integers are fine. The value of the first column is used as a key for a sub-table (each sub-table is one row), and the other columns in that row are keys in the subtable.
The CSV loading function (BuildTableFromCSV) loads the data into a table specified by name. If that table already has data then the new data is added to the existing table's data which can be useful to incrementally update the table with new or amended fields with repeated calls to BuildTableFromCSV, either with the same filename (with the contents having been modified by your Discord bot thing), or a new filename.
It's also resiliant and handles locked files as well. If you try to tell it to load a file but that file is already open and locked because your Discord bot thing is writing new data to it then BuildTableFromCSV just fails and keeps the existing table data as-is.
The only annoyings about BuildTableFromCSV are:
1) You have to specify the CSV file name via a path relative to the game EXE file so if the user puts your addon in a weird folder name then it won't work. There are ways of working out the folder the addon is installed in but none are intuitive (generate an error and parse it to work out the path of the file which generated the error, and then from that work out the add-on folder). For the PocketPallete addon (which uses CSVs) I just put a giant disclaimer on it saying if the addon folder it not named "PocketPallete" and is not in the main addons folder then it won't work and that's your fault.
2) It is NOT asynchronous. Nothing about the resource loading of the UI appears to be asynchronous, especially loading CSV files. If you use it to load huge amounts of data then the client might microstutter for that frame so try to keep your data compact. If the file was recently written to by your Discord bot then a copy should also be in the Window's file cache in memory which will eliminate any disk-to-memory stutters at least.
I made you a very simple test add-on should get you started. Put it in a folder named "ReloadCSV"
![Razz :P](./images/smilies/icon_razz.gif)
Get the addon here: https://filebin.net/iu8jfcukqufvdnb1/ReloadCSV.zip (the link expires in 6 days, this is the first result on Google for free file hosting).
edit: read the LUA file for instructions and more notes
Zomega: RR8x Zealot
Re: Addon Idea - looking for info/advice from developers
Thanks so much for the help! I'll definitely have a look at the test add-on you've written ASAP.
I've finished the Discord client, which I'll run on my own server to (a) protect the access tokens for the bot, (b) more easilydebug if anything goes wrong with the calls to the Discord API.
Next is the client which runs on the users local machine. I'll make sure to write it's output as a CSV![Cool 8-)](./images/smilies/icon_cool.gif)
I've finished the Discord client, which I'll run on my own server to (a) protect the access tokens for the bot, (b) more easilydebug if anything goes wrong with the calls to the Discord API.
Next is the client which runs on the users local machine. I'll make sure to write it's output as a CSV
![Cool 8-)](./images/smilies/icon_cool.gif)
Who is online
Users browsing this forum: No registered users and 72 guests