I also did some looking and I also found that it isn’t related to FE, it’s related to the module somehow. I tested it with the server controlling the module and it still messed up. Before, I had the code integrated with the main script (server side) and breaking it out into the module is causing the error. I will definitely be doing more investigating, but it seems that I was hasty in putting the blame on Filtering. Currently, the (believed) cause is the module.
EDIT: continuing the investigation, putting the code back in the main script isn’t the issue. Right now I’m checking to see if the cause is updating it on Stepped or RenderStepped and putting it on a while wait() do loop
EDIT 2: it lasts for a longer time but it still is not the cause, it seems.
EDIT 3: I am going to be pouring over the differences between what I have right now (which I expected to be in a configuration the same as the last known working version) and the actual last known working version.
EDIT 4: the first difference that caught my eye was the difference in calculating the delta time. The known working version (which I confirmed to work) uses
local dt = wait()
while the trouble version uses
t1 = tick()
--loop begin
t2 = tick()
local dt = t2-t1
t1 = t2
if tick() is not precise enough, it may return a delta-t of 0, which potentially is causing these errors.
EDIT 5: somehow that still isn’t it
EDIT 6: I believe I finally found it: a half-assed attempt to better-handle cases where the train travels a great distance in a short time (i.e. because of latency). Below is the code in the working version:
if LeftAngle > 2*math.pi then
LeftAngle = LeftAngle-2*math.pi
elseif LeftAngle < 0 then
LeftAngle = LeftAngle+2*math.pi
end
and here is the broken code:
if LeftAngle > 2*math.pi then
LeftAngle = LeftAngle-(math.floor(LeftAngle/math.pi/2)*2*math.pi)
elseif LeftAngle < 0 then
LeftAngle = LeftAngle+(math.ceil(LeftAngle/math.pi/2)*2*math.pi)
end
the additional irony is that the original edit 6 (this is edit 6.5) included a broken [code bbcode tag
The irony is that I do not even think I need anything more complex than the working version, even if the loco travels a great distance in a single frame. In my head, the working code will automatically decrease or increase the angle every frame that the calculated angle is outside of [0,pi] and wind up in a couple of frames within that range, and that forcing the value to be within the range immediately is not absolutely necessary.
EDIT 7: edit 6 is correct, that difference was the entire reason. case closed
CodeWriter, thanks for inspiring me to take another look at the problem like I should have, and I’m glad that I got it all straightened out finally.