summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/init.lua b/init.lua
new file mode 100644
index 0000000..1756628
--- /dev/null
+++ b/init.lua
@@ -0,0 +1,22 @@
+--- Somewhat safely loads "run.lua" module into a global variable RUN. Loaded module itself should be a function. If
+--- everything seems fine, true is returned.
+function init ()
+ wifi.setmode(wifi.NULLMODE, false)
+ local l, r = pcall(require, "run")
+ if not l then
+ print("run.lua not found")
+ return
+ end
+ RUN = r
+ l, r = node.bootreason()
+ if l == 2 and (r == 2 or r == 4) then
+ print("Most likely an exception restarted last boot, run.lua loaded into RUN and left as is")
+ return
+ end
+ return true
+end
+
+
+if init() then
+ RUN()
+end