1. Hi, sorry but my english is not very good xD

    I want to share data between users of a same addon, like epgp with the dkps. I have been trying to create a variable to store a value whit the functions GetGloblal and SetGlobal, but the value only change at local way, in another machine that has the addon don't change the value:

     function Frame1_OnLoad() 
      setglobal("MyAddon_MyVar", 0); 
     end 
    
     function MiBoton_OnClick() 
      _G["MyAddon_MyVar"]=_G["MyAddon_MyVar"] +1; 
     end
    

    Also I try another way but is wrong too:

     MyVar = 0; 
     function MyButton_OnClick() 
      MyVar = MyVar +1; 
      MyLabel:SetText(MyVar); 
      SendAddonMessage("MyAddon", MyVar, "GUILD"); 
     end 
    
     function Frame1_OnEvent() 
      if (event == "CHAT_MSG_ADDON") then 
       MyVar=arg2;
       MyLabel:SetText(MyVar);
      end 
     end
    

    Can somebody help me?, I have experience with another OOP languages, but I am a novice with LUA. Thanks.

  2. Hi, sorry but my english is not very good xD

    I want to share data between users of a same addon, like epgp with the dkps. I have been trying to create a variable to store a value whit the functions GetGloblal and SetGlobal, but the value only change at local way, in another machine that has the addon don't change the value:

    Correct. First, you should not be using getglobal and setglobal. They are deprecated functions that aren't really necessary. Secondly, what you want to do is not easy to accomplish. There is no official supported way to share information between multiple users on different computers. The best you can do is store information in the guild note, guild motd, or a calendar event (i.e. something that is guild-shared) or send messages from client to client.

     function Frame1_OnLoad() 
      setglobal("MyAddon_MyVar", 0); 
     end 
     
     function MiBoton_OnClick() 
      _G["MyAddon_MyVar"]=_G["MyAddon_MyVar"] +1; 
     end
    

    Indeed, this won't even persist across sessions. Global variables are just global storage.

    Also I try another way but is wrong too:

     MyVar = 0; 
     function MyButton_OnClick() 
      MyVar = MyVar +1; 
      MyLabel:SetText(MyVar); 
      SendAddonMessage("MyAddon", MyVar, "GUILD"); 
     end 
     
     function Frame1_OnEvent() 
      if (event == "CHAT_MSG_ADDON") then 
       MyVar=arg2;
       MyLabel:SetText(MyVar);
      end 
     end
    

    There's quite a bit wrong here. You can't just have an OnEvent unless you've registered for the OnEvent handler. You also need to register for the CHAT_MSG_ADDON event. Then, you should not be using arg2, you need to instead get the parameter from the event arguments. Otherwise, this approach should work.. but only is good for sending messages from one client to another at the same time. The data won't persist.

    Can somebody help me?, I have experience with another OOP languages, but I am a novice with LUA. Thanks.

    Lua isn't an acronym ;-) It's the Portuguese word for 'Moon', and thus shouldn't be all capitals. I'm not particularly bothered, just letting you know =)

  3. Thanks for your help, it had been very useful to me.

    You have clarified me the setglobal and getglobal use. And yes, I forgot to register the event. And by this way I've done it.

    I didn't know Lua means moon in portuguese, but it's posible cause in spanish is 'Luna' ;) Adeus