-Fixed basalt.getMainFrame() not returning the main frame (instead it was returning the active frame)
- Fixed basalt.run() beeing able to run multiple times - Added basalt.isRunning to check if basalt is running
This commit is contained in:
19
src/main.lua
19
src/main.lua
@@ -13,6 +13,7 @@ local expect = require("libraries/expect")
|
|||||||
--- @field _events table A table of events and their callbacks
|
--- @field _events table A table of events and their callbacks
|
||||||
--- @field _schedule function[] A table of scheduled functions
|
--- @field _schedule function[] A table of scheduled functions
|
||||||
--- @field _plugins table A table of plugins
|
--- @field _plugins table A table of plugins
|
||||||
|
--- @field isRunning boolean Whether the Basalt runtime is active
|
||||||
--- @field LOGGER Log The logger instance
|
--- @field LOGGER Log The logger instance
|
||||||
--- @field path string The path to the Basalt library
|
--- @field path string The path to the Basalt library
|
||||||
local basalt = {}
|
local basalt = {}
|
||||||
@@ -20,6 +21,7 @@ basalt.traceback = true
|
|||||||
basalt._events = {}
|
basalt._events = {}
|
||||||
basalt._schedule = {}
|
basalt._schedule = {}
|
||||||
basalt._plugins = {}
|
basalt._plugins = {}
|
||||||
|
basalt.isRunning = false
|
||||||
basalt.LOGGER = require("log")
|
basalt.LOGGER = require("log")
|
||||||
if(minified)then
|
if(minified)then
|
||||||
basalt.path = fs.getDir(shell.getRunningProgram())
|
basalt.path = fs.getDir(shell.getRunningProgram())
|
||||||
@@ -29,7 +31,6 @@ end
|
|||||||
|
|
||||||
local mainFrame = nil
|
local mainFrame = nil
|
||||||
local activeFrame = nil
|
local activeFrame = nil
|
||||||
local updaterActive = false
|
|
||||||
local _type = type
|
local _type = type
|
||||||
|
|
||||||
local lazyElements = {}
|
local lazyElements = {}
|
||||||
@@ -232,7 +233,7 @@ end
|
|||||||
--- @shortDescription Stops the Basalt runtime
|
--- @shortDescription Stops the Basalt runtime
|
||||||
--- @usage basalt.stop()
|
--- @usage basalt.stop()
|
||||||
function basalt.stop()
|
function basalt.stop()
|
||||||
updaterActive = false
|
basalt.isRunning = false
|
||||||
term.clear()
|
term.clear()
|
||||||
term.setCursorPos(1,1)
|
term.setCursorPos(1,1)
|
||||||
end
|
end
|
||||||
@@ -243,18 +244,22 @@ end
|
|||||||
--- @usage basalt.run()
|
--- @usage basalt.run()
|
||||||
--- @usage basalt.run(false)
|
--- @usage basalt.run(false)
|
||||||
function basalt.run(isActive)
|
function basalt.run(isActive)
|
||||||
updaterActive = isActive
|
if(basalt.isRunning)then errorManager.error("Basalt is already running") end
|
||||||
if(isActive==nil)then updaterActive = true end
|
if(isActive==nil)then
|
||||||
|
basalt.isRunning = true
|
||||||
|
else
|
||||||
|
basalt.isRunning = isActive
|
||||||
|
end
|
||||||
local function f()
|
local function f()
|
||||||
renderFrames()
|
renderFrames()
|
||||||
while updaterActive do
|
while basalt.isRunning do
|
||||||
updateEvent(os.pullEventRaw())
|
updateEvent(os.pullEventRaw())
|
||||||
if(updaterActive)then
|
if(basalt.isRunning)then
|
||||||
renderFrames()
|
renderFrames()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
while updaterActive do
|
while basalt.isRunning do
|
||||||
local ok, err = pcall(f)
|
local ok, err = pcall(f)
|
||||||
if not(ok)then
|
if not(ok)then
|
||||||
errorManager.header = "Basalt Runtime Error"
|
errorManager.header = "Basalt Runtime Error"
|
||||||
|
|||||||
Reference in New Issue
Block a user