Problem with a rule
![casparwylie](http://forums.gamesalad.com/applications/dashboard/design/images/defaulticon.png)
Ok, this might be hard to explain.....
I have made a rule: When Attribute game.test = 1 {
timer{
after: 7secs
change attribute {game.test to: game.test - 1}
change attribute {game.all_money to: game.all_money + 50}
}
}
So you might be able to see whats going on, this works, but if i want it to be When Attribute game.test = 2 { do something slightly different}, then When Attribute game.test = 3 { do something slightly different}, ETC.
Is there a way of making this one rule, and just teach the rule a pattern?
it would take 80 rules to accomplish my intention!
If i have not explained very well, please say!
Any ideas?
Thank you!
I have made a rule: When Attribute game.test = 1 {
timer{
after: 7secs
change attribute {game.test to: game.test - 1}
change attribute {game.all_money to: game.all_money + 50}
}
}
So you might be able to see whats going on, this works, but if i want it to be When Attribute game.test = 2 { do something slightly different}, then When Attribute game.test = 3 { do something slightly different}, ETC.
Is there a way of making this one rule, and just teach the rule a pattern?
it would take 80 rules to accomplish my intention!
If i have not explained very well, please say!
Any ideas?
Thank you!
Best Answers
-
mikelowe Posts: 177
I have an idea.... not sure it would work...
1. Make a BOOL attribute called startCheck
2. Wherever in your code that you want to call the rule you gave in your post, set startCheck TRUE
2. Make a new integer attribute in this actor (lets call it "check")
3. If startCheck = TRUE: Make a timer that says every .01 seconds, change check to check + 1
4. In this timer, also put the rule that you have checking if test = 1, but instead of making it 1, make it the new attribute called check
So now, every .01 seconds, it will change check to the next value (after .01 seconds it will be 2, after .02 seconds it will be 3, etc....). It will also run that rule each time the timer ticks.
5. Put a rule in the timer that says, if check = 80, change attribute startCheck FALSE (this will prevent it from continuing to loop through numbers greater than 80)
So now comes the part that I am unsure about...
You want it to do something different for each value of "test" (1, 2, 3, 4,etc....)
Lets say that you want to add a different value of money for each value of test....
In step 2 you would also make an integer attribute (lets call it "money").
In step 3 you would say change attribute money to money + 5 (or however much you want to increase it)
Then you would change the rule you posted to say:
change attribute {game.all_money to: self.money}
Like I said, I have not tested this, but this is along the lines of how I would do this.
Hope I was of at least some help to you
- Michael
-
mikelowe Posts: 177
Yea no problem. Did it work? I hope this method can apply to what you are doing with 80 different cases.
Answers
every time the timer ticks, self.money = self.money + 5
every time the rule is called, game.money = self.money