Constrain Attribute then get it back HELP

Hello to GS Community,

I have been banging my head for 2 days on a feature which I want to implement in my project but I can't seem to find a solution.

I have a total of 3 actors. The first one has the DISPLAY TEXT attribue . It displays a game.attribute. This game.attribute changes to let's say 15 (because of rules and etc which are not so imporant). When the touch is INSIDE second actor it constrains game.attribute to game.attribute+1. The third actor is the same as second but constrains game.attribute to game.attribute-1. The issue is that I want when the touch is released to change game.attribute to ITS INITIAL number. game.attribute changes its number not to 15 every time but to random number every 5 seconds lets say. The question is how I can change it back to its initial number.

Thank you

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited February 2014
    It's never a good idea to constrain an attribute to an expression that includes that expression. This creates an endless loop. Second, I would recommend instead using a timer. Something like this:

    When Touch is Inside
         change attribute game.originalValue to game.attribute
         Timer every 0.1 seconds
              Change game.attribute to game.attribute+1 (or -1)
    Otherwise
         change game.attribute to game.originalValue
         Timer every 5 seconds
              change game.attribute to random(1,30)

    Obviously, you can alter the frequency of the timer and the random value range to your liking.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • BonepileGamesBonepileGames Member Posts: 194
    @tatiang

    Thank you for your answer but I am afraid I couldnt express properly my situation.

    The issue is connected with my project which we discussed early on. You said that I should look for solution myself or hire someone to fix it up. Thus I am quite unsure if you would like to volunteer in helping me.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited February 2014
    I assume you're talking about this thread: http://forums.gamesalad.com/discussion/64512/an-odd-movement. I don't see the connection immediately but if my answer above doesn't solve it for you, try explaining it further.
    Thus I am quite unsure if you would like to volunteer in helping me.
    I'm quite unsure, too. :-? I took your other thread/project as far as I felt I could given my time constraints and the complexity of the setup you had. So, no, I'm not offering to help you get everything working, but... if you separate everything into bite-sized pieces like in this thread, I can probably help out here and there.

    I guess what I'm saying is there's a difference between asking, "How do I get my platforms to move at the correct speed based on multiple rule conditions, a spawner actor, and various changes to the velocity of these actors, all the while taking into account how other actors affect this system?" and asking "How do I reset an attribute value once touch is released?" The first might take me 2 hours. The second might take me 2 minutes, so I'm happy to answer that type of question.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • BonepileGamesBonepileGames Member Posts: 194
    I got it now.

    I will be able to upload the project. If you got free time, you might give it a shot.

    More details tomorrow.
  • BonepileGamesBonepileGames Member Posts: 194
    @tatiang,

    I got my problem fixed. Can I send you my project just to check something? I cant seem to find my mistake.
Sign In or Register to comment.