Adding startup script to delay program execution until everything is properly loaded...
authorOlav Bakke Svendsen <mail@olavbs.no>
Wed, 18 Oct 2023 02:03:46 +0000 (04:03 +0200)
committerOlav Bakke Svendsen <mail@olavbs.no>
Wed, 18 Oct 2023 02:03:46 +0000 (04:03 +0200)
common/delayed_startup.lua [new file with mode: 0644]

diff --git a/common/delayed_startup.lua b/common/delayed_startup.lua
new file mode 100644 (file)
index 0000000..4bacbbb
--- /dev/null
@@ -0,0 +1,28 @@
+-- delayed_startup.lua
+-- save as "/startup.lua" and modify delay and run
+
+-- delay in seconds
+local delay = 60
+
+-- what to do after delay
+local run = function()
+  
+end
+
+
+
+local wait = os.startTimer(60)
+term.clear()
+term.setCursorPos(1,1)
+print("Starting in "..tostring(delay).." seconds")
+print("Press any key to cancel...")
+while true do
+  local e, t = os.pullEvent()
+  if e == "timer" and t == wait then
+    run()
+  elseif e == "char" then
+    print("Canceled")
+    os.cancelTimer(wait)
+    break
+  end
+end