WoWInterface - View Single Post - upvalue functions and default key values of an array
View Single Post
04-06-20, 09:14 AM   #2
I did that?
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,236
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):
local string = {
	format = string.format,
but you can lessen your typing depending on preference .

local format = string.format
Lua Code:
  1. if event == "PLAYER_LOGIN" then
  2.     if not MYADDON_CFG then -- doesn't exist so add defaults
  3.         MYADDON_CFG = {
  4.             KEY1 = true,
  5.             KEY2 = "var2",
  6.             KEY3 = 3,
  7.         }
  8.     end
  9. 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.
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 04-06-20 at 09:51 AM.
  Reply With Quote