GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Load Attributes setting values to 1

jrj.clarkjrj.clark Posts: 17Member, PRO

Hi there,

I'm having problems that when I try to load attributes it sets the values to 1. Any thoughts on where I'm going wrong?

When the player dies in my game, it triggers a GameOver attribute to change to true. When this happens it saves a number of attributes (including High Score). The player then taps on the screen and the scene is reset. When the scene loads, the attributes are loaded as well. This is when I see the values reset to 1.

I've tried a few things to solve this, but haven't resolved it. Eg. I've tried adding a time delay of 1 sec before it loads the attributes. That doesn't work... I can see the High Score at what it should be when the scene resets, but when the attributes are loaded, it resets to 1.

I did have it working at one point. I've got an ad hoc version working on my iphone. But I've done something to mess it up - and I've made a lot of changes since then, so I don't want to roll back to the version that I know does work.

I'm guessing that others have encountered this previously, so I'd appreciate any thoughts on what I'm doing wrong.

Thanks,
James

Comments

  • tatiangtatiang Posts: 11,673Member, Sous Chef, PRO, Senior Sous-Chef
    edited October 2016

    These kinds of problems can be very simple to fix when looking at the rules directly but they can also be time-consuming because there is an actor somewhere that has a Load Attribute behavior setting the value of the attribute to 1. That's the only explanation unless you are changing the value of the attribute to 1 using Change Attribute just after the Load Attribute behavior runs. Also make sure that the default value of the attribute in the attributes list is NOT 1. If it's 0 or something else, that's fine.

    I'd recommend troubleshooting this by removing actors from the scene one by one until you have ONLY the actor responsible for loading the attribute. Or create a new blank scene and add ONLY that actor. (Be sure to backup to a SEPARATE FILE first). Either way, if the problem no longer exists, then you know it wasn't that actor. You can then start over and delete one actor at a time until the problem stops. The last actor deleted is likely the culprit. If the problem still exists when you have ONLY that actor in the scene, then at least you've narrowed down the cause and can post screenshots of the rules that aren't working as you expect them to.

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

  • jrj.clarkjrj.clark Posts: 17Member, PRO

    Thanks for comments Tatiang
    So I've been playing around, trying to solve this some more...

    Here's the basic logic I have:

    • When 'Game Over' attribute is true, update 'High Score' attribute if < 'Level Reached' attribute.
    • 2 sec delay, then Save High Score Attribute and then Reset Scene
    • An actor in the scene loads 'High Score' attribute

    I am displaying the 'High Score' attribute so I can constantly see what it is. At Game Over, I can see that High Score is updated to (let's say) 55. If I turn off 'Load Attribute', when the scene resets, the high score remains as 55. But if I turn on 'Load Attribute' is gets set to 1.

    I've deleted almost everything in the game and can't see anything that is setting the High Score to 1. It can't be happening after the Load Attribute, because I have only turned off Load Attribute. And it can't be before, because otherwise I would see the High Score get updated with this.

    Any further thoughts on what could be causing it???

  • tatiangtatiang Posts: 11,673Member, Sous Chef, PRO, Senior Sous-Chef

    Sure, also make sure you are using locked prototypes and not unlocked instances of actors. If possible, upload your project file and someone can take a look and see if they can spot the problem.

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

  • tatiangtatiang Posts: 11,673Member, Sous Chef, PRO, Senior Sous-Chef

    By the way, providing logic/pseudocode can be great when you're trying to think through how to do something but it's not very useful when you're trying to troubleshoot why something isn't working. It's better to have the actual rules and/or screenshots. There are just so many variables involved from the order of behaviors and rules to missing parentheses to misspelled key names, etc., that it's hard to know what might be causing the issue without those details. That's why a project file is best in terms of quickly getting to the root cause.

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

  • ToqueToque Posts: 1,172Member
    edited October 2016

    Sometimes i hit delete on this attributes. It will give warning of all actors it's in. I write them down. Hit CANCEL!!!!

    Then go through all actors and see where the change attribute is.

    You don't want actually delete the attribute you just want to look at the warning!!

  • tatiangtatiang Posts: 11,673Member, Sous Chef, PRO, Senior Sous-Chef

    @Toque said:
    Sometimes i hit delete on this attributes. It will give warning of all actors it's in. I write them down. Hit CANCEL!!!!

    Then go through all actors and see where the change attribute is.

    That's not a bad idea. First, backup your project file to a separate file/copy. Then, delete the GameOver attribute. It will then display a list of actors that contain that attribute.

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

  • jrj.clarkjrj.clark Posts: 17Member, PRO

    I appreciate the help guys!
    Okay, I've attached a very stripped back file.

    There are a number of attributes that are experiencing the same problem, but let's stick with the 'High Score' attribute. I've followed Toque's suggestion and identified that the High Score attribute shows up only in the 'Attribute' and 'AchievementBoard' actors.

    I've tried changing where the High Score value is saved. I've tried this in both actors. Currently, the AchievementBoard actor is not used for High Score. The loading, saving, and updating of the High Score attribute is all currently done in the Attributes actor.

    There is one number displayed on the game screen. This is the High Score. It shows the number of exits/platforms (the things that look like stairs) that have been passed. This updates when the character 'dies'. The easiest way to get the character die is to use the down arrow until he falls off the bottom of the screen. Or use the left or right arrows to run him off the screen.

    After you die and are prompted with the onscreen message 'tap to continue' that is when the scene resets and the High Score attribute loads a value of 1. If I turn off Load Attribute then it is not an issue.

    Any help would most greatly be appreciated!

Sign In or Register to comment.