Better understanding at Attributes??

eliehangeliehang Member, PRO Posts: 105
edited November -1 in Working with GS (Mac)
Can anyone give me a better understanding of how attributes works... I see a lot of .. example:
create an integer. If 1 does this, then 1 activates or what not. I still have some trouble understanding how game attributes and numbers work together in the rules.

Comments

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    http://gamesalad.com/wiki/how_tos:gsc_create_attribute

    In a nutshell, an attribute is an object where you can store data. That data can be accessed and modified by behaviors in an actor, depending on where that actor(prototype or instance) and the attribute(game,scene,actor types) are located. <see the link above>

    When an attribute is used in a rule's condition (e.g. if Attribute, self.blah is ? <some expression>), it is comparing that attribute to the value of the expression. (you can just use a value that is not an express, but just a plain value)
  • I'm kind of in the same boat as the original poster. I loosely understand how to use attributes, but I don't completely know why I would use one over another. If I'm trying to make a hud element showing how many lives the player has, why would I use integer over real? Or making a "true vs. false" attribute, why would I use boolean over index?

    Somehow I always manage to figure it out, but it would be nice if there were an in depth guide somewhere other than this one.

    http://gamesalad.com/wiki/how_tos:gsc_create_attribute
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Integers are whole numbers: 1, 2, 3, -5, 32000, etc... you use them a lot. Especially handy for counting. Number of Lives, Current Level, High Score, etc...

    Real Numbers have decimal points: 1.2, 3.45, 66.78,etc. Only use them if you need the precision that they offer. They are generally considered more taxing on the system, but that matters less and less as time goes on.

    An Index is basically an integer, but it can only be positive - no negative numbers. They are generally used for counting lists of items. i.e: there are 5 apples in this bag. There can never be -5 apples in the bag. You do not really need to use an index attribute with GameSalad. You can forget that one for now!

    A boolean is an attribute that can only be true or false. One or the other. Off or on. You will use these a lot as well.
  • MotherHooseMotherHoose Member Posts: 2,456
    Wow @eliehang...like how your "Bork's Adventure" looks!

    http://gamesalad.com/game/play/36994

    attributes are where you store/access information that your actors use for different behaviors... variables in other programming languages... characteristics of a particular actor in GS...

    Excellent descriptions...FMG!

    though I seldom use boolean...and use Index often...for image display in a scene... and to assign to a touch/drag actor position... or may even try them to have appropriate background (etc.) for scene at runtime without actually adding the image in the editor... just make drag-in Note with a list of your images/# for index...

    MH
  • Thanks for the info FMG. Those examples really helped in the better understanding of how they work. Very much appreciated.

    Much appreciation to all of you. I really appreciate the help. /hug
Sign In or Register to comment.