Page 1 of 1

Constantly updated Variable

PostPosted: Fri Dec 11, 2009 12:59 am
by niffirg1
So I was running a scene and i set a variable (Lets say scene.my.varex) equal to lets say 100 and i type in the console
Code: Select all
scene.my.varex = scene.my.varex * 1.5
so i do that and now it is at 150 then i type in the console
Code: Select all
scene.my.varex = scene.my.varex * 0.9
So then thinking it would spit out 135 it spits out 90. So then i realized the variable is staying at 100 instead of being updated to 150. Then i thought of an argument taking function to constantly update the scene.my.varex but could not figure it out. Any Help please?

Re: Constantly updated Variable

PostPosted: Fri Dec 11, 2009 1:33 am
by KarateBrot
{ } - brackets tell algodoo that the code between it is a variable. Otherwise it will be treaten like a constant.

That's why you always have to put the code in the scripting menu between { } - brackets to let it refresh all the time and not only once.


[Edit]
Oh, wait. I didn't understand your problem I think.
I did what you described but it gave me the value of 135. It works for me. Make a new scene and test it again.

Re: Constantly updated Variable

PostPosted: Fri Dec 11, 2009 4:14 am
by niffirg1
Let me explain more clearly ok so i set a variable to 100 and it is being multiplied constantly by a number between -10 and 10. So when the number it 5 then the 100 is turned to a 500 because the variable is being multiplied by that number then the number changes to 2 the variable changes to 200 and i expected it to turn to 100000. Is that a better explanation

Re: Constantly updated Variable

PostPosted: Fri Dec 11, 2009 4:31 am
by KarateBrot
niffirg1 wrote:Let me explain more clearly ok so i set a variable to 100 and it is being multiplied constantly by a number between -10 and 10. So when the number it 5 then the 100 is turned to a 500 because the variable is being multiplied by that number then the number changes to 2 the variable changes to 200 and i expected it to turn to 100000. Is that a better explanation


What do you expect to turn to 100,000? The variable or something else? Because if you just multiply the variable by 2 it would be 1,000 and not 100,000. That's what's unclear. Sorry that I'm aksing too much but I need to know exactly what needs to be calculated :D

Re: Constantly updated Variable

PostPosted: Fri Dec 11, 2009 4:36 am
by niffirg1
The variable and i multiplied it by 200 not 2

Re: Constantly updated Variable

PostPosted: Fri Dec 11, 2009 4:58 am
by KarateBrot
I still can't get what you want to say. It doesn't make sense to me that in the second step the number is changing to 2, then the variable changing to 200 and then to 100,000.
I'll just post an algorithm. Tell me if it's correct or what's wrong.

  • variable = 100

    loop:
  • number = random(-10,10)
  • variable = variable * number

Re: Constantly updated Variable

PostPosted: Fri Dec 11, 2009 5:37 am
by Kilinich
niffirg1 wrote:So I was running a scene and i set a variable (Lets say scene.my.varex) equal to lets say 100 and i type in the console
Code: Select all
scene.my.varex = scene.my.varex * 1.5
so i do that and now it is at 150 then i type in the console
Code: Select all
scene.my.varex = scene.my.varex * 0.9
So then thinking it would spit out 135 it spits out 90. So then i realized the variable is staying at 100 instead of being updated to 150. Then i thought of an argument taking function to constantly update the scene.my.varex but could not figure it out. Any Help please?

Just use this code
Code: Select all
scene.my.varex = 0.9 * scene.my.varex