Attribute names - boolean, integer, real, etc

LokitoesLokitoes Member, PRO Posts: 187
Hi all!

I am a beginner to GS and also lacking in some basic mathematics skills ;) so I was wondering if there is a good source/tutorial that goes into more detail about these different types of attributes named in the discussion title, and different instances in which you would choose them? I understand that in general boolean means only true or false, and I think integer means whole numbers and real means it can have a decimal point. But I can't think of many examples where one would be used instead of the other (particularly with real and integer), which means I get stuck setting up attributes because I'm not sure which one to put my attribute under.

And I am even worse with text, angle, and index - I don't know what they are for at all. I've looked through the cookbook tutorials, but haven't found what I'm looking for.

Cheers
A

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited February 2014
    @Alintakk

    Boolean = true or false (or 1 or 2)
    Text = stores text
    Integer = whole numbers only
    Real = numbers with decimal places
    Angle = numbers between 0-360 (has a built-in modulus function which loops at 360)
    Index = positive integers
    . . . I can't think of many examples where one would be used instead of the other (particularly with real and integer)
    Examples: A 'real' attribute could store a precise location on the screen, an integer would be quantized to the nearest pixel. If you had a game where a ball had to bounce to a certain height, the ball that went to 145.32 would beat the ball that went to 145.11 - if these scores were stored as an integer they would (wrongly) draw.
    And I am even worse with text, angle, and index
    Text is obvious enough, it's for storing text ! Someone enters their name or chooses a letter in a spelling game - and if you needed to save it - then you'll want to store it in a text attribute.

    Angle . . . meh . . . useful up to a degree (I don't charge for the these jokes, they're free), but I never use it, you can do most of what you need with 'real' and 'integer' - even with angle / circle stuff.

    Index, not too sure when you'd use it as their are maths functions ('abs' and 'floor' come to mind) that essentially can make 'real' and 'integer' attributes do what a 'index' attribute does.
  • LokitoesLokitoes Member, PRO Posts: 187
    Thanks Socks :)
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    This is part one of my GS logic series. It will teach you about attributes and how to use them and how to structure your code. Click the video link in my signature to see the rest.

  • LokitoesLokitoes Member, PRO Posts: 187
Sign In or Register to comment.