i want to spawn an actor when an attribute is divisible
agueis
Member Posts: 420
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
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
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Thanks gyroscope it works, and if i want that coins spawn like 20,40,60,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.
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