- Home /
Setting an int through function update
Here is an example script:
MinimumWage = MinimumWage - Poverty/10;
So, what I want is function update constantly checking that "MinimumWage" equals Poverty/10. But, it constantly minus's the number every function which I get and understand. I don't want to add any extra variables... like"
if(CheckMinimumWage == true){
LawMinimumWage = LawMinimumWage - Poverty/10;
}
This is so hard to explain... So I only want the script to do the math once, but constantly check if it has to do the math, without it going crazy and going into the negatives.
For Example, if MinimumWage = 20, And Poverty = 100, I want the script to do the math once, and MinimumWage to equal 10 in the end. (Also, it cant be a "one time function" I need it to work for constant changes in Poverty and or MinimumWage)
Is there any easy way out of this? or do I need a bunch of variables added (that I don't want) Sorry if I cant explain this well... Any help is appreciated.
You decreasing your value every call, use it only for "info", and make all math in other one, look i add new answer.
Answer by StormSabotage · Dec 10, 2013 at 09:36 PM
maybe you should create 1 new variable like "NewMinimumWage" and use it? because in that way your MinimumWage will not decrease.
float NewMinimumWage = 0;
NewMinimumWage = MinimumWage - Poverty/10;
I had thought of that, and it seems as though it might have to be the path I'll have to take. If nothing else comes up, Ill go with this.
you can declare "New$$anonymous$$inimumWage" in top and set 0 at Start() for example, after that you will use it to take math result and interact with it, your "$$anonymous$$inimumWage" will just say value and will not be changed nowhere.
Answer by Peter G · Dec 10, 2013 at 02:03 AM
If I'm understanding your question correctly, you shouldn't need any other variables.
Can you do something like this:
int minimumWage;
int poverty;
function Update () {
if(minimumWage < poverty/10)
minimumWage = poverty/10;
}
Nope, doesn't work, same problem. Thanks for trying though.
Your answer