neat-donk/neat-donk.lua

65 lines
1.7 KiB
Lua
Raw Normal View History

--Update to Seth-Bling's MarI/O app
local gui = gui
2021-03-22 18:53:13 -04:00
local base = string.gsub(@@LUA_SCRIPT_FILENAME@@, "(.*[/\\])(.*)", "%1")
2021-03-05 19:53:44 -05:00
2021-04-09 15:06:55 -04:00
local pool = dofile(base.."/pool.lua")
2021-05-01 20:50:13 -04:00
local util = dofile(base.."/util.lua")()
2021-04-09 15:06:55 -04:00
local statusLine = nil
local statusColor = 0x0000ff00
2021-03-07 02:36:09 -05:00
2021-04-09 15:06:55 -04:00
pool.onMessage(function(msg, color)
print(msg)
2021-05-01 21:47:20 -04:00
local stderrColor = util.nearestColor(color, {
2021-05-01 20:50:13 -04:00
-- Green
['92'] = { r = 0 , g = 255, b = 0 },
2021-05-01 21:47:20 -04:00
-- Red
['91'] = { r = 255, g = 0 , b = 0 },
2021-05-01 20:50:13 -04:00
-- Yellow
['93'] = { r = 255, g = 255, b = 0 },
-- Blue
['94'] = { r = 0 , g = 0 , b = 255},
-- Magenta
['95'] = { r = 255, g = 0 , b = 255},
-- Cyan
['96'] = { r = 0 , g = 255, b = 255},
-- White
['97'] = { r = 255, g = 255, b = 255},
})
2021-05-01 21:47:20 -04:00
io.stderr:write('\x1b['..stderrColor..'m'..msg..'\x1b[0m\n')
2021-04-09 15:06:55 -04:00
statusLine = msg
statusColor = color
end)
2021-04-09 15:06:55 -04:00
local guiHeight = 0
local guiWidth = 0
pool.onRenderForm(function(form)
guiWidth, guiHeight = gui.resolution()
2021-04-09 15:06:55 -04:00
gui.left_gap(500)
gui.top_gap(0)
gui.bottom_gap(0)
gui.right_gap(0)
2021-04-09 15:06:55 -04:00
form:draw(-500, 0)
2021-04-09 15:06:55 -04:00
if statusLine ~= nil then
2021-05-01 20:50:13 -04:00
gui.rectangle(-500, guiHeight - 20, guiWidth, 20, 1, 0x00000000, statusColor)
2021-04-09 15:06:55 -04:00
gui.text(-500, guiHeight - 20, statusLine, 0x00000000)
end
2021-04-09 15:06:55 -04:00
end)
2021-05-01 19:39:35 -04:00
2021-05-05 03:34:04 -04:00
local DONK_LOAD_POOL = os.getenv('DONK_LOAD_POOL')
if DONK_LOAD_POOL ~= nil and DONK_LOAD_POOL ~= "" then
pool.requestLoad(DONK_LOAD_POOL)
end
2021-05-01 19:39:35 -04:00
pool.run():next(function()
print("The pool finished running!!!")
end):catch(function(error)
if type(error) == "table" then
error = "\n"..table.concat(error, "\n")
end
2021-05-01 19:39:35 -04:00
io.stderr:write(string.format("There was a problem running the pool: %s", error))
print(string.format("There was a problem running the pool: %s", error))
2021-05-01 20:50:13 -04:00
end)