• 0

    posted a message on problem with GetBattlefiledscore function
    how are you extracting the name from the battleground message?

    i take it, you've inserted a print command to verify they are the same. i would add a string.length() for each as well just to ensure that there's not some escape code funny business going on.


    yes it was the function to extract the name which had a problem -_-... I use string.len and there are 2 excess spaces...

    so I have to format name from getbattlefieldscore() to have only the name, and then use string.match (because I can't remove the 2 excess spaces I don't know how)

    thank you
    Posted in: Lua Code Discussion
  • 0

    posted a message on problem with GetBattlefiledscore function
    Just an FYI: There's absolutely no reason why anybody needs to dumb down their code. Someone once compared program code to the Matrix. Where laymen see lines of text, we see a picture.


    sorry i only intend to show the problem quickly

    for the "==" I know it won't work because if the player carrying the flag is in another server getbattlefieldscore returns Name-Server but may be I can format to keep only Name I'm going to try thank you
    Posted in: Lua Code Discussion
  • 0

    posted a message on problem with GetBattlefiledscore function
    ok that is the code in the addon :

    if (Ll.CarrierName[1]=="") then
                 Ll.CarrierClass[1] = "";
                 Frame026:Hide();
                 FrameText026:SetText("");                         
                 Frame026:SetAttribute("macrotext",format("/target %s",""));
    else             
                 Frame026:Show();
                 FrameText026:SetText(Ll.CarrierName[1]);             
                 Frame026:SetAttribute("macrotext",format("/target %s",Ll.CarrierName[1]));                                
                 for i=1,GetNumBattlefieldScores() do
                      local Name,_,_,_,_,_,_,_,class = GetBattlefieldScore(i);                                                                   
                      if (strmatch(Name,Ll.CarrierName[1])) then                      
                          FrameText026:SetTextColor(ColorCarrier(class));                         
                      end
                 end                                   
    end


    where Ll is the big table, ColorCarrier is a function which return class color (it seems to work)
    Posted in: Lua Code Discussion
  • 0

    posted a message on problem with GetBattlefiledscore function
    no I have a big table in a file like localisation file, and I put everything in it, for example my table is named "Mytable" and it is loaded when addon load

    when CHAT_MESSAGE_BG_SYSTEM_ALLIANCE event I get flag carrier name and I put it in MyTable.Name[1]

    and I want to do same for the class in MyTable.Class[1]

    I know strmatch can find something else the thing I'm looking for but I don't think it is the problem

    but i'm going to try name == CarrierName

    edit : no name == CarrierName won't work because name is sometimes Batman-Ysondre.. the name and the server
    Posted in: Lua Code Discussion
  • 0

    posted a message on problem with GetBattlefiledscore function
    there aren't names I use in the addon it's to be clear in the the forum
    Posted in: Lua Code Discussion
  • 0

    posted a message on problem with GetBattlefiledscore function
    Hello, I tried to get flag carrier class in Warsong gulch, it worked few days ago but now I don't know why doesn't work anymore.... I haven't changed anything. I use in update :

    for i=1,GetNumBattlefieldScores() do
            local name,_,_,_,_,_,_,_,class = GetBattlefieldScore(i);  
            if (strmatch(name,CarrierName)) then
                table.class = class;                             
            end
    end


    and it doesn't work.... strmatch always return nil even if name and CarrierName are same...

    it is strange I tried to print(name,CarrierName), both are exactly the same but table.class is always nil...

    Do you know why ?

    thanks
    Posted in: Lua Code Discussion
  • 0

    posted a message on how to save frame position correctly
    In fact my method works very well, I have my 75 cases table and the Savedvariable file is now only 1,65kb instead of 1200kb, the problem was in

    function frame:OnEvent()
    ....
    elseif (event=="PLAYER_LOGOUT" or event=="ZONE_CHANGED_NEW_AREA") then
    f1,f2,f3,f4,f5 = frame:GetPoint();
    MySaves[1]=f1;
    MySaves[2]=f2;
    MySaves[3]=f3;
    MySaves[4]=f4;
    MySaves[5]=f5;
    end
    end


    frame:GetPoint() is for exemple ("CENTER",nil,"CENTER",-25,25) but in the line

    "MySaves[2] = f2", I put "nil" in the second case of the table, and I don't why, but the "nil" transforms itself into 6000 lines in MySaves.lua....

    So I changed "MySaves[2] = f2", by "MySaves[2] = 0;". As I want all my frames to be anchored to UIParent, I don't need the 2nd variable. I may delete "MySaves[2] = f2" line

    and know it works without using too much memory

    with this I can save frame position per account, it seems it was not possible with the "frame:SetUserPlaced(true)" command
    Posted in: Lua Code Discussion
  • 0

    posted a message on how to save frame position correctly
    sorry it works... I have to write :

    frame = CreateFrame(......)
    frame:SetMovable(true);
    frame:EnableMouse(false);
    frame:SetUserPlaced(true);

    and in the slash command :

    if (frame:IsMouseEnabled()) then
    frame:EnableMouse(false) ;
    else
    frame:EnableMouse(true);
    end

    thank you it will help me a lot
    Posted in: Lua Code Discussion
  • 0

    posted a message on how to save frame position correctly
    in the addon I create a unmovable frame, but I want to make it movable with a slash command, so I write something like that :

    SLASH_MOVE1 = "/move";
    function SlashCmdList.MOVE()
    if (Frame:IsMovable()==1) then
        Frame:SetMovable(false);
        Frame:EnableMouse(false);
     else
      Frame:SetMovable(true);
      Frame:EnableMouse(true);
     end
    end


    but I just tried to add the line Frame:SetUserPlaced(true) (after the else) and it doesn't worked... when I reload UI the frame is at its origin position
    Posted in: Lua Code Discussion
  • 0

    posted a message on how to save frame position correctly
    If these frames have names, you can call Frame:SetUserPlaced(true) method, that tells frame to save position and sizes before logging out/interface reloading, and restore them when interface starts up.


    yes all frames have names, but do I need to name a savedvariables file with that ? Where does the information will be saved ?

    I keep the line "## SavedVariables: MyAddonSaves" in the .toc file and I use

    Frame:SetUserPlaced(true) ? Is it all ?
    Posted in: Lua Code Discussion
  • 0

    posted a message on how to save frame position correctly
    Hello, I try to save frame's position per account, I did something working I think but savefile is 1200ko , it is 48000 lines... So I think there is a problem, it make the addon using too much memory

    I have added a line in the .toc file with savedvariable name, and for each frame I want to save position I write something like in OnEvent:

    function frame:OnEvent()
    if (event == "ADDON_LOADED" and arg1 == "MyAddon") then
          if (#MySaves==0) then
          else
        az1=MySaves[1];
        az2=MySaves[2];
        az3=MySaves[3];
        az4=MySaves[4];
        az5=MySaves[5];   
        frame:ClearAllPoints();
        frame:SetPoint(az1,UIParent,az3,az4,az5);
         end     
     elseif (event=="PLAYER_LOGOUT" or event=="ZONE_CHANGED_NEW_AREA") then
       f1,f2,f3,f4,f5 = frame:GetPoint();
       MySaves[1]=f1;
       MySaves[2]=f2;
       MySaves[3]=f3;
       MySaves[4]=f4;
       MySaves[5]=f5;
     end
    end


    and here it MySaves[1] -- MySaves[5] but for the 2nd frame it is MySaves[6] --MySaves[10] ect...

    What's wrong with that ? What is the good manner to save frame position ? I tried to see how other addon make it but I don't understand

    I need to save position of 15 frames so I should have table with 75 cases ? not a thing of 48000 lines

    thanks
    Posted in: Lua Code Discussion
  • 0

    posted a message on Forbidden lua fonction ?
    I don't really understand the code of complex addon because I'm a noob in coding :s there lot of thing I don't understand yet

    for my problem I think I have maybe found the solution I'm going to check if the buff "preparation" is here with the function "UnitAura"
    Posted in: Lua Code Discussion
  • 0

    posted a message on Forbidden lua fonction ?
    Hi, I have another question^^

    Is there a way to know quickly if a battleground has begun ? Because I would to show a frame but only if the battleground has begun that is to say after the message :

    "The battle has begin"

    I can do registerevent("CHAT_MSG_BG_SYSTEM_NEUTRAL") and wait the message, but if the battleground has already begun, the message will never appear and my frame will stay hidden.

    So I tried to use the GetBattlefieldInstanceRunTime() function, but it seems to works only when it wants.... sometimes return the good time, sometimes return nil and often return 0.

    Do you know if it is possible to do that ?

    thanks
    Posted in: Lua Code Discussion
  • 0

    posted a message on Forbidden lua fonction ?
    No, you can't do this in combat.


    But if I create a frame with a button fixed on it, shouldn't I be able to move the frame while in combat and so the button ?

    Anyways, it seems to be a lot of work for not really important thing I will do anything else
    Posted in: Lua Code Discussion
  • 0

    posted a message on Forbidden lua fonction ?
    Try this. Create 10 frames and place them in a grid pattern. Have each frame target a enemy. Set them all to 0% transparency. Once a enemy gets the flag, give their frame a flag texture and set transparency to 100%.


    Yes it is a good idea, and to prevent this problem :

    Meanwhile, the user is trying to click to move the camera or turn his character and can't figure out why it's not working.


    I may set the position of the button that doesn't interest me out of the screen for exemple, or make them unclickable by using :

    B1:EnableMouse(false)

    But is there a way to scan enemy raid and record their name ?
    Posted in: Lua Code Discussion
  • To post a comment, please or register a new account.