Announcement

Collapse
No announcement yet.

Properties Rename at a shot - Help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Properties Rename at a shot - Help

    Hi Friends

    Just to introduce I am not an expert in programming. Just used to browse around and make some small events in autoplay. My question is.. Is there a way to change some string lines in multiple objects at same time ?

    Ex: I have 5 different buttons. In their separted code, they all have a " specific and similar " name I would like to change. Ex - " command_alfa " ! This line, " command _alfa" is writen in all five buttons, inside their codes. I would like to change them all to " command_beta "! The only way I know to change them all is, opening every single button, one at a time , and changing the text I want to change! So, the question is, is there a way to change the text in all buttons at same time ? or change a " text , string " in all elements into the screen ( simillar texts of course ) at same time ?

    many of my elements in the screen have strings like " , something_A , something_B ... " and I would like to change them all at one single shot! Possible ? Currently I am opening element by elemnt and chaging all them manualy !

    I hope someone can help me !

  • #2
    Your request is confused and garbled. And difficult to ascertain exactly what you want. Start by outlining your request more succinctly. And by using terminology more accurately. You 'seem' to confusing the term 'elements' with 'objects'? And conflating the term 'button names' with 'button text'?

    Currently, I can only ascertain that you wish to change the 'text' displaying in each of your buttons via a single clickable event? Is this correct?

    If so, you control the Properties (ie. text, size, shape, etc) of an any Object, via its Properties Table. If it's just button Text you wish to change, define your Properties table with just that aspect. ie.
    Code:
    local t = {
        Text="command_beta"
    };
    If you want to change more than just the text, define that in your table, too. ie.
    Code:
    local t = {
        Text="command_beta",
        FontName = "Tahoma",
        FontSize = 7,
        FontWeight = FW_BOLD    
    };

    Then apply your Properties Table via a Button.SetProperties() command. If applying it to more than one Button, use a count-loop. (ie. 5 buttons means a count-loop of 1-5). ie.
    Code:
    for i = 1, 5 do
        Button.SetProperties("Button"..i, t);
    end
    See attached example.
    Attached Files

    Comment


    • #3
      Hi Biohazard. Thank you for your replay. In fact, my explanation was very confusing indeed. Attached is a sample that best illustrates what I need.
      ( thak you for help in previous post today ! )
      Let me know if file is enought to make things clear.
      Attached Files

      Comment


      • #4


        items_code_rename.zip

        Comment


        • #5
          Bobfern

          Use the Page.SetObjectScript() function.

          As you wish to apply this action to multiple objects whose script values are dynamic (ie. g_01, g_02, g_03, g_04), set up the script values in a local table first. Then iterate over the table to retrieve each value:
          Code:
          local tScripts = {
              'File.Open("AutoPlay\\Images\\pack_02\\g_01");',
              'File.Open("AutoPlay\\Images\\pack_02\\g_02");',    
              'File.Open("AutoPlay\\Images\\pack_02\\g_03");',    
              'File.Open("AutoPlay\\Images\\pack_02\\g_04");'
          };
          
          for k,v in pairs (tScripts) do
              Page.SetObjectScript("Button"..k, "On Click", v);
              Dialog.Message("New Script on Button"..k, v);
          end
          This code can be fired from any event in which your buttons objects have already been drawn.

          Nb.
          Note use of single quote(') encapsulation with the table values - which instructs Lua to escape / interpret values as literal strings.

          Comment


          • #6
            Correction:
            Come to think of it, you'll need to "double up" on those backslashes so the filepaths get correctly interpreted by AMS. (And add the file-extensions to the image names, too).
            Code:
            local tScripts = {
                'File.Open("AutoPlay\\\\Images\\\\pack_02\\\\g_01.jpg");',
                'File.Open("AutoPlay\\\\Images\\\\pack_02\\\\g_02.jpg");',    
                'File.Open("AutoPlay\\\\Images\\\\pack_02\\\\g_03.jpg");',    
                'File.Open("AutoPlay\\\\Images\\\\pack_02\\\\g_04.jpg");'
            };
            
            for k,v in pairs (tScripts) do
                Page.SetObjectScript("Button"..k, "On Click", v);
            end
            Here's an example based on your request description:
            Attached Files

            Comment


            • #7
              Hi Biohazard ! the las sample you sent helped a lot. This is a new way to approach the question . I grab another code that also helps but I am stucked in another more complex situation .. Attacehd is the apz with explanation. Can you help me with this ?
              Attached Files

              Comment


              • #8
                Hi Bobfern ,
                I had a look at your small example, the code you tried to employ ? - Seems you had no understanding of what it meant. I have not looked at Bio's example but done a simple mod
                of your example.I think this is what you are trying to acheive.You can have a lot of folders with files inside with same name using a common variable assigned when you click
                a button eg Level A or B Pack1 or 2 etc

                code transfer_Modded.apz

                Comment


                • #9
                  Hi " Charlie " , this is exaclty what I was looking for !! Ansolutely fantastic for me !!! Thank you a lot. Now , I will try to undestand how did you make it ! Again, thank you a lot !!!

                  Comment


                  • #10
                    example

                    Code:
                    [ATTACH]n302498[/ATTACH]

                    Comment


                    • #11
                      Originally posted by herrin View Post
                      example

                      Code:
                      [ATTACH]n302498[/ATTACH]
                      Hi Herrin

                      Yor code is really amazing ! very simple and smart indeed. I just try it and this solves part of my probelm. I just came to another scenario and would like to know if you coulf give me some light on this. Attached in a project with new situation .
                      can you solve this ?
                      Attached Files

                      Comment

                      Working...
                      X
                      😀
                      🥰
                      🤢
                      😎
                      😡
                      👍
                      👎