Lua loading & saving data into dictionary?

just started today looking at writing a wow addon, been reading pages and browsing examples. A big part of my addon will require loading some data and storing that data if it changes.

I want to load data into a dictionary or map and this map would contain dictionaries as well as values. so something like: {id1=dict1, id2=dict2, id_n=dict_n}

and dict1,dict2,dictn would look like

{ id1, “some text”}
{ id2, “some other text”}
{ idn, “some other text n”}

using Lua how can I store and read something like this from a file? anyone have an example I can reference?

You can include fixed information as tables in your addon to be loaded when it loads.

The only mechanism for writing to a file is via the SavedVariables. You specify in your .toc that you want to use SavedVariable(s) which are loaded into memory after your addon loads and written out (including changes) after you character exits, logs out or reloads the UI.

SavedVariables can be either “global” (saved in one place) or “per character” (saved under each characters settings and loads only with that character). These are all under the WTF folder.

local dict1 = { [1]=“some text”, [2]="more text" }
local dict2 = { [1]=“some other text”, [2]="Yada Yada" }
local dict_n = { idn=“some other text n” }
local dictList = { id1=dict1, id2=dict2, id_n=dict_n }

How you store (format) the information depends on how you want to use it.

hey thanks again :slight_smile: