Every X number of integer

joelloydjoelloyd Member, PRO Posts: 119

Any way to make a rule saying every '5' do this? Integer

Thanks

Comments

  • SocksSocks London, UK.Member Posts: 12,822

    When [numeric expression] mod(attribute,5) = 0
    --Then do some stuff

  • joelloydjoelloyd Member, PRO Posts: 119

    Legend !

  • joelloydjoelloyd Member, PRO Posts: 119

    this worked but it seems to be doing it in clumps and leaving bigger gaps than what it should, any idea why? @Socks

    thanks

  • SocksSocks London, UK.Member Posts: 12,822
    edited July 2015

    @joelloyd said:
    any idea why?

    No, I've no idea why. The expression itself is fine, so I guess you might have some other code that is working with this expression that is causing the issue ?

  • joelloydjoelloyd Member, PRO Posts: 119

    sorted it @socks sorry for the delay in time, work has been calling me away. One little question, this method worked fine. If i wanted to extend it by saying 2,3,4,5 do something, would it be best to simply place these in a table and have it randomly generating it?

    thanks so much, working well

  • SocksSocks London, UK.Member Posts: 12,822

    @joelloyd said:
    . . . If i wanted to extend it by saying 2,3,4,5 do something, would it be best to simply place these in a table and have it randomly generating it?

    I'm not 100% what the question means ?

    Can you describe what you want to happen (and you are not allowed to use 'it', you must instead refer to the thing by name :smile: )

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @joelloyd Are you saying that you want something to happen every time the attribute is a multiple of 2 and something else to happen every time the attribute is a multiple of 3 and so on for 4 and 5? If so, you don't need a table. Just make four separate rules with four mod() expressions.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • joelloydjoelloyd Member, PRO Posts: 119

    I mean i want the rule to say, every 2or3or4or5or6 spawn character. basically

    thanks

  • SocksSocks London, UK.Member Posts: 12,822
    edited July 2015

    When attribute is >1 and <7
    --Then do some stuff

  • joelloydjoelloyd Member, PRO Posts: 119

    dont think that will work as, I have a score increasing quite fast. So im saying every 1-6 score points spawn an actor. again and again and again. will this work?

    thanks

  • tintrantintran Member Posts: 453
    edited July 2015

    @joelloyd said:
    dont think that will work as, I have a score increasing quite fast. So im saying every 1-6 score points spawn an actor. again and again and again. will this work?

    thanks

    I think you want this right?
    if any
    mod(score,2) = 0
    mod(score,3) = 0
    mod(score,4) = 0
    mod(score,5) = 0
    mod(score,6) = 0
    then do something

    but saying every two is the same as saying every 2 and every 4 because 4 is multiple of 2
    and saying every 3 is the same as saying every 3 and every 6 because 6 is multiple of 2
    every 5 is different
    so you might just have this
    if any
    mod(score,2) = 0
    mod(score,3) = 0
    mod(score,5) = 0

    but if you say every 1 than spawn then it's like saying spawn for every score value.
    Unless you mean you want to spawn one actor at every 1
    and then spawn an extra actor at every 2 so that at every 2 you get 2 actors spawned (because 1 actor for every 1 and 1 actor for every 2)
    and then spawn an extra actor at every 3 so that at every 6 you'd get 1 actor for every 1
    and an actor for every 2 and actor for every 3...
    in which case you'd have to write separates rules for each every to spawn those actors separately.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Can you give an example of scores that would "trigger" your rules? For example, if I wanted something to happen every 3 points and the points increased by 1, I might have this setup:

    0
    1
    2
    3... do something
    4
    5
    6... do something
    7
    8
    etc.

    What would yours look like?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • ArmellineArmelline Member, PRO Posts: 5,368

    I assume you mean something like this?

  • joelloydjoelloyd Member, PRO Posts: 119

    they all spawn the same actor, just in a different spot as you move along, i just dont want the same intervals. For example, doodle jump, if it was made like that. every so many points because the character is going up, spawn another ready to drop down, etc. its going to be reoccurring constantly.

    every so many pixels if that makes it easier, 1or2or3or4or5or6. Then the process starts again. if you had a conveyer belt, you would see actors spread in different places of that belt.

    Cant really explain in any more haha

    thanks though

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Sorry, I'm not understanding. Maybe someone else can help! You might check out some of the free templates and tutorials available by Googling doodle jump gamesalad to get ideas for what you're trying to do.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • ArmellineArmelline Member, PRO Posts: 5,368

    My demo does what you are asking (just spawn in a different spot rather than spawning a different actor). I suspect you are trying to ask a different question, though.

  • joelloydjoelloyd Member, PRO Posts: 119
    edited July 2015

    It's literally what socks said at the beginning, just slightly different if possible

    When [numeric expression] mod(attribute,5) = 0
    --Then do some stuff

    But instead of just every 5, I want that number constantly changing every time and actor is spawned. 2,3,4,5,6 being the possibilities.

    @socks @Armelline

    Hope that makes it easier

  • SocksSocks London, UK.Member Posts: 12,822
    edited July 2015

    @joelloyd said:
    I want that number constantly changing . . .

    In what way do the the numbers change ?

  • ArmellineArmelline Member, PRO Posts: 5,368

    So you want to spawn an actor after 5 points, then after a random number of points spawn another, and then after a random number of points spawn another etc.?

  • joelloydjoelloyd Member, PRO Posts: 119

    Just imagine a timer going up from 0, a rule saying every 1,2,3,4or5 seconds spawn an actor. So you will have actors spawned maybe at 2seconds then 5 seconds after that, then another 5 seconds after that, then 3 seconds after that. Just random spawning as the timer went up, non stop with those interval possibilities

  • joelloydjoelloyd Member, PRO Posts: 119

    Instead of every 5 which would go 5,10,15,20,25 and so on. It could spawn like 3,7,8,10,15,17,18,20...endlessly etc

  • joelloydjoelloyd Member, PRO Posts: 119

    Yes armelline exactly like what you said, sorry only just read that proper. The first number doesn't have to be 5, it could be any of the numbers

  • ArmellineArmelline Member, PRO Posts: 5,368
  • joelloydjoelloyd Member, PRO Posts: 119

    perfect, thanks a lot! thats some less messing than my way with tables haha.

    thankyou!

Sign In or Register to comment.