You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-2Lines changed: 9 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,6 +52,9 @@ existingCreature:Load(123) -- Load data of entry with guid = 123 (guid is the pr
52
52
-- Way 2
53
53
localexistingCreature=DbCreature():Load(123)
54
54
55
+
-- You can now access the columns like a normal Lua table. Attribute names are always the same as the column names in the table (case sensitive!).
56
+
print(existingCreature.map) -- Prints the map id of the loaded creature
57
+
55
58
-- Load entry with combined primary keys
56
59
localexistingPlayerCreateInfo=DbPlayercreateinfo():Load(1, 4) -- Table playercreateinfo has a combined primary key based on column race and class. The order will always be the same as in the database which means we're loading the entry with race = 1 AND class = 4
I only tested it on AzerothCore and TrinityCore, but it should work on all emulators supported by Eluna.
78
+
73
79
### What can i do when i see errors in my world server console?
74
80
Set `DbScriptExtensions_PrintQueries = true` in your file `lua_scripts/extensions/DbScriptExtensions/DbScriptExtensions.ext`. Now restart the world server. It should show all DbScriptExtensions SQL queries that it tries to run. Now you can open up an issue on the GitHub repository with the query it tried to execute and a snippet of your code that leads to this error. Make sure to mention which emulator you're using.
75
81
@@ -86,14 +92,15 @@ Yes. After adding a new table to your world database, just regenerate the table
86
92
The mapping is done in the file `lua_scripts\extensions\DbScriptExtensions\Mapping\DbScriptExtensions_Mappings.ext`. You can find all class names in there.
87
93
88
94
### Are there any attributes that could help me to create objects in a generic way?
89
-
There are several internal helper attributes that you can use.
95
+
There are several internal helper attributes that you can use. Also check the Queryable class for functions that you could call.
96
+
Example of internal helper attributes:
90
97
```lua
91
98
localcreature=DbCreature():Load(123)
92
99
localguid=creature.__columns["guid"] -- Access column directly by name, same value as creature.guid
93
100
localguidColumnId=creature.__columnIds["guid"] -- Will return 0 because guid is the first column in the table creature (it's 0 based because the ElunaQuery functions are 0 based. Lua is usually 1 based)
94
101
localguidColumnName=creature.__columnById[guidColumnId] -- Will return "guid" because column 1 is guid as seen in the line above
95
102
localamountOfColumns=creature.__columnIdCounter-- Will return 24 because the table creature has 24 columns
96
-
localelunaReadColumnFunction=self.__columnFunctions["guid"] -- Will return function ElunaQuery:GetUInt32 because this is the function to read the value out of an query object. Use like this: elunaReadColumnFunction(query)
103
+
localelunaReadColumnFunction=creature.__columnFunctions["guid"] -- Will return function ElunaQuery:GetUInt32 because this is the function to read the value out of an query object. Use like this: elunaReadColumnFunction(query, columnId)
97
104
localqueryObject=WorldDBQuery("SELECT * FROM creature WHERE guid = 123")
98
105
if (queryObject) then
99
106
localguid=elunaReadColumnFunction(queryObject, guidColumnId) -- Will return 123
0 commit comments