-
-
Save IgorTimofeev/0fe93bd4549aa32161b9dbbba59425e8 to your computer and use it in GitHub Desktop.
TunnelConfigurator.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local GUI = require("GUI") | |
local system = require("System") | |
local paths = require("Paths") | |
local fs = require("Filesystem") | |
local modem = component.modem | |
local port = 512 | |
modem.open(port) | |
--------------------------------------------------------------------------------- | |
local workspace, window, menu = system.addWindow(GUI.filledWindow(1, 1, 32, 15, 0xE1E1E1)) | |
local layout = window:addChild(GUI.layout(1, 4, window.width, window.height - 3, 1, 1)) | |
-- Wake | |
layout:addChild(GUI.button(1, 1, window.width - 4, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, "Wake")).onTouch = function() | |
modem.broadcast(port, "w") | |
end | |
-- Shutdown | |
layout:addChild(GUI.button(1, 1, window.width - 4, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, "Shutdown")).onTouch = function() | |
modem.broadcast(port, "s") | |
end | |
-- Flash | |
layout:addChild(GUI.button(1, 1, window.width - 4, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, "Flash")).onTouch = function() | |
local dialog = GUI.addFilesystemDialog(workspace, true, 50, math.floor(workspace.height * 0.8), "Open", "Cancel", "File name", "/") | |
dialog:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_FILE) | |
dialog:addExtensionFilter(".lua") | |
dialog:expandPath(paths.user.desktop) | |
dialog.filesystemTree.selectedItem = paths.user.desktop | |
dialog:show() | |
dialog.onSubmit = function(path) | |
local data = fs.read(path) | |
local result, reason = load(data) | |
if result then | |
modem.broadcast(port, "f", data) | |
else | |
GUI.alert(reason) | |
end | |
end | |
end | |
--------------------------------------------------------------------------------- | |
workspace:draw() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment