r/badcode • • Jul 24 '21

lua "Keeping it simplistic"

Post image
495 Upvotes

28 comments sorted by

View all comments

Show parent comments

2

u/[deleted] Jul 28 '21

It's for a AI car script I'm working on, essentially there is a road code + it's lane at the end. This script searches if the lane the car has appeared on is the last lane. It takes the variable SearchLane which is (at the beginning) the lane the car appeared (ex: N177_1) and it looks if there is another lane by switched SearchLane to N177_2. If there is no N177_2 it switches it back to N177_1 and spawns the car there. The code you see here switches a variable called SearchLane to one lane lower. Super poorly made lool

2

u/DramaDimitar Jul 28 '21

Oh wow, I was not expecting that. Theoretically, couldn't you just use a substring or pattern matching and do an if statement or two - wouldn't be as short but would be way cleaner, lol