Computer Core

by Relik77

Computer is a modification for Factorio that’s all about computer programming. It allows you to write programs using the Lua programming language.

Utilities
6 years ago
0.15 - 0.16
25

i os.wait without need for callback

6 years ago
(updated 6 years ago)

Could you add a function similar to os.wait that doesn't require a callback? It would make programming a lot easier since I would be able to make it release control back to factorio inline with my code, rather than doing weird functions with callbacks. for example:

while(n<10) do
term.write(n)
n += 1
os.sleep(1)
end

would increment n and print it once per second, instead of your loop example that does a similar thing
reading your code, it looks like the sleep function depends on callbacks because of the way on_tick works.. hopefully there's a way to do it without, I'm not sure

6 years ago

Hi,

I'm not much on the project now, but from memory it was not possible for me to perform this kind of function without impacting the game. Because Factorio "wait" the result of the script before calculating the next tick.

New response