Closed GinjaNinja32 closed 7 years ago
It's by design - to access anything in world we need to synchronize (with main thread), otherwise game may crash.
Basically, some of calls in OpenPeripheral (marked as synchronous in documentation) internally look like this:
local task_id = issueMainThreadTask(...) -- function from CC API
while true do
event, id = os.pullEvent("task_complete")
if id == task_id then break end
end
return ... -- actual return of function stored somewhere else
This is standard pattern in CC and identical to behaviour of turtle methods (turtle.dig
, etc).
To get around this, please use built-in parallel module.
I'm trying to write an interactive program that needs to poll an external tank in a loop, and the fact
getTankInfo()
is dropping events while executing is making that a lot harder. Is it possible to make it either take no time to execute, or at least not drop events while it takes its tick?Reproduction:
I'm running FTB Infinity 2.6.0, which contains:
ComputerCraft 1.75 OpenModsLib 0.9.1 OpenPeripheralCore 1.3 OpenPeripheralAddons 0.5.1 OpenPeripheralIntegration 0.5