Jump to content




Dash - L2drive a manual car!


17 replies to this topic

#1 Dave-ee Jones

  • Members
  • 456 posts
  • LocationVan Diemen's Land

Posted 25 August 2017 - 01:12 AM

DASH
Dave-ee's Dash (as in car dash..)




Have you ever wanted to learn how to drive a manual in ComputerCraft? (pretend that you have)
Well, this should do the trick. I haven't implemented a speedometer / speed in general but most other mechanics (ha, a pun..) of a car's transmission and engine are implemented. Basically you can change gears, rev the car up nice and good, oh, and don't forget to start the car first. YES, it is possible to stall the car..(l2use clutch peeps..).

How does it work?
Well, you can start the car by holding down the clutch (default key: Left Ctrl) and then clicking and holding on the ignition for 1 second (the ignition is the little box on the left of the gearstick, has a "key" in it). Once that is green you can go into first gear by pressing the Up Arrow, because you are, by default, in Neutral. The Up Arrow and Down Arrow change gears, up and down respectively. You can go back to neutral, or even reverse, by using the default keys N and M respectively (N for neutral, M for reverse).

The accelerator's key is, by default Right Alt and the brake's key is, by default, Space.

I keep stalling it!
Yep. Keep in mind that you need to give it some rev before you "dump the clutch" (let the clutch out - release Left Ctrl), otherwise you will stall the car. Also keep in mind that if your RPMs are too low (below 500) when in a gear higher than 3, you will stall as you don't have enough revs to keep your gear. Also, make sure you put the clutch in before and during you changing gears.

What in the world were you thinking when you coded *such-and-such*?
Keep in mind I'm not a car-mechanic expert, I don't claim to know everything about transmissions, gear-ratios and car control in general. This is just a few basic calculations for the simple-learning.

I also have yet to fix the rev-changing when you gear change. In a real manual if you go up a gear your RPMs go down, if you go down a gear the RPMs go up. This isn't exactly implemented yet (it kind of is but it isn't accurate).

Will you implement speed?
Eventually, probably, but it's far more difficult than a tachometer because it means many more ways of stalling, gear changing and, maybe, even rev matching!

I noticed you have the TRANSMISSION variable, does this mean you are going to add an Automatic feature?
Yep, probably. It just means it will automatically enable the clutch and change gears when it needs to. You will still be able to override to neutral/reverse using the normal method.

There's just..something..missing..It doesn't feel right..
I KNOW! NO SOUND!! UGHHHHHH! Driving me crazy!

Can I use this as background code for a car game I want to make?
Sure. No need to ask. I would love to be in the credits but it's not required.

Can there be like a "Great shift!", "Too much rev!", "Woah, gear is way too high for this speed!"?
Well, maybe. It would be a good idea, make it more interactive and intuitive, but not right now. Maybe later.

No pics, no cli-
http://imgur.com/a/PcbLS




Pastebin:

pastebin get DGcyaue7 dash


PLEASE give suggestions and feedback because I know there is a lot that needs to be done to make this complete!


Edited by Dave-ee Jones, 31 August 2017 - 06:12 AM.


#2 Saldor010

  • Members
  • 467 posts
  • LocationThe United States

Posted 25 August 2017 - 01:24 AM

Looks very interesting! I'll have to try it out when I get a chance.

#3 Exerro

  • Members
  • 801 posts

Posted 25 August 2017 - 10:18 AM

View PostDave-ee Jones, on 25 August 2017 - 01:12 AM, said:

There's just..something..missing..It doesn't feel right..
I KNOW! NO SOUND!! UGHHHHHH! Driving me crazy!

Heh, I see what you did there.

Interesting idea though. I've never thought of making a real-world education program inside CC. I wonder what drivers would think of this, whether it's realistic or not.

#4 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 25 August 2017 - 10:45 AM

View PostExerro, on 25 August 2017 - 10:18 AM, said:

I wonder what drivers would think of this, whether it's realistic or not.
Something which immediately sticks out is that you can't control how far down the clutch is, so it can't sit at the "biting point". None the less, it's a pretty cool program. Now we need a way to rig up some gaming pedals :P.

#5 Lupus590

  • Members
  • 2,029 posts
  • LocationUK

Posted 25 August 2017 - 11:07 AM

View PostSquidDev, on 25 August 2017 - 10:45 AM, said:

Now we need a way to rig up some gaming pedals :P.

What's the easiest way to make analog redstone signals? Would redstone have enough resolution for controllers?

#6 The Crazy Phoenix

  • Members
  • 136 posts
  • LocationProbably within 2 metres of my laptop.

Posted 25 August 2017 - 05:06 PM

View PostLupus590, on 25 August 2017 - 11:07 AM, said:

View PostSquidDev, on 25 August 2017 - 10:45 AM, said:

Now we need a way to rig up some gaming pedals :P.

What's the easiest way to make analog redstone signals? Would redstone have enough resolution for controllers?

That solution would require a mod that adds a block that outputs a redstone signal between 0 and 15 based on the position of the analog input.
Redstone should have enough resolution to avoid stalling, but it wouldn't be smooth.

#7 Dave-ee Jones

  • Members
  • 456 posts
  • LocationVan Diemen's Land

Posted 26 August 2017 - 12:10 AM

View PostSquidDev, on 25 August 2017 - 10:45 AM, said:

View PostExerro, on 25 August 2017 - 10:18 AM, said:

I wonder what drivers would think of this, whether it's realistic or not.
Something which immediately sticks out is that you can't control how far down the clutch is, so it can't sit at the "biting point". None the less, it's a pretty cool program. Now we need a way to rig up some gaming pedals :P.

Yep, that's the thing. Unfortunately the only way I could fix that is utilise the mouse and use a dragging feature or something.

I was actually looking at my racing pedals in the other corner while making this going "sorry, you can't help me with this one :(". If only..

View PostLupus590, on 25 August 2017 - 11:07 AM, said:

View PostSquidDev, on 25 August 2017 - 10:45 AM, said:

Now we need a way to rig up some gaming pedals :P.

What's the easiest way to make analog redstone signals? Would redstone have enough resolution for controllers?

Oo that would be interesting..I kinda wanted to use the gearstick for dragging as well, like have the user drag the gearstick to the right gear but doing that while having your fingers awkwardly placed on the keyboard wasn't ideal..

View PostThe Crazy Phoenix, on 25 August 2017 - 05:06 PM, said:

View PostLupus590, on 25 August 2017 - 11:07 AM, said:

View PostSquidDev, on 25 August 2017 - 10:45 AM, said:

Now we need a way to rig up some gaming pedals :P.

What's the easiest way to make analog redstone signals? Would redstone have enough resolution for controllers?

That solution would require a mod that adds a block that outputs a redstone signal between 0 and 15 based on the position of the analog input.
Redstone should have enough resolution to avoid stalling, but it wouldn't be smooth.

Yep. That's the only solution I can think of. A peripheral that records controller/pedal input and the computer can read that.

#8 MineRobber___T

  • Members
  • 50 posts
  • LocationStop being nosy

Posted 26 August 2017 - 01:21 AM

View PostDave-ee Jones, on 25 August 2017 - 01:12 AM, said:

-snip-
There's just..something..missing..It doesn't feel right..
I KNOW! NO SOUND!! UGHHHHHH! Driving me crazy!
-snip-

I suggest adding a condition where, if speakers are attached, you play a low note (like
speaker.playNote("guitar",100,0)
) continuously. That way, you get the hum of the running car.

#9 Dave-ee Jones

  • Members
  • 456 posts
  • LocationVan Diemen's Land

Posted 26 August 2017 - 11:52 AM

View PostMineRobber___T, on 26 August 2017 - 01:21 AM, said:

View PostDave-ee Jones, on 25 August 2017 - 01:12 AM, said:

-snip-
There's just..something..missing..It doesn't feel right..
I KNOW! NO SOUND!! UGHHHHHH! Driving me crazy!
-snip-

I suggest adding a condition where, if speakers are attached, you play a low note (like
speaker.playNote("guitar",100,0)
) continuously. That way, you get the hum of the running car.

Yeah I was thinking about that, and it would be fun to implement the rev sound.

#10 Lupus590

  • Members
  • 2,029 posts
  • LocationUK

Posted 26 August 2017 - 12:00 PM

View PostDave-ee Jones, on 26 August 2017 - 12:10 AM, said:

View PostSquidDev, on 25 August 2017 - 10:45 AM, said:

View PostExerro, on 25 August 2017 - 10:18 AM, said:

I wonder what drivers would think of this, whether it's realistic or not.
Something which immediately sticks out is that you can't control how far down the clutch is, so it can't sit at the "biting point". None the less, it's a pretty cool program. Now we need a way to rig up some gaming pedals :P.

Yep, that's the thing. Unfortunately the only way I could fix that is utilise the mouse and use a dragging feature or something.

I was actually looking at my racing pedals in the other corner while making this going "sorry, you can't help me with this one :(". If only..

View PostLupus590, on 25 August 2017 - 11:07 AM, said:

View PostSquidDev, on 25 August 2017 - 10:45 AM, said:

Now we need a way to rig up some gaming pedals :P.

What's the easiest way to make analog redstone signals? Would redstone have enough resolution for controllers?

Oo that would be interesting..I kinda wanted to use the gearstick for dragging as well, like have the user drag the gearstick to the right gear but doing that while having your fingers awkwardly placed on the keyboard wasn't ideal..

View PostThe Crazy Phoenix, on 25 August 2017 - 05:06 PM, said:

View PostLupus590, on 25 August 2017 - 11:07 AM, said:

View PostSquidDev, on 25 August 2017 - 10:45 AM, said:

Now we need a way to rig up some gaming pedals :P.

What's the easiest way to make analog redstone signals? Would redstone have enough resolution for controllers?

That solution would require a mod that adds a block that outputs a redstone signal between 0 and 15 based on the position of the analog input.
Redstone should have enough resolution to avoid stalling, but it wouldn't be smooth.

Yep. That's the only solution I can think of. A peripheral that records controller/pedal input and the computer can read that.

or you make use of http to communicate with a non-CC program which can use real world hardware

#11 The Crazy Phoenix

  • Members
  • 136 posts
  • LocationProbably within 2 metres of my laptop.

Posted 26 August 2017 - 07:41 PM

Wouldn't that have the massive overhead of opening the socket every time you try to read from the controller.

You might get away with partial responses (allowing you to send an infinite amount of data in response to 1 GET) but that's only if CC supports it, and the server wouldn't know when to stop sending inputs.

#12 H4X0RZ

  • Members
  • 1,315 posts
  • LocationGermany

Posted 27 August 2017 - 01:27 AM

View PostThe Crazy Phoenix, on 26 August 2017 - 07:41 PM, said:

Wouldn't that have the massive overhead of opening the socket every time you try to read from the controller.

You might get away with partial responses (allowing you to send an infinite amount of data in response to 1 GET) but that's only if CC supports it, and the server wouldn't know when to stop sending inputs.

Depending on your CC version and the mods you have installed you can use actual (web)sockets (the mod in question is CCTweaks). I even got a "native" discord client somewhat working that way.

#13 Dave-ee Jones

  • Members
  • 456 posts
  • LocationVan Diemen's Land

Posted 27 August 2017 - 06:29 AM

View PostLupus590, on 26 August 2017 - 12:00 PM, said:

-snip-
or you make use of http to communicate with a non-CC program which can use real world hardware

Yes, that's definitely possible but would be quite slow. Even if it was for an internal HTTP request on an internal website it was still be pretty slow..The best way would be for someone to make a custom peripheral that can make sound, obviously being able to be 'used' by a CC computer. Would be very nice. A noteblock could work I suppose but it would sound quite weird..

#14 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 27 August 2017 - 06:53 AM

View PostDave-ee Jones, on 27 August 2017 - 06:29 AM, said:

The best way would be for someone to make a custom peripheral that can make sound, obviously being able to be 'used' by a CC computer. Would be very nice. A noteblock could work I suppose but it would sound quite weird..
Could you put a custom sound is a resource pack, and play it using an iron noteblock/speaker (or anything that supports playing sounds by resource name)? It's a bit of a faff, but easier than creating a new mod.

#15 Dave-ee Jones

  • Members
  • 456 posts
  • LocationVan Diemen's Land

Posted 27 August 2017 - 09:48 AM

View PostSquidDev, on 27 August 2017 - 06:53 AM, said:

View PostDave-ee Jones, on 27 August 2017 - 06:29 AM, said:

The best way would be for someone to make a custom peripheral that can make sound, obviously being able to be 'used' by a CC computer. Would be very nice. A noteblock could work I suppose but it would sound quite weird..
Could you put a custom sound is a resource pack, and play it using an iron noteblock/speaker (or anything that supports playing sounds by resource name)? It's a bit of a faff, but easier than creating a new mod.

Yep, good idea. If someone else made one I'd be happy to add it in! I say that because I don't know how, and it might be better if someone else does it.

#16 Lupus590

  • Members
  • 2,029 posts
  • LocationUK

Posted 27 August 2017 - 12:51 PM

View PostDave-ee Jones, on 27 August 2017 - 06:29 AM, said:

View PostLupus590, on 26 August 2017 - 12:00 PM, said:

-snip-
or you make use of http to communicate with a non-CC program which can use real world hardware

Yes, that's definitely possible but would be quite slow. Even if it was for an internal HTTP request on an internal website it was still be pretty slow..The best way would be for someone to make a custom peripheral that can make sound, obviously being able to be 'used' by a CC computer. Would be very nice. A noteblock could work I suppose but it would sound quite weird..

I was thinking more of for the pedals/analogue input.

#17 Dave-ee Jones

  • Members
  • 456 posts
  • LocationVan Diemen's Land

Posted 28 August 2017 - 12:15 AM

View PostLupus590, on 27 August 2017 - 12:51 PM, said:

View PostDave-ee Jones, on 27 August 2017 - 06:29 AM, said:

View PostLupus590, on 26 August 2017 - 12:00 PM, said:

-snip-
or you make use of http to communicate with a non-CC program which can use real world hardware

Yes, that's definitely possible but would be quite slow. Even if it was for an internal HTTP request on an internal website it was still be pretty slow..The best way would be for someone to make a custom peripheral that can make sound, obviously being able to be 'used' by a CC computer. Would be very nice. A noteblock could work I suppose but it would sound quite weird..

I was thinking more of for the pedals/analogue input.

Yeah, sorry, I just trailed off somewhere, but it would still be the same kinda thing..But you could still do a similar thing with the block that catches the analog input and the CC computer can read it. I would love it if I had that working, because I could port it to CraftOS 2.0 (maybe..) and make a driving game based on this, with the analog input. Would be pretty nice, until you realise DiRT Rally is a better option and start playing that instead :P

I've got a seat made of PVC pipe that has a Logitech G29 wheel, base and shifter which is a lot of fun - even more so with VR (just can't play it as long :wacko:)

Edited by Dave-ee Jones, 28 August 2017 - 06:16 AM.


#18 Dave-ee Jones

  • Members
  • 456 posts
  • LocationVan Diemen's Land

Posted 28 August 2017 - 03:46 AM

UPDATE!
Okay so I've added speed! It wasn't OVERLY hard but unfortunately it is a theoretical speed based on gear ratios, RPM and tyre diameter. You can change defaults in the config at the start of the program if you wish, have a play, but I wouldn't advise it unless you know what you're doing or you know that what I've done may be stupid and/or silly.

You can tell it's theoretical when you change from 1st to 2nd and your speed jumps by like 10mph..There's no acceleration (smooth speed acceleration, anyway) so you can go from Neutral to 1st gear and be at 20mph from 0 instantly. Bit annoying but I can't work out how to have a smooth acceleration while gear changing, as the speed is a theoretical speed based on what I said earlier, it doesn't take into account current speed/gear/RPM.

If you play around with the tyre diameter and the gear ratios you can see what it does to the speed/RPM as well, so have a play with that! Comment your fastest speed setup, as well, I'd be interested to see if anyone can get a nice gear ratio setup with a good tyre diameter. Keep in mind even if you get your speed up to like a crazy 100000 or something your car will never make that speed because you have to take into account the maximum power output your car has. Might implement that at some point too, not sure though - it's a lot of work.

Any suggestions would be great! :) For now, I hope you enjoy the speed!

EDIT: Was playing DiRT Rally and my back wheel came off, so I ended up revving it up to like 8000rpm and it said my speed was 120km/h when I could clearly see I wasn't moving 20km/h..So that's also theoretical as well :P

Edited by Dave-ee Jones, 31 August 2017 - 06:09 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users