## Constantly updated Variable

### Constantly updated Variable

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?

niffirg1

Posts: 376
Joined: Mon Aug 31, 2009 10:31 pm
Location: The Great American South!

### Re: Constantly updated Variable

{ } - 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.

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.

KarateBrot

Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

### Re: Constantly updated Variable

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

niffirg1

Posts: 376
Joined: Mon Aug 31, 2009 10:31 pm
Location: The Great American South!

### Re: Constantly updated Variable

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

KarateBrot

Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

### Re: Constantly updated Variable

The variable and i multiplied it by 200 not 2

niffirg1

Posts: 376
Joined: Mon Aug 31, 2009 10:31 pm
Location: The Great American South!

### Re: Constantly updated Variable

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

KarateBrot

Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

### Re: Constantly updated Variable

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`
Dream of Algodoo as game development engine...

Kilinich
[Best bug reporter 2010]

Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia