1. #1
    Deleted

    Question [Lua] Saved Variables Being Overwritten

    I'm trying to store a list of variables which will be consistent throughout sessions using saved variables, at the minute it only seems to overwrite one table (still a bit new to this so sorry if I get terminology wrong or something).

    Say I add myself to the table I will get this:
    Code:
    RolesDB = {
    	["Dumbfoundead"] = {
    		["Main"] = "Dumbfoundead",
    		["Roles"] = "Tank/Healer",
    	},
    }

    but then I add a guildy to the table it will override the field for myself with something like:
    Code:
    RolesDB = {
    	["Guildyman"] = {
    		["Main"] = "Guildymansmain",
    		["Roles"] = "DPS/Healer",
    	},
    }

    The code I'm currently using to do this is:
    Code:
    RolesDB[playerName:GetText()] = { ["Main"] = mainName:GetText(), ["Roles"] = playerRoles:GetText()}


    There's also another problem, I would like to cross check what's in a text box with the table to display the properties inside it. Say I want to find out someone's main by entering their character name in the textbox, pressing a button and having their mains name pop up. I simply don't have a clue how I'd go about searching through the table to do it

    Thanks for reading!

  2. #2
    Deleted
    SavedVariables should not be changed before the ADDON_LOADED event fires with arg1 being your addon's folder name. Make sure you're not doing
    Code:
    RolesDB = RolesDB or {}
    (or similar) during the loading process.

    For the lookup part, you can simply:
    Code:
    print(("Main is: %s"):format(RolesDB[editBox:GetText()].Main))

  3. #3
    Deleted
    Thanks for the response, if there are any problems I will get back to you <3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •