Thread Tools Display Modes
08/20/15, 11:49 AM   #1
domintheus
Join Date: Aug 2015
Posts: 8
Question Addon connect to external database?

Preface
  • I've seen some threads in regards to global auction houses, yet that's not the purpose for the addon I'm working on.
  • I understand the ui would need reloaded to get updates, I am fine with that. The target group of people are fine with that.
  • There won't be a very large number of people using the addon, so this shouldn't be a problem.
  • This isn't a question of should I do this, it is a question of how to do this.


The goal is to have an addon that can get data from an external database and display it ingame, have a field for text entry and be able to save the data to be posted via ui reload. The database connection will be set up in PHP, obviously it's not a good idea to put database usernames/passwords in the .lua files for all to find. Hopefully this will open up new possibilities for future addons from all creators.


Does anyone know how to connect to an external resource, specifically a database, webpage, or even an image on a website, with an addon in ESO?

Last edited by domintheus : 08/20/15 at 11:55 AM.
  Reply With Quote
08/20/15, 11:55 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
The only possibility would be to:

-Create an external tool which connects to the database, reads some information and saves the DB data into the SavedVariables lua file of an addon
-Reloadui ingame and activate the addon before
-The addon is able to use the data from its own SavedVariables then (which came from the DB)

Same thing the other way around if you like to update data from the SavedVariables to the database:
-Update information
-Reloadui
-External tool read the SavedVariables lua file and updates it into a database
  Reply With Quote
08/20/15, 02:08 PM   #3
domintheus
Join Date: Aug 2015
Posts: 8
Thanks! Would it be possible for you to provide an example of this?

I feel not only would it help me, but it would also help many others who may be seeking to do something similar.

**EDIT**

I apologize if my request seems to be too forward, but I'm very eager to figure this out and any additional help would be highly appreciated as my fingers need a break after making the API on the wiki a little more convenient to navigate:

http://wiki.esoui.com/w/index.php?ti...action=history

Last edited by domintheus : 08/20/15 at 02:13 PM. Reason: Felt too forward in my request.
  Reply With Quote
08/20/15, 03:35 PM   #4
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
What kind of example do you want to see for this?
I'm not able to actually write an addon for it :-)

Here is an example tutorial abou the SavedVariables:
http://wiki.esoui.com/Circonians_Sav...ables_Tutorial

Maybe it helps you to understand the addons and how they save the data to the harddisk.

If you just take a look at the SavedVariables folder (one folder above your "Addons" folder) on your local harddrive, you'll find the stored lua files for the different addons.
The path should be something like:
Code:
C:\Users\<your windows user name>\Documents\Elder Scrolls Online\live(eu)
The structure of the SavedVariables lua files look like this:
Code:
Addon_SavedVariables_Name =
{
    ["Default"] =
    {
        ["@AccountName"] =
        {
            ["CharacterName1"] =
            {
                ["variableName"] =
                {
                    ["value1"] = 1,
                    ["value2"] = true,
                    ["value3"] = {
                    	"1" = 1,
                        "2" = true,
                        "3" = "Hello"
                    },
                },
            },
            ["CharacterName2"] =
            {
                ["variableName"] =
                {
                    ["value1"] = 12,
                    ["value2"] = false,
                },
            }
            ["$AccountWide"] =
            {
                ["variableName"] =
                {
                    ["value1"] = -1,
                    ["value2"] = "Hello World",
                },
            }
        }
    }
}
The "Addon_SavedVariables_Name" can be any string as a description which addon' saved variables this table contains. It's sepcified inside the according addon as you can see in the tutorial above.

The "default" table entry is the default branch to follow.

@AccountName is a placeholder for the @account ingame where these settings are stored for.
Below the @AccountName there can be different "CharacterNames" if you store the settings differently for each of your characters, or a variable "$AccountWide" which will contain the settings for ALL your characters.
Settings for all characters AND for each character can be combined, so there mustn't be just either each character or all characters.
Example: Positions of windows will be stored differently for each character, but the content will be stored the same for all characters.


The data saved will be stored as different types.
Either boolean, integer, String, array, mixture of all, etc like shown in the example structure above.



You'd need some tool where you specify the SavedVariables .lua filename to read from, parse the structure of this lua file and use the information gained to upload it to a database somewhere.

Same way for writing to the SavedVariables file.
But: If you write to the SavedVariables file and the game client is running at this moment, all written data to the SavedVariables will be overwritten by the current game values if the user logouts/closes the game/does an /reloadui ingame AFTER you wrote to the file.
  Reply With Quote
08/20/15, 06:12 PM   #5
domintheus
Join Date: Aug 2015
Posts: 8
Very helpful. Thanks.

I should have been more specific, I apologize. I was getting a little hungry after spending all day on the wiki, should have had a snickers with me.

I was more curious about how one would go about making an external tool for connecting to a webserver. I understand PHP and can set up a page to translate sent data and do all the processing on the webserver side. I am just a little undereducated on the LUA side. If anyone could help bring some insight to this, it would be greatly appreciated.

Once figured out I will go back and edit the initial post in this thread with an example on how to make a simple addon send data to a webserver, and an example on what a php page should be set up like to retrieve it.
  Reply With Quote
08/20/15, 06:38 PM   #6
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
depends what you're going to do, what's your project? (i'm currently working on same thing, but a way bigger).
  Reply With Quote

ESOUI » AddOns » AddOn Help/Support » Addon connect to external database?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off