[SOLVED]Please explain this math.
7 posts • Page 1 of 1
[SOLVED]Please explain this math.
When I add two variables, I get the result that I expect. For example:
a = 1;
b = 2;
a + b == 3
But when I add a variable to an array element, I do not get the result that I expect. For example:
a = 1;
b = 2;
scene.my.array = [3];
a + b + scene.my.array(0) == 123
Take a look at the scene I included here and explain WHY this is happening. If this is not a bug, then please explain how I can add a variable and an array element, and come up with the result that I would expect.
Thanks
a = 1;
b = 2;
a + b == 3
But when I add a variable to an array element, I do not get the result that I expect. For example:
a = 1;
b = 2;
scene.my.array = [3];
a + b + scene.my.array(0) == 123
Take a look at the scene I included here and explain WHY this is happening. If this is not a bug, then please explain how I can add a variable and an array element, and come up with the result that I would expect.
Thanks
- Attachments
-
What's Happening_.phz- (13.18 KiB) Downloaded 21 times
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Please explain this math.
Seams like an issue with the way text is evaluated.
Open the script menu of the box, and type the following into
as a workaround, just use a laser or use another method to create the variable needed.
In the next version of algodoo, it seams like we will be able to run code without requiring an laser or collision driven event!
Open the script menu of the box, and type the following into
- Code: Select all
_c = _a + _b + scene.my.array(0)
as a workaround, just use a laser or use another method to create the variable needed.
In the next version of algodoo, it seams like we will be able to run code without requiring an laser or collision driven event!
When asking for help, READ THE STICKIES!
- electronicboy
- Posts: 1694
- Joined: Mon Aug 31, 2009 6:18 pm
Re: Please explain this math.
electronicboy wrote:Seams like an issue with the way text is evaluated.
Open the script menu of the box, and type the following into
- Code: Select all
_c = _a + _b + scene.my.array(0)
as a workaround, just use a laser or use another method to create the variable needed.
In the next version of algodoo, it seams like we will be able to run code without requiring an laser or collision driven event!
This isn't text! The same thing occurs when adding variables and array elements in OnCollide, and HitByLaser, and even in the console. TRY IT!
EDIT: I just now tried it again in OnCollide and it worked correctly. I don't know why I got a crazy answer earlier when I tried it, but now it's coming up with the correct answer. I believe you are right about it having something to do with TEXT. It seems to give the correct answer except when calculated in a text box.
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Please explain this math.
one of your variables was text not number, but you can't see it in console - a = "1" and a = 1 will looks like 1
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
Re: Please explain this math.
Kilinich wrote:one of your variables was text not number, but you can't see it in console - a = "1" and a = 1 will looks like 1
Yes, I just now realized that. So, apparently, if even ONE of the variables is text, then ALL of the variables are evaluated as text.
Thanks guys!
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: [SOLVED]Please explain this math.
Added [SOLVED] in this topic title 
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
-

tatt61880 - [Most Helpful Person 2010]
- Posts: 1150
- Joined: Mon Aug 31, 2009 5:45 pm
- Location: Tokyo, Japan
Re: [SOLVED]Please explain this math.
Thanks, Tatt! 
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
7 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 4 guests



