
[1.12.2, version 1.7.4.153] event.timer not working correctly for small intervals
JasonS05 opened this issue ยท 2 comments
When I call event.timer with an interval shorter than about 0.4, it acts as if the interval is around 0.4. Even 0.0000001 acts as if it was called with 0.4. If I call it with an interval of 0, it works correctly and calls the function repeatedly in rapid succession (for however many times I told it to via the third argument). So, between 0 and 0.4, the interval is rounded up to 0.4, but at 0 or above 0.4 it works correctly. This seems to be incorrect behavior because the wiki says: "interval - time in seconds between each invocation of the callback function. Can be a fraction like 0.05." However, 0.05 does not work.
I am on Ubuntu 20.04 LTS running Minecraft 1.12.2 with 1.12.2-forge-14.23.5.2855.jar
, OpenComputers-1.12.1.jar
, and Computronics-1.12.2-1.6.6.jar
. The computer and monitor are both tier 3 and the components I have are as follows: one tier 3 CPU, two tier 3.5 RAM sticks, one tier 3 HDD, one tier 3 GPU, one internet card, and one beep card. I am also using an unmodified copy of the standard EEPROM Lua BIOS. I have not changed the configuration files except for line 1261 of settings.conf which I changed to "ignorePower=true" so that I could run the computers without using other mods for power supply.
Edit: I timed it and calling event.timer with an interval of 0.000001 takes exactly 50 seconds to call the callback 100 times. So, it looks like the interval can't go any lower than 0.5 despite the wiki claiming it works at 0.05. Perhaps the one of the devs missed a zero somewhere (or added an extra one)?
Edit 2: Doing more experiments tells me that event.timer has a granularity of 0.5 seconds, always rounded up. So, it's as if it does interval = math.ceil(interval * 2) / 2
. I looked into the code and all I can think of is that computer.pullSignal (defined on line 33 of /lib/event.lua
) is called every half second when it should be called every tick since computer.pullSignal is responsible for calling callbacks registered by event.timer.
turns out this issue was a duplicate of #3058