1. You can't
local string.format = string.format
directly, you would need a local "string" table to assign the functions to (a bit self defeating):
Code:
local string = {
format = string.format,
}
but you can lessen your typing depending on preference .
Code:
local format = string.format
2.
Lua Code:
if event == "PLAYER_LOGIN" then
if not MYADDON_CFG then -- doesn't exist so add defaults
MYADDON_CFG = {
KEY1 = true,
KEY2 = "var2",
KEY3 = 3,
}
end
end
PLAYER_LOGIN only fires once after all addons have loaded including their saved variables. The game knows most things about the character loading that don't requiring a server request at this point.