How to Find the References to Game Variables

ronixusronixus Member Posts: 19
edited July 2012 in Working with GS (Mac)
First, I'm unsure if this is supposed to be a question or a discussion, since I actually have a workaround.

Just to check with everyone else - how do you find which actors have references to a specific game variable? I found that the only way seems to be to attempt to delete the it. Doing that triggers a confirmation screen that presents the list of actors that have references to the concerned variable.

In addition to being risky (in case you press OK accidentally), it's still a difficult task, since you have to dig inside the behaviors to find them individually.

Any techniques you can share? Or is this a change on the way?

Comments

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Nope. You must be using a template because if you made the code yourself you would know what is assigned to what. You have to look at the code it's all there.
  • ronixusronixus Member Posts: 19
    Nope. You must be using a template because if you made the code yourself you would know what is assigned to what. You have to look at the code it's all there.
    I do agree with you, but no it was done completely by me. It could happen though if there are a number of actors in a game, or if you have not visited your project for some time - the variables could get referenced deep into nested timers and rules, not counting the otherwise.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Nope. Clicking delete is the only way to see what actors that attribute is in. Be careful though if you accidentally delete it all the way there's no way to reverse it.
  • MotherHooseMotherHoose Member Posts: 2,456
    use all the goodies GS gives you!

    when you make an attribute … name it so you know why it exists/what it does
    (names do not matter to the computer … computer stores by an id#
    … names are there for your ease in defining the attribute's purpose)

    in your actor's behaviors … drag in a Note behavior
    type/drag into that Note the gameAttributes actor accesses

    in your rules … in the titleBar … type in the attribute(s) accessed

    before you start deleting attributes … save a back-up project that is perfect
    when done your deletions … if the new project works … you are good to go

    as @FryingBaconStudios said: when you made the game you should know the attributes you used … worried you may forget? … then write them down

    image MH
  • ronixusronixus Member Posts: 19
    edited August 2012
    Found a workaround guys! @FryingBaconStudios, @tenrdrmer, @motherhoose

    All components of the Game Salad project file are saved as XML files. Using the Mac console and the "grep" command, I'm able to find all occurrences a certain variable. It actually works as a global "find-in-workspace" solution.

    Thanks for your inputs.
  • rhinokeyrhinokey Member Posts: 158
    I'll have to try that Ron, I'm doing all my own code, and since I'm still learning i try a lot of different things, and sometimes in big projects I'll find attributes i remember making but not sure if they are still in use or left overs, and have to do the delete thing.
    i think a search function in gs would be a nice addition maybe at the top of the rules a little box to enter text, or an attribute, (like an expression editor) and have it highlight all the matches in the rules below. especially since sometimes things get stuck in the otherwise section and can hide away in there.
  • rhinokeyrhinokey Member Posts: 158
    also as i have just found out, game salad does not always tell you that a attribute is in use when you delete, so be careful, i have an index attribute in an actor that when i press delete on, it just deletes, even tho it is in use in that same actor.
  • MotherHooseMotherHoose Member Posts: 2,456
    of course, GS doesn't warn you when deleting the attribute from the actor
    that is the actor you are working in
    … you should know if you created the attribute when you used it

    however, when you do not make the needed changes in the actor … when you reopen that actor … GS will alert you of the now blank attribute fields

    image MH
  • rhinokeyrhinokey Member Posts: 158
    well the thing is, sometimes it does warn you i deleted 3 in a row, 2 of them gave me a warning that they were being used, and the last one gave no warning, even when it was being used.
  • ronixusronixus Member Posts: 19
    edited August 2012
    @rhinokey This should do the trick. You can issue this command before you delete any variable, and you'll know if it's ever called anywhere.

    I created 5 actors in a dummy project and created 8 nested layers of rules, then used "MyVariable" in "Otherwise" section of Actor 5. It was still able to return the result.

    1. In the Terminal, cd to the directory where your gameproj file is located.

    2. cd MyDummyProject.gameproj

    3. Issue this command:

    grep -RH MyVariable *

    4. In the result, there will be some text surrounded in a tag [text id="name"]. That's the actor that has reference to it.

    The catch is that it will return any actor that even mentions that word in a Note, or a disabled rule. But it will save you from accidentally deleting something that's used.
Sign In or Register to comment.