[0.10.4+] Bumpers (not multiplayer compatible)

Topics and discussion about specific mods
Post Reply
Schmendrick
Fast Inserter
Fast Inserter
Posts: 222
Joined: Wed Apr 30, 2014 11:17 pm
Contact:

[0.10.4+] Bumpers (not multiplayer compatible)

Post by Schmendrick »

Well, this is a mod I've been wanting to make for a long time - and finally with 0.10.4, I can.

Bumpers works with one (or both) of two other mods: Roadworks and Floors. The Bumpers mod will let you install and activate it with neither of these selected, but it won't you much good.

A car (or, theoretically, any other vehicle) driving on a Roadworks road or one of the Floors will automatically steer itself to stay on the road, unless the player is steering to the left or right manually (so you can go off-roading if you want) Driving across a road in a straight line does become a little troublesome, since the car will try to "snap" to the road... but this is a small price to pay for the ease of not having to constantly watch out for pipes, power lines, and trees.

The car doesn't handle right angles very well, though, so you'll want to include a few diagonal-ish spaces for corners to help nudge it in the right direction (this is more true for Floors than for Roads).
bumpers.jpg
bumpers.jpg (115.79 KiB) Viewed 13549 times
I could probably stand to optimize the code a little, but since it only works on one vehicle (per player... someday...) at a time, I'm not particularly worried about it.

v.1.1.0: removed residual debug message, added mod interfaces
v.1.1.1: removed debug messages I added in 1.1.0, increased off-road-to-on-road detection rate, tweaked turning speed formula.~
v.1.1.2: trying not to keep being a dumbass (disabled more debug nonsense).


Dropbox
Attachments
bumpers.zip
(2.01 KiB) Downloaded 343 times
Last edited by Schmendrick on Sat May 09, 2015 8:13 pm, edited 5 times in total.
Like my mods? Check out another! Or see older, pre-0.12.0 mods.

omegasrevenge
Inserter
Inserter
Posts: 45
Joined: Sat Jul 12, 2014 8:54 am
Contact:

Re: [0.10.4+] Bumpers

Post by omegasrevenge »

The orgasm that I had after seeing this mod turned the entire interior of my house white.

User avatar
SHiRKiT
Filter Inserter
Filter Inserter
Posts: 706
Joined: Mon Jul 14, 2014 11:52 pm
Contact:

Re: [0.10.4+] Bumpers

Post by SHiRKiT »

omegasrevenge wrote:The orgasm that I had after seeing this mod turned the entire interior of my house white.
Wtf was that?

DaveKap
Long Handed Inserter
Long Handed Inserter
Posts: 57
Joined: Sun Mar 16, 2014 5:33 am
Contact:

Re: [0.10.4+] Bumpers

Post by DaveKap »

omegasrevenge wrote:The orgasm that I had after seeing this mod turned the entire interior of my house white.
Hahahaha well that's one way to express your pleasure at seeing this mod. I, on the other hand, am simply happy that it's out so quick! Nicely done. Can't wait to start using it.

Schmendrick
Fast Inserter
Fast Inserter
Posts: 222
Joined: Wed Apr 30, 2014 11:17 pm
Contact:

Re: [0.10.4+] Bumpers

Post by Schmendrick »

It should be relatively easy to adapt/add other road or road-like implementations, if anybody has any requests.

I'm also open to suggestions for a better title. :|
Like my mods? Check out another! Or see older, pre-0.12.0 mods.

Schmendrick
Fast Inserter
Fast Inserter
Posts: 222
Joined: Wed Apr 30, 2014 11:17 pm
Contact:

Re: [0.10.4+] Bumpers

Post by Schmendrick »

Updated. Removed the Roadworks and Floors "detected" messages called at load (and, by extension, on saves). Also cleaned things up ever so slightly, and added some extensibility for future compatibility with other mods.

Modders: if you want Bumpers to work with your mod, add a remote interface called "BumperRoadCheck" to your mod. It takes two values, x and y, and needs to return true when the x,y in question is considered to be on a road. For example, if you're the Roadworks guy:

Code: Select all


local roadtiles = {
	["RW-concretepavement"]=true,
	["RW-asphaltroad"]=true,
	["RW-cobblestonepath"]=true,
	}

remote.addinterface("roadworks",{
BumperRoadCheck=function(x,y)
	if roadtiles[game.gettile(x,y).name] then return true end
end
})
Keep in mind that Bumpers makes this call potentially up to 25 times per tick while checking for roads in front of the car, so try to keep it fast ;)
Like my mods? Check out another! Or see older, pre-0.12.0 mods.

Despy
Burner Inserter
Burner Inserter
Posts: 5
Joined: Fri Jun 27, 2014 7:14 pm
Contact:

Re: [0.10.4+] Bumpers

Post by Despy »

Really nice mod, but I found some problems with v.1.1.0, theres a lot of numbers when the car sticks to the road and the mod only works on a single line road, I made a video to explain it better:
https://www.youtube.com/watch?v=DfeHpm7nV4E

Schmendrick
Fast Inserter
Fast Inserter
Posts: 222
Joined: Wed Apr 30, 2014 11:17 pm
Contact:

Re: [0.10.4+] Bumpers

Post by Schmendrick »

Eurgh. Those numbers would be me forgetting to take out debug stuff again :roll:

To prevent the mod from scanning more than it has to, while it's disengaged it only checks about eight times a second to see if you've moved onto one, which is probably why you're missing the road in your video (when those numbers aren't showing up, it's not checking for roads). I will shorten this time (using the exact numbers in question, actually...)
Like my mods? Check out another! Or see older, pre-0.12.0 mods.

Despy
Burner Inserter
Burner Inserter
Posts: 5
Joined: Fri Jun 27, 2014 7:14 pm
Contact:

Re: [0.10.4+] Bumpers

Post by Despy »

Thanks for the quick update.
I still have problems when trying to make a double road, maybe it's Floors mod problem and not yours, another video to explain it lol:
https://www.youtube.com/watch?v=MVI3Uds1gWM
As you can see the car sticks when going on a single line road, but if I make it double so it looks better the car just ignore it. I also noticed that when I make a single line I can select the placed floor, but when I make it double or bigger I can only remove it with the Floor-B-Gone item, probably Floors bug or something

Schmendrick
Fast Inserter
Fast Inserter
Posts: 222
Joined: Wed Apr 30, 2014 11:17 pm
Contact:

Re: [0.10.4+] Bumpers

Post by Schmendrick »

I'm not completely sure from looking at the video, but the problem is probably mainly graphical. You'll notice that when you put enough floors together to make them connect, they appear to shrink; this is because the edge and corner pieces for the connected floors don't extend all the way to the end of their space, graphically. Each floor piece is 2x2 grids large, so the thinnest connected floor is 4x4 tiles long. But (largely because of concerns making inner corners look right, I assume) it still only looks like a 2x2 covered floor area, because the outside edge of each 2x2 floor tile is transparent. Bumpers uses the full size of the floor piece, so it sees a wider road than you see visually. In the video, you seem to be giving up on it too early (thanks for the videos by the way) - there might be something else going on in that last part where you drive off the horizontal road, but I'm not sure. Try it on longer stretches.

This is one of the main reasons in my first post I talked about Bumpers being more touchy with Floors than with Roadworks. As long as you stick to unconnected floors (whose graphic fills their whole space), it actually works pretty much just as well (the lower 2-tile "resolution" of the floors can still cause some problems). But unconnected floors are ugly :p

Roadworks is much more "what you see is what you get" regarding the underlying implementation vs. appearances. Of course, Floors is a cosmetic mod, so this is perfectly acceptable -- until you start trying to base mechanics around it, the way Bumpers does (but personally I like it more than Roadworks, which is why I added support for it).
Like my mods? Check out another! Or see older, pre-0.12.0 mods.

Despy
Burner Inserter
Burner Inserter
Posts: 5
Joined: Fri Jun 27, 2014 7:14 pm
Contact:

Re: [0.10.4+] Bumpers

Post by Despy »

I tried with a really long road and still doesn't work, probably because its 4 tiles wide (to make it look better) so I'm going to use Roadworks for the roads :)
Btw you forgot to remove the 10k floors for testing lol

Schmendrick
Fast Inserter
Fast Inserter
Posts: 222
Joined: Wed Apr 30, 2014 11:17 pm
Contact:

Re: [0.10.4+] Bumpers

Post by Schmendrick »

heh..

I'd like to say I'm not usually this inattentive, but I'm afraid I am. :oops:

Actually, looking at the code to remove (again) the debuggy stuff, I realized last time when I was moving things around a little, I put the code that recognizes Floors in an awkward order that meant connected floors would sometimes not get detected.

Fixed (hopefully) and updated, again (or, will be, anyway, moments after I post this). Let me know if you have any more problems.
Like my mods? Check out another! Or see older, pre-0.12.0 mods.

Despy
Burner Inserter
Burner Inserter
Posts: 5
Joined: Fri Jun 27, 2014 7:14 pm
Contact:

Re: [0.10.4+] Bumpers

Post by Despy »

v1.1.2 is working really nice with Floors, thanks a lot for the update

User avatar
SuperSandro2000
Filter Inserter
Filter Inserter
Posts: 741
Joined: Sun Jan 12, 2014 3:54 am
Contact:

Re: [0.10.4+] Bumpers

Post by SuperSandro2000 »

Is there a way you can reduce these left and right starrings at straight roads?

Schmendrick
Fast Inserter
Fast Inserter
Posts: 222
Joined: Wed Apr 30, 2014 11:17 pm
Contact:

Re: [0.10.4+] Bumpers

Post by Schmendrick »

What do you mean?
Like my mods? Check out another! Or see older, pre-0.12.0 mods.

Post Reply

Return to “Mods”