7 Replies Latest reply on Sep 12, 2011 8:12 PM by Adam-C

    Redo and undo operations in lingo.

    Abhilash M

      I wanted to know how you people develop redo and undo method in a director project using lingo? Is there any standard function which keeps track of user interactions and provide the traditional method of redo and undo? Else should i develop a own logic? I'm new to lingo programming, so asking you experienced people how to go about it?

        • 2. Re: Redo and undo operations in lingo.
          brahim_ayi

          You have to use the lists for that.

          For example if you want to save the frames visited, just creat a list where you add the number of the frame visited.

          Ex: my_visited_frames =

          Then you can use this list to undo or redo your action ex: go to frame my_visited_frames[5]

           

           

          Brahim

          • 3. Re: Redo and undo operations in lingo.
            Abhilash M Level 1

            I tried your solution, but there is no change when sprite undo is done. Basically go to frame does not update the sprite to its previous location. Is there any simpler method to achieve undo redo operations.

            • 4. Re: Redo and undo operations in lingo.
              Wolfgang Herold Level 2

              if you change the location of a sprite you'll have to store the actual and the original position/size/rotation ( all you can change) of all changable sprites.

              on clicking your undo button you can restore the last changes  by setting the sprite's last parameters

               

              e.g.

              repeat with spritecount = firstsprite to lastsprite --(  the changeables)

              sprite(n).loc =

              sprite(n).location =

              sprite(n).rotation =

              .whatever

              .you

              .want

              end repeat

               

              regards

              wolfgang

              • 5. Re: Redo and undo operations in lingo.
                brahim_ayi Level 1

                You have to save the sprites positions in a lists for that.

                 

                Ex: my_sprite1_position_H =

                    my_sprite1_position_V =

                 

                then you set the loch and locV of your sprites when you need them :

                example if you return to frame 2 :

                sprite(1).locH = my_sprite1_position_H[2]

                sprite(1).locV = my_sprite1_position_V[2]

                 

                Brahim

                • 6. Re: Redo and undo operations in lingo.
                  Abhilash M Level 1

                  Thanks, finally i was able to create undo operation in lingo! Lists are very helpfull in lingo, i got to know these just after coding undo action, i was able to create with counters and two lists.

                  Here is just sample i did, not too great though!

                   

                  global clicklist, counter, undolist, undocounter

                   

                  on mouseUp me

                  -- store values in variables for undo operation

                    spriteName = undolist.getAt(undocounter - 2)

                    spriteX = undolist.getAt(undocounter - 1)

                    spriteY = undolist.getlast(undocounter) 

                   

                    sprite(spriteName).loc = point(spriteX, spriteY)

                    undolist.deleteAt(undocounter)

                    undolist.deleteAt(undocounter-1)

                    undolist.deleteAt(undocounter-2)

                   

                    undocounter = undocounter - 3

                   

                  end

                  • 7. Re: Redo and undo operations in lingo.
                    Adam-C Level 2

                    There's nothing built-in so you'll need to develop your own logic to do it. How best to do this depends on the complexity of your program. I once used a system that logged all changes to a list of property lists, with each property list logging the details of the user's actions. So, if a user's actions changed the value of "name" property of a given parent script instance (let's call it theObject), I would store something like this in my undo list:

                     

                    [#targetObj: theObject, #targetProp: #name, #oldVal: "This is what it used to say", #newVal: "This is the new text"]

                     

                    It's then a simple task to step back and forth through the undo list and reverse / re-apply the changes.