summaryrefslogtreecommitdiff
path: root/init.lua
blob: 4727838e9ba78ef2b124a46302d31fe8927f4d2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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("Could not load run.lua:", r)
		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