1. I'm trying to get my addon, VGC, to work with variables. There are two of them. One is called VGCHEALTH, and the other is VGCMANA.

    I can set them no problem using

    /script VGC_HEALTH=X

    or

    /script VGC_MANA=X

    They work as I want them to, but it's saving them that's the problem. I thought custom variables were saved automatically on logout, but WoWWiki tells me that I need to load them manually.

    This is the code I am using to load them:

     local hpandmp = CreateFrame("Frame")
     hpandmp:RegisterEvent("ADDON_LOADED")
    
     function hpandmp:OnEvent(event, arg1)
        if event == "ADDON_LOADED" and arg1 == "VGComms" then
            -- If this is the users first time, set the variables to nil.
            if VGC_HEALTH == nil and VGC_MANA == nil then
                -- Set default values and print a message saying that this has been done.
                    VCG_HEALTH = 30;
                VGC_MANA = 50;
                DEFAULT_CHAT_FRAME:AddMessage("|cFF00FF00[VGComms]|r Default health and mana cutoffs set to 30% and 50% respecively.")
            end
        end
     end
    

    In my VGComms.toc file, I also have:

     ##SavedVariablesPerCharacter: VGC_MANA
     ##SavedVariablesPerCharacter: VGC_HEALTH
    

    I'm following the instructions on WoWWiki as best I can, but every time I reload my UI, they aren't loaded, and I have to resort to the /script command again.

    What am I doing wrong? It's probably something really simple, too.

    Thanks again for your help.

    They work as I want them to, but it's saving them that's the problem. I thought custom variables were saved automatically on logout, but WoWWiki tells me that I need to load them manually.

    No, there's a few places in the book where saved variables come up, but certainly nothing is done automatically.

    This is the code I am using to load them:

     local hpandmp = CreateFrame("Frame")
     hpandmp:RegisterEvent("ADDON_LOADED")
    
     function hpandmp:OnEvent(event, arg1)
      if event == "ADDON_LOADED" and arg1 == "VGComms" then
          -- If this is the users first time, set the variables to nil.
              if VGC_HEALTH == nil and VGC_MANA == nil then
              -- Set default values and print a message saying that this has been done.
                  VCG_HEALTH = 30;
              VGC_MANA = 50;
              DEFAULT_CHAT_FRAME:AddMessage("|cFF00FF00[VGComms]|r Default health and mana cutoffs set to 30% and 50% respecively.")
          end
      end
     end
    

    In my VGComms.toc file, I also have:

     ##SavedVariablesPerCharacter: VGC_MANA
     ##SavedVariablesPerCharacter: VGC_HEALTH
    

    You don't want two different lines. You want:

     ##SavedVariablesPerCharacter: VGC_MANA, VGC_HEALTH
    

    I'm following the instructions on WoWWiki as best I can, but every time I reload my UI, they aren't loaded, and I have to resort to the /script command again.

    What am I doing wrong? It's probably something really simple, too.

    Which edition of the book do you have? I can point you to where this is discussed.

    No, there's a few places in the book where saved variables come up, but certainly nothing is done automatically.

    http://www.wowwiki.com/Saving_variables_between_game_sessions says: The client saves variables to disk automatically when you log out, disconnect, quit the game, or reload your user interface (/run ReloadUI()).

    Also, I haven't got a copy of the book.

    No, there's a few places in the book where saved variables come up, but certainly nothing is done automatically.

    http://www.wowwiki.com/Saving_variables_between_game_sessions says: The client saves variables to disk automatically when you log out, disconnect, quit the game, or reload your user interface (/run ReloadUI()).

    Yes, and none of that is automatic. You need to specify what variables need to be saved and then manage when they're loaded by the game.. hence the code you've had to write.

    Also, I haven't got a copy of the book.

    Alright... well this forum is for the readers of the book. There are a number of other forums that you could use to get help with writing addons for World of Warcraft. I'm not opposed to giving you help, but you have to understand I've already written 1400+ pages about this very topic and it's not a very good use of my time to simply repeat the same things over and over again.