milo autorun programs

This commit is contained in:
kepler155c
2018-11-24 14:16:44 -05:00
parent dff7f4bdab
commit 537db89a82
3 changed files with 25 additions and 3 deletions

View File

@@ -9,10 +9,12 @@ local Util = require('util')
local colors = _G.colors
local device = _G.device
local fs = _G.fs
local os = _G.os
local socket
local SHIELD_SLOT = 2
local SHIELD_SLOT = 2
local STARTUP_FILE = 'usr/autorun/miloRemote.lua'
local config = Config.load('miloRemote', { displayMode = 0 })
@@ -139,6 +141,10 @@ local page = UI.Page {
formLabel = 'Shield Slot', formKey = 'useShield',
help = 'Or, use the shield slot for sending'
},
[4] = UI.Checkbox {
formLabel = 'Run on startup', formKey = 'runOnStartup',
help = 'Run this program on startup'
},
info = UI.TextArea {
x = 1, ex = -1, y = 6, ey = -4,
textColor = colors.yellow,
@@ -307,6 +313,16 @@ function page:eventHandler(event)
self.grid:draw()
self:setFocus(self.statusBar.filter)
if config.runOnStartup then
if not fs.exists(STARTUP_FILE) then
Util.writeFile(STARTUP_FILE,
[[os.sleep(1)
shell.openForegroundTab('packages/milo/MiloRemote')]])
end
elseif fs.exists(STARTUP_FILE) then
fs.delete(STARTUP_FILE)
end
elseif event.type == 'form_cancel' then
self.setup:hide()
self:setFocus(self.statusBar.filter)

View File

@@ -21,10 +21,13 @@ local Peripheral = require('peripheral')
local Util = require('util')
local device = _G.device
local fs = _G.fs
local os = _G.os
local peripheral = _G.peripheral
local turtle = _G.turtle
local STARTUP_FILE = 'usr/autorun/miloFurni.lua'
local function equip(side, item, rawName)
local equipped = Peripheral.lookup('side/' .. side)
@@ -50,6 +53,11 @@ local intro = device['plethora:introspection']
local inv = intro.getInventory()
local sides = { 'front', 'back', 'right', 'top' }
if not fs.exists(STARTUP_FILE) then
Util.writeFile(STARTUP_FILE,
[[os.sleep(1)
shell.openForegroundTab('packages/milo/apps/furni')]])
end
-- slot 1: item to cook
-- slot 2: fuel
-- slot 3: return

View File

@@ -3,6 +3,4 @@ local shell = _ENV.shell
if device.workbench then
shell.openForegroundTab('Milo')
elseif device.neuralInterface then
shell.openForegroundTab('MiloRemote')
end