Change attribute back and forth between 1 and 2

iPhoneDevForMeiPhoneDevForMe Member Posts: 362
edited November -1 in Working with GS (Mac)
I swear I have read how to do this somewhere but I CANNOT find the post!

Basically I just have an int attribute that I want to change every 15 seconds between 1 and 2

so:
1, 2, 1, 2, 1, 2, 1, 2.....ect

All I know is it involves the expression editor and modulus, just don't remember the formula!

Thanks for your time!

-Kyle

Comments

  • jstrahanjstrahan Member Posts: 498
    Attribute set to 0
    Every 15 sec
    Change attribute to ((attribute+1)%2)+1
  • iPhoneDevForMeiPhoneDevForMe Member Posts: 362
    Just so you know, I love you.

    You can take that any way you want haha!
  • iPhoneDevForMeiPhoneDevForMe Member Posts: 362
    It doesn't seam to be working :(

    My rule is set:

    Every 15 sec:
    -Change attribute to ((attribute+1)%2)+1

    I am using display text to check, and it goes from 0 to 2, and stays that number. Any thoughts?
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    After 15 seconds it changes your attribute from 0 to 2 (attribute+1 = 1, 1%2 = 1, 1+1 = 2). Then, each pass after that sets your attribute back to 2. (attribute+1 = 3, 3%2 = 1, 1+1 = 2)

    You will need 2 attributes to get that to work correctly...
  • iPhoneDevForMeiPhoneDevForMe Member Posts: 362
    Ok, I see the math now, I swear FireMapleGames had a solution, but I will try to do a work around.

    Thanks alot for the detailed explantion barkbark!
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    You could do this:

    Display text: attribute+1

    Rule:
    Every 15 sec:
    -Change attribute to (attribute+1)%2

    The rule gives you 1,0,1,0,1,0,1, etc...

    You just need to add the +1 when you use the attribute.
  • jstrahanjstrahan Member Posts: 498
    Update
    Set attribute to 0
    Change attribute to (attribute+1)%2

    actor that uses this
    Check for attribute +1 but do not add the extra 1 to attribute

    Oops barkbark beat me
    I should have got it right the first time cause i use tgus alot in mu games when i need an actor to be in two different location depending on some other attribute
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi Kyle, I've had a bash as well (there's more than one way to skin a cat, as they say...)

    A bit unrefined perhaps, but it works. 2 game attributes, bool OneTwo + int Switcher:

    Photobucket

    Might help you out, although there's no modulus involved or the expression editor though... so barkbark00 + jstrahan ideas could well work out better.

    :-)

    ---------------------------------------------------------------
    Spiral Gyro Apps

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • iPhoneDevForMeiPhoneDevForMe Member Posts: 362
    Perfect, these solutions all worked EXACTLY the way they needed! Thanks everyone!
Sign In or Register to comment.