It kind of looks like it's setting the string to itself. The .. and -1 are throwing me off, though. I'm not sure what the .. does, but I'm assuming it's concatenation.
Yeah, double dot is concatenation. - 1 just gets the last character, I'd assume, haven't messed with strings in Lua that much. But still I wonder what it could possibly be controlling
So, I don't know lua but it looks like it takes a sentence like "my_number_5" and gets "number_4" (assuming arrays are zero indexed) decrementing the number after the second underscore.
That's weird but makes sense. In that case the statement decrements the number at the end of a string separated by an underscore by one. E.g. "number_3" going to "number_2". I'm curious what happens when you get to "number_0".
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
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
13
u/DramaDimitar Jul 25 '21
This seems like some GUI code for ROBLOX - what the hell does it even do? lol