Anyway to know if a number is even?
beefy_clyro
Member Posts: 5,394
Hello,
Lets say I have 20 actors and they all have their own unique id between 1-20. Is there a way of telling the actor that its unique id is an even number? so 2,4,6,8,10,12,14,16,18,20.
The range will be varying throughout so cannot really be a static solution.
Thanks,
Keith
Lets say I have 20 actors and they all have their own unique id between 1-20. Is there a way of telling the actor that its unique id is an even number? so 2,4,6,8,10,12,14,16,18,20.
The range will be varying throughout so cannot really be a static solution.
Thanks,
Keith
Comments
Should look something like this:
if attribute Number = (floor(Number/2))*2 . . . .
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
Change attribute self.position.X to prec(self.position.X/game.gridSize,0)*game.gridSize
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I'm about to create a new thread, look out for it, sure you guys will have some way to make me feel utterly stupid again for not thinking of it (i've been having a week of this kind of thing).
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
Make a table with 20 rows.
In column 1, put a '1' in the row of each 'even' number row. Leave the prime number ones at 0.
e.g.
1: 0
2: 1
3: 0
4: 1
5: 0
6: 1
7: 0
8: 1
Select a random number between 1 and 20.
In your rule, use the first part to check the table cell value based on your random number, and the '1' to check if it's even.
e.g.
If tablecellvalue(table,your random number,1) = 1
Then you have an even number.
This only works in pro with the ability to put stuff on both sides of a rule though.
My mind is not normal - I came up with this as a way of being able to decide which level certain things happen on e.g.
Table has 100 entries - each row represents a level.
If I want boss characters to appear every 10 levels, I mark where I want them to appear with a '1' (row 10, 20, 30, 40, etc) and check every time the player moves on to a new level.
Works a treat, and is much simpler than having 'if level =10' or 'if level =20' or 'if level =30' etc etc
QS =D
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS