Unpolished gearbox
14 posts • Page 1 of 1
Unpolished gearbox
I know that a few of these have been made in the past, but i thought i would take a crack
I have never been a master at thyme, but i am slowly learning. (Thankyou grady, for showing me that program, notepad++ (Its pretty handy)).
- Code: Select all
// Gear 1. Less than 35
scene.my.velocity(0) < 17.5 ? {scene.my.one = 0; scene.my.zero = 0; scene.my.seven = 0; scene.my.two = 0; scene.my.six = 0; scene.my.five = 0; scene.my.three = 2; scene.my.four = 2} : {}
//Gear 1 Shift up to 2
scene.my.velocity(0) > 17.5 && scene.my.velocity(0) < 32 ? {scene.my.three = 0; scene.my.zero = 0; scene.my.seven = 0; scene.my.one = 0; scene.my.six = 0; scene.my.four = 0; scene.my.two = 2; scene.my.five = 2} : {}
//Gear 2 shift up to gear 3
scene.my.velocity(0) > 32 && scene.my.velocity(0) < 59.5 ? {scene.my.two = 0; scene.my.zero = 0; scene.my.seven = 0; scene.my.four = 0; scene.my.three = 0; scene.my.five = 0; scene.my.one = 2; scene.my.six = 2} : {}
//Gear 3 shift up to gear 4
scene.my.velocity(0) > 59.5 ? {scene.my.one = 0; scene.my.two = 0; scene.my.three = 0; scene.my.four = 0; scene.my.five = 0; scene.my.six = 0; scene.my.zero = 2; scene.my.seven = 2} : {}
//Gear Visual
scene.my.velocity(0) < 17.5 ? {scene.my.gear = 1} : {}; scene.my.velocity(0) > 17 && scene.my.velocity(0) < 32 ? {scene.my.gear = 2} : {}; scene.my.velocity(0) > 32 ? {scene.my.gear = 3} :{}; scene.my.velocity(0) > 59.5 ? {scene.my.gear = 4} : {}
I have never been a master at thyme, but i am slowly learning. (Thankyou grady, for showing me that program, notepad++ (Its pretty handy)).
-

kilebantick - Posts: 1267
- Joined: Tue Sep 01, 2009 9:50 am
Re: Unpolished gearbox
Too much unnecessary code.
One scene.my.gear is enough.
Put some code in gearbox circles like:
collideSet = {scene.my.gear == 1 ? 1 : 0}
and that's all
One scene.my.gear is enough.
Put some code in gearbox circles like:
collideSet = {scene.my.gear == 1 ? 1 : 0}
and that's all
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: Unpolished gearbox
I don't know, i am not a master at thyme, actually, i am pretty terrible with it 
-

kilebantick - Posts: 1267
- Joined: Tue Sep 01, 2009 9:50 am
Re: Unpolished gearbox
I don't think you're bad at thyme.
To calculate the absolute velocity you don't need thyme. It's maths. You only have to translate it to thyme. You need to know about how to calculate the length of a vector.
So the "real" velocity/speed (velocity(0) and velocity(1) value put together) is:
speed = √( v(0)² + v(1)² )
It doesn't make any difference if you choose scene.my.speed or scene.my.velocity(0) if you just let it move on an horizontal plane. But it will make a difference if you let it climb hills. So if it doesn't move horizontally all the time you have to choose scene.my.speed.
To calculate the absolute velocity you don't need thyme. It's maths. You only have to translate it to thyme. You need to know about how to calculate the length of a vector.
So the "real" velocity/speed (velocity(0) and velocity(1) value put together) is:
speed = √( v(0)² + v(1)² )
- Code: Select all
scene.my.speed = ( scene.my.velocity(0)^2 + scene.my.velocity(1)^2 )^0.5
It doesn't make any difference if you choose scene.my.speed or scene.my.velocity(0) if you just let it move on an horizontal plane. But it will make a difference if you let it climb hills. So if it doesn't move horizontally all the time you have to choose scene.my.speed.

-

KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Unpolished gearbox
TOO...CONFUSING!!! This is why I almost never use thyme. It gives me a headache...
-

Sonic - Posts: 1467
- Joined: Tue Sep 01, 2009 6:18 pm
- Location: America!!!
Re: Unpolished gearbox
...I am? I wasn't trying to be. I just like to share my opinion on things.
-

Sonic - Posts: 1467
- Joined: Tue Sep 01, 2009 6:18 pm
- Location: America!!!
Re: Unpolished gearbox
Sonic wrote:TOO...CONFUSING!!! This is why I almost never use thyme. It gives me a headache...
And that constitutes as an opinion?
Anyway, I can see what you're trying to get at with this scene.I can definitely tell what you mean by unpolished. Also, check the console while you're running the scene. Here's what I am getting in the console:
- Code: Select all
-- Warning: Exception thrown: Not a real from /Users/nils/Work/phun/trunk/xcode/../Source/script/ValueConversions.cpp:32: T script::ObjectToValue(script::ObjectPtr) [with T = Long Double]
In your script you are dividing by zero!
-

standardtoaster - Posts: 606
- Joined: Mon Aug 31, 2009 7:57 pm
Re: Unpolished gearbox
That's weird. How does that work out if they both equal zero?
-

Sonic - Posts: 1467
- Joined: Tue Sep 01, 2009 6:18 pm
- Location: America!!!
Re: Unpolished gearbox
standardtoaster wrote:In your script you are dividing by zero!You have it so that scene.my.LTRBL = Sim.time. Then you subtract that from sim.time. You are always going to get zero. You also have scene.my.AHPD = e.pos and then you take the same position and subtract it. That means you are supposed to be getting [0/0, 0/0]! And yet, somehow, it calculates the velocity.
No, he's not dividing by zero. You have to look at the order of the variables and the calculation of the velocity. first velocity gets calculated, after that Scene.my.LTRBL = sim.time and scene.my.AHPD = e.pos.
To make it clearer:
1)
the code starts velocity gets calculated
2)
sim.time and e.pos get assigned to the variables.
for example Scene.my.LTRBL = 3.50 and scene.my.AHPD = [6.3,0]
3)
the code ends, algodoo does one simulation step, and the code starts again.
4)
velocity gets calculated with the values of the simulation step before and the actual values.
for example ([6.8,0] - [6.3,0]) / (3.51 - 3.50) and that's [0.5,0] / 0.01 there's no zero.
So they are not the same.

-

KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Unpolished gearbox
Right. I forgot that it went in the order it was typed. Never mind what I had said about dividing by zero then. Kile still needs to look into why it gets the error in the console that I had said.
-

standardtoaster - Posts: 606
- Joined: Mon Aug 31, 2009 7:57 pm
Re: Unpolished gearbox
yes it's weird sometimes. i recognized that you get an error for an unknown reason sometimes 

-

KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Unpolished gearbox
standardtoaster wrote:Sonic wrote:TOO...CONFUSING!!! This is why I almost never use thyme. It gives me a headache...
And that constitutes as an opinion?
Anyway, I can see what you're trying to get at with this scene.I can definitely tell what you mean by unpolished. Also, check the console while you're running the scene. Here's what I am getting in the console:
- Code: Select all
-- Warning: Exception thrown: Not a real from /Users/nils/Work/phun/trunk/xcode/../Source/script/ValueConversions.cpp:32: T script::ObjectToValue(script::ObjectPtr) [with T = Long Double]
In your script you are dividing by zero!You have it so that scene.my.LTRBL = Sim.time. Then you subtract that from sim.time. You are always going to get zero. You also have scene.my.AHPD = e.pos and then you take the same position and subtract it. That means you are supposed to be getting [0/0, 0/0]! And yet, somehow, it calculates the velocity.
That timer Speedometre is grady's code, so talk to him about it.
-

kilebantick - Posts: 1267
- Joined: Tue Sep 01, 2009 9:50 am
14 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 6 guests






