Constantly updated Variable
7 posts • Page 1 of 1
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
- Code: Select all
scene.my.varex = scene.my.varex * 0.9
-
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.
[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.
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.
-
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.
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 consoleso i do that and now it is at 150 then i type in the console
- Code: Select all
scene.my.varex = scene.my.varex * 1.5
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?
- Code: Select all
scene.my.varex = scene.my.varex * 0.9
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
7 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 4 guests