How to minus 1 off an integer on touch for the actor?

FF1FF1FF1FF1 Member Posts: 75
edited November -1 in Working with GS (Mac)
Hi, I need to minus 1 off an integer on touch. So on each touch the actors integer will go like from 3 to 2 to 1. Thanks

FF1FF1.

Really just need the code to take 1 away :D

Comments

  • FloridaGamesFloridaGames Member Posts: 328
    When actor receives event: touch: pressed.
    Change attribute: integer to integer-1.
  • FF1FF1FF1FF1 Member Posts: 75
    Mmmm Doesn't work I've tried everything :-(

    I got: self.Spawner to self.Spawner -1

    Also tried just -1 ect

    Any thing else? Does it work for you ?

    Thanks.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    self.spawner to self.spawner-1 works so you gotta be doing somehting wrong

    Your not just typing in the attribute names right, your selecting them from the drop down menu in the expression editor?
  • FF1FF1FF1FF1 Member Posts: 75
    I have typed in the name manually and from the list -

    In the end I get --- self.spawner to self.spawner-1
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    yea you cant just type the attribute name in. You have to select it from the list then type-1 at the end of it.
  • FF1FF1FF1FF1 Member Posts: 75
    Ah, I see done that by the menu, but the integer does not go down ? mmmmmm
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    post a screenshot of your rule if you can not sure what your doing wrong.

    Change attribute self.spawner to self.spawner-1

    with the attribute in both places being selected from the drop down
  • FF1FF1FF1FF1 Member Posts: 75
    Owww, I got it, kk

    Its works! As you said I must have been doing something wrong. Whats it was is, I had a rule that didn't need. Well I don't think I do as starting to work.

    What im doing is only allowing 3 balls to be dropped on touch and any more i do not allow.
  • FF1FF1FF1FF1 Member Posts: 75
    But what I do need is an if statment in the actor spawner to say --

    If self.Spawner = 0 then don't spawn, Ill have to figure it out
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    whatever rules you have to spawn, put that in a rule that says when attribute self.spawner is > 0. That way it turns off once the attribute has reached 0

    cheers
  • FF1FF1FF1FF1 Member Posts: 75
    yer, have just done that after some thinking cheers!

    It works perfect! But, why don't it spawn a ball on 0, when its on more than or equal to ? is it a glitch? Coz thats what mines on....
  • FF1FF1FF1FF1 Member Posts: 75
    oww lol just my poor maths.... Looks weird but it makes sense..

    Thanks allot!
Sign In or Register to comment.