Or?
joelloyd
Member, PRO Posts: 119
When making a rule, what do i use to say or?
example, im placing it in the position of a spawned actor and iv got 3 attributes constantly changing at random. I want it to randomly choose one of the 3 attributes. so like,
random(attribute1 or attribute2 or attribute3)
something like that if possible, thanks
Comments
Can you expain why three attributes? You would need to add another layer of random code with three different rules looking at each of the three attributes. Not a very efficent method.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Like The_Gamesalad_Guru said, it's not clear why you'd need 3 random choices ?
Why could you not simply have a single random number generator ?
you could try something an expression like this
(random(1,3)==1) and attribute1 or
(random(1,2)==1) and attribute2 or
attribute3
so it'll evaluate random(1,3) if you get a 1 it'll return attribute1. so 2/3 of the time it'll go on to evaluate the rest of the expression.
next since there's 2/3 you want it to return attribute2 half of the time so that's why the random(1,2)==1 which occurs statistically 1/2 the time....
and what's left is 1/3 of the time it'll just return attribute3.
Yes but that just bloats the code needlessly as he obviously has a specific purpose for each of the three and you'd need rules for what each attribute does. If he tells me why, i can show him a way to do it in an intergrated way. He may need those three values for specfic reason but once I know their purpose i could build a better logic branch than that.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
If I understood what you are trying to ask, you need to create a Rule which says:
When Any conditions are valid:
Attribute Game.RandomPosition = 1
Attribute Game.RandomPosition = 2
Attribute Game.RandomPosition = 3
Then insert your behavior or attribute.
Pure speculation on my part: I imagine that when GameSalad was made, they thought of a person with no programming skills whatsoever, or of using colloquial English. The Rule behavior is really an "if-then" statement, where "all" is "and", and "any" is "or".
Edit: You need to have a Change Attribute behavior which would say:
Change Attribute Game.RandomPosition to random(1,3)
somewhere before the Rule.
My Blog / App Store / Google Play
True, true!
At the pace my actors are being spawned, the random generator doesn't look random at all. With a doodle jump type game the platforms as in going up are half the time going left to right in a line and not randomly placed. That's why. I was going to have 3 attributes constantly changing the spawn position on the X and choose one of 3 to see if it made it any better
You could put your 3 random X positions in a table and then randomly pick one of the 3 rows i.e.:
self.Position.X = tableCellValue(table name, random(1,3), 1)
I may have got the rows and columns the wrong way around in that example.
And if you want those 3 values to change throughout the game you would just update the table cells with the new values.
If you don't want to use tables then have 3 rules and an attribute to store the random number i.e.:
Change Attribute: self.randomNo = random(1, 3)
Rule: If self.randomNo = 1
..Change Attribute: self.Position.X = game.attribute1
Rule: If self.randomNo = 2
..Change Attribute: self.Position.X = game.attribute2
Rule: If self.randomNo = 3
..Change Attribute: self.Position.X = game.attribute3
thanks for the help, worked out well like this, seems a bit more random