This site works best with JavaScript enabled. Please enable JavaScript to get the best experience from this site.
Quote from "blankStare3" »what am I doing wrong? I have two statments (if memory serves): self:db:set("spell", 1, "Heal") self:db:set("spell", 2, "Regrowth") I do 2 /console reloadui to make sure it gets out to the savedvariables. What I see in the saved var file is just "spell" and a 2, with no text.
your_db = { ["spell"] = { [1] = "Heal", [2] = "Regrowth", }, }
self:db:set({"spell"}, 1, "Heal") self:db:set({"spell"}, 2, "Regrowth")
1) set(key, value) 2) set(path, key, value)
self.db:set("spell","Heal") self.db:set("spell","Regrowth")
for k,v in ipairs(self.db:get("spell")) do ace:print("Key: "..k.." Value: "..v) end
Quote from LordRhys » What if I wanted to build something like: TestItems = { ["Mithril Ore"] = { ["inv"] = 0, ["bank"] = 0, ["mail"] = 0, }, ["Silver Ore"] = { ["inv"] = 0, ["bank"] = 0, ["mail"] = 0, }, etc... } would I use self.db:set("Mithril Ore","inv",0) self.db:set("Mithril Ore","bank",0) self.db:set("Mithril Ore","mail",0) self.db:set("Silver Ore","inv",0) self.db:set("Silver Ore","bank",0) self.db:set("Silver Ore","mail",0) etc...
I have two statments (if memory serves):
self:db:set("spell", 1, "Heal")
self:db:set("spell", 2, "Regrowth")
I do 2 /console reloadui to make sure it gets out to the savedvariables. What I see in the saved var file is just "spell" and a 2, with no text.
What are you trying to do here? If you are trying to create this:
Then the syntax that I think you want is this:
This is because self:db:set() can be called in two ways:
If the first parameter is a table then the second form is used otherwise the first form is used and your third parameter is ignored.
(Disclaimer: I got this from looking at the code for AceDatabase:set() and I am new to LUA so I could be wrong - just try it and see 8) )
Steve
You don't have to index your entries yourself with ',1,"Heal" '. Lua does index it for you by using keys (starting from 1).
You only need to:
so, using
the output would be:
Key: 1 Value: Heal
Key: 2 Value: Regrowth
TestItems = {
["Mithril Ore"] = {
["inv"] = 0,
["bank"] = 0,
["mail"] = 0,
},
["Silver Ore"] = {
["inv"] = 0,
["bank"] = 0,
["mail"] = 0,
},
etc...
}
would I use
self.db:set("Mithril Ore","inv",0)
self.db:set("Mithril Ore","bank",0)
self.db:set("Mithril Ore","mail",0)
self.db:set("Silver Ore","inv",0)
self.db:set("Silver Ore","bank",0)
self.db:set("Silver Ore","mail",0)
etc...
self.db:set({"Silver Ore"},"bank",0)
self.db:set({"Silver Ore"},"mail",0) ect