Unpolished gearbox

Discuss scenes and videos made with Algodoo.

Unpolished gearbox

Postby kilebantick » Mon Nov 30, 2009 11:31 am

I know that a few of these have been made in the past, but i thought i would take a crack


Rating: rated 5.3
Filesize: 70.98 kB
Comments: 3
Ratings: 2
download






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)).
Image
User avatar
kilebantick
 
Posts: 1267
Joined: Tue Sep 01, 2009 9:50 am

Re: Unpolished gearbox

Postby Kilinich » Mon Nov 30, 2009 2:10 pm

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
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Unpolished gearbox

Postby KarateBrot » Mon Nov 30, 2009 2:48 pm

Why do you only use velocity(0) instead of the absolute velocity?
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: Unpolished gearbox

Postby kilebantick » Tue Dec 01, 2009 7:15 am

I don't know, i am not a master at thyme, actually, i am pretty terrible with it :(
Image
User avatar
kilebantick
 
Posts: 1267
Joined: Tue Sep 01, 2009 9:50 am

Re: Unpolished gearbox

Postby KarateBrot » Tue Dec 01, 2009 12:59 pm

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)² )
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.
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: Unpolished gearbox

Postby Sonic » Tue Dec 01, 2009 7:03 pm

TOO...CONFUSING!!! This is why I almost never use thyme. It gives me a headache...
I do stuff and break things. You know how it is.
Image
User avatar
Sonic
 
Posts: 1467
Joined: Tue Sep 01, 2009 6:18 pm
Location: America!!!

Re: Unpolished gearbox

Postby kilebantick » Wed Dec 02, 2009 7:35 am

Well, sonic, you are our new post whore :)
Image
User avatar
kilebantick
 
Posts: 1267
Joined: Tue Sep 01, 2009 9:50 am

Re: Unpolished gearbox

Postby Sonic » Wed Dec 02, 2009 6:03 pm

...I am? I wasn't trying to be. I just like to share my opinion on things.
I do stuff and break things. You know how it is.
Image
User avatar
Sonic
 
Posts: 1467
Joined: Tue Sep 01, 2009 6:18 pm
Location: America!!!

Re: Unpolished gearbox

Postby standardtoaster » Wed Dec 02, 2009 6:39 pm

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! :o 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. :|
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Unpolished gearbox

Postby Sonic » Wed Dec 02, 2009 6:52 pm

That's weird. How does that work out if they both equal zero?
I do stuff and break things. You know how it is.
Image
User avatar
Sonic
 
Posts: 1467
Joined: Tue Sep 01, 2009 6:18 pm
Location: America!!!

Re: Unpolished gearbox

Postby KarateBrot » Wed Dec 02, 2009 9:28 pm

standardtoaster wrote:In your script you are dividing by zero! :o 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.
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: Unpolished gearbox

Postby standardtoaster » Wed Dec 02, 2009 9:44 pm

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.
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Unpolished gearbox

Postby KarateBrot » Wed Dec 02, 2009 11:24 pm

yes it's weird sometimes. i recognized that you get an error for an unknown reason sometimes :?
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: Unpolished gearbox

Postby kilebantick » Thu Dec 03, 2009 7:42 am

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! :o 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.
Image
User avatar
kilebantick
 
Posts: 1267
Joined: Tue Sep 01, 2009 9:50 am


Return to Scenes

Who is online

Users browsing this forum: No registered users and 6 guests