i want to spawn an actor when an attribute is divisible

Helo, i want to spawn an actor when an attribute is divisible, i explain better: when an attribute is true , there is a counter, change attribute game.coin to game coin+1.I want that when game.coin is 10,20,30,40... spawn an actor but i don´t know the way to do it, can you help me?

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited November 2014

    Hi @agueis I'm going to guess there's more than one solution t your prob... here's my take:

    Make a text attribute, let's call it CoinCheck

    Constrain Attribute game.CoinCheck to game.coin
    
    Rule: When attribute game.CoinCheck ends with 0
    Spawn actor
    

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

  • agueisagueis Member Posts: 420

    Thanks gyroscope it works, and if i want that coins spawn like 20,40,60,80...?

  • SocksSocks London, UK.Member Posts: 12,822
    edited November 2014

    @agueis said:
    Thanks gyroscope it works, and if i want that coins spawn like 20,40,60f,80...?

    If game.coin = (floor(game.coin/10))*10 . . . . . . then it is divisible by 10.

    If game coin = (floor((floor(game.coin/10))/2))*20 . . . . . then it is divisible by 20.

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

    You can also use the mod() math function:

    When attribute game.coin>0 and mod(game.coin,10)=0
    --> behavior when divisible by 10

    When attribute game.coin>0 and mod(game.coin,20)=0
    --> behavior when divisible by 20

    mod() returns the remainder of a division problem, so if you divide a number by 10 and you get zero remainder, then that number is a multiple of ten. The reason for the two conditions is that mod(0,10) also equals zero so we have to ignore zero.

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

Sign In or Register to comment.