SHOW:
|
|
- or go back to the newest paste.
| 1 | - | local component = require("component") |
| 1 | + | local component = require("component")
|
| 2 | - | local gpu = component.gpu |
| 2 | + | local gpu = component.gpu |
| 3 | - | gpu.setResolution(80,25) |
| 3 | + | gpu.setResolution(80,25) |
| 4 | - | local gui = require("gui") |
| 4 | + | local gui = require("gui")
|
| 5 | - | local event = require("event") |
| 5 | + | local event = require("event")
|
| 6 | - | local modem = component.modem |
| 6 | + | local modem = component.modem |
| 7 | - | |
| 7 | + | |
| 8 | - | gui.checkVersion(2,5) |
| 8 | + | gui.checkVersion(2,5) |
| 9 | - | |
| 9 | + | |
| 10 | - | local prgName = "noname" |
| 10 | + | local prgName = "noname" |
| 11 | - | local version = "v1.0" |
| 11 | + | local version = "v1.0" |
| 12 | - | |
| 12 | + | |
| 13 | - | -- Begin: Callbacks |
| 13 | + | -- Begin: Callbacks |
| 14 | - | local function button_0_callback(guiID, buttonID) |
| 14 | + | local function button_0_callback(guiID, buttonID) |
| 15 | - | -- Your code here -- |
| 15 | + | -- Your code here -- |
| 16 | - | modem.open(2412) |
| 16 | + | modem.open(2412) |
| 17 | - | modem.broadcast(2412, "drone=component.proxy(component.list('drone')())") |
| 17 | + | modem.broadcast(2412, "drone=component.proxy(component.list('drone')())")
|
| 18 | - | modem.broadcast(2412, "drone.move(1, 0, 0)") |
| 18 | + | modem.broadcast(2412, "drone.move(1, 0, 0)") |
| 19 | end | |
| 20 | - | |
| 20 | + | |
| 21 | - | local function button_1_callback(guiID, buttonID) |
| 21 | + | local function button_1_callback(guiID, buttonID) |
| 22 | - | -- Your code here |
| 22 | + | -- Your code here |
| 23 | - | modem.open(2412) |
| 23 | + | modem.open(2412) |
| 24 | - | modem.broadcast(2412, "drone=component.proxy(component.list('drone')())") |
| 24 | + | modem.broadcast(2412, "drone=component.proxy(component.list('drone')())")
|
| 25 | - | modem.broadcast(2412, "drone.move(-1, 0, 0)") |
| 25 | + | modem.broadcast(2412, "drone.move(-1, 0, 0)") |
| 26 | end | |
| 27 | - | |
| 27 | + | |
| 28 | - | local function button_2_callback(guiID, buttonID) |
| 28 | + | local function button_2_callback(guiID, buttonID) |
| 29 | - | -- Your code here |
| 29 | + | -- Your code here |
| 30 | - | modem.open(2412) |
| 30 | + | modem.open(2412) |
| 31 | - | modem.broadcast(2412, "drone=component.proxy(component.list('drone')())") |
| 31 | + | modem.broadcast(2412, "drone=component.proxy(component.list('drone')())")
|
| 32 | - | modem.broadcast(2412, "drone.move(0, 1, 0)") |
| 32 | + | modem.broadcast(2412, "drone.move(0, 1, 0)") |
| 33 | end | |
| 34 | - | |
| 34 | + | |
| 35 | - | local function button_3_callback(guiID, buttonID) |
| 35 | + | local function button_3_callback(guiID, buttonID) |
| 36 | - | -- Your code here |
| 36 | + | -- Your code here |
| 37 | - | modem.open(2412) |
| 37 | + | modem.open(2412) |
| 38 | - | modem.broadcast(2412, "drone=component.proxy(component.list('drone')())") |
| 38 | + | modem.broadcast(2412, "drone=component.proxy(component.list('drone')())")
|
| 39 | - | modem.broadcast(2412, "drone.move(0, -1, 0)") |
| 39 | + | modem.broadcast(2412, "drone.move(0, -1, 0)") |
| 40 | end | |
| 41 | - | |
| 41 | + | |
| 42 | - | local function button_4_callback(guiID, buttonID) |
| 42 | + | local function button_4_callback(guiID, buttonID) |
| 43 | - | -- Your code here |
| 43 | + | -- Your code here |
| 44 | - | modem.open(2412) |
| 44 | + | modem.open(2412) |
| 45 | - | modem.broadcast(2412, "drone=component.proxy(component.list('drone')())") |
| 45 | + | modem.broadcast(2412, "drone=component.proxy(component.list('drone')())")
|
| 46 | - | modem.broadcast(2412, "drone.move(0, 0, -1)") |
| 46 | + | modem.broadcast(2412, "drone.move(0, 0, -1)") |
| 47 | end | |
| 48 | - | |
| 48 | + | |
| 49 | - | local function button_5_callback(guiID, buttonID) |
| 49 | + | local function button_5_callback(guiID, buttonID) |
| 50 | - | -- Your code here |
| 50 | + | -- Your code here |
| 51 | - | modem.open(2412) |
| 51 | + | modem.open(2412) |
| 52 | - | modem.broadcast(2412, "drone=component.proxy(component.list('drone')())") |
| 52 | + | modem.broadcast(2412, "drone=component.proxy(component.list('drone')())")
|
| 53 | - | modem.broadcast(2412, "drone.move(0, 0, 1)") |
| 53 | + | modem.broadcast(2412, "drone.move(0, 0, 1)") |
| 54 | end | |
| 55 | - | |
| 55 | + | |
| 56 | - | local function exitButtonCallback(guiID, id) |
| 56 | + | local function exitButtonCallback(guiID, id) |
| 57 | - | local result = gui.getYesNo("", "Do you really want to exit?", "") |
| 57 | + | local result = gui.getYesNo("", "Do you really want to exit?", "")
|
| 58 | - | if result == true then |
| 58 | + | if result == true then |
| 59 | - | gui.exit() |
| 59 | + | gui.exit() |
| 60 | - | end |
| 60 | + | end |
| 61 | - | gui.displayGui(mainGui) |
| 61 | + | gui.displayGui(mainGui) |
| 62 | - | refresh() |
| 62 | + | refresh() |
| 63 | end | |
| 64 | - | -- End: Callbacks |
| 64 | + | -- End: Callbacks |
| 65 | - | |
| 65 | + | |
| 66 | - | -- Begin: Menu definitions |
| 66 | + | -- Begin: Menu definitions |
| 67 | - | mainGui = gui.newGui(1, 2, 79, 23, true) |
| 67 | + | mainGui = gui.newGui(1, 2, 79, 23, true) |
| 68 | - | Forward = gui.newButton(mainGui, 34, 6, "Forward", button_0_callback) |
| 68 | + | Forward = gui.newButton(mainGui, 34, 6, "Forward", button_0_callback) |
| 69 | - | Backward = gui.newButton(mainGui, 34, 16, "Backward", button_1_callback) |
| 69 | + | Backward = gui.newButton(mainGui, 34, 16, "Backward", button_1_callback) |
| 70 | - | Up = gui.newButton(mainGui, 37, 9, "Up", button_2_callback) |
| 70 | + | Up = gui.newButton(mainGui, 37, 9, "Up", button_2_callback) |
| 71 | - | Down = gui.newButton(mainGui, 36, 13, "Down", button_3_callback) |
| 71 | + | Down = gui.newButton(mainGui, 36, 13, "Down", button_3_callback) |
| 72 | - | Left = gui.newButton(mainGui, 24, 11, "Left", button_4_callback) |
| 72 | + | Left = gui.newButton(mainGui, 24, 11, "Left", button_4_callback) |
| 73 | - | Right = gui.newButton(mainGui, 46, 11, "Right", button_5_callback) |
| 73 | + | Right = gui.newButton(mainGui, 46, 11, "Right", button_5_callback) |
| 74 | - | exitButton = gui.newButton(mainGui, 73, 23, "exit", exitButtonCallback) |
| 74 | + | exitButton = gui.newButton(mainGui, 73, 23, "exit", exitButtonCallback) |
| 75 | - | -- End: Menu definitions |
| 75 | + | -- End: Menu definitions |
| 76 | - | |
| 76 | + | |
| 77 | - | gui.clearScreen() |
| 77 | + | gui.clearScreen() |
| 78 | - | gui.setTop("Drone Control") |
| 78 | + | gui.setTop("Drone Control")
|
| 79 | - | gui.setBottom("Made with Visual Gui v0.1a and Gui library v2.5") |
| 79 | + | gui.setBottom("Made with Visual Gui v0.1a and Gui library v2.5")
|
| 80 | - | |
| 80 | + | |
| 81 | - | -- Main loop |
| 81 | + | -- Main loop |
| 82 | - | while true do |
| 82 | + | while true do |
| 83 | - | gui.runGui(mainGui) |
| 83 | + | gui.runGui(mainGui) |
| 84 | end | |
| 85 | - | |
| 85 | + | |
| 86 | - | while true do |
| 86 | + | while true do |
| 87 | - | local cmd=io.read() |
| 87 | + | local cmd=io.read() |
| 88 | - | if not cmd then return end |
| 88 | + | if not cmd then return end |
| 89 | - | modem.broadcast(2412, cmd) |
| 89 | + | modem.broadcast(2412, cmd) |
| 90 | - | print(select(6, event.pull(5, "modem_message"))) |
| 90 | + | print(select(6, event.pull(5, "modem_message"))) |
| 91 | end |