changes for deprecated ui methods - recolor milo - make turtle scripts run again - mob rancher improvements
This commit is contained in:
@@ -724,8 +724,7 @@ function startPage:eventHandler(event)
|
|||||||
Builder:begin()
|
Builder:begin()
|
||||||
|
|
||||||
elseif event.type == 'quit' then
|
elseif event.type == 'quit' then
|
||||||
UI.term:reset()
|
UI:quit()
|
||||||
Event.exitPullEvents()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return UI.Page.eventHandler(self, event)
|
return UI.Page.eventHandler(self, event)
|
||||||
@@ -769,5 +768,4 @@ UI:setPages({
|
|||||||
})
|
})
|
||||||
|
|
||||||
UI:setPage('start')
|
UI:setPage('start')
|
||||||
|
UI:start()
|
||||||
UI:pullEvents()
|
|
||||||
|
|||||||
@@ -354,7 +354,7 @@ function categoryPage:eventHandler(event)
|
|||||||
self:draw()
|
self:draw()
|
||||||
|
|
||||||
elseif event.type == 'quit' then
|
elseif event.type == 'quit' then
|
||||||
UI:exitPullEvents()
|
UI:quit()
|
||||||
|
|
||||||
else
|
else
|
||||||
return UI.Page.eventHandler(self, event)
|
return UI.Page.eventHandler(self, event)
|
||||||
@@ -366,4 +366,4 @@ print("Retrieving catalog list")
|
|||||||
categoryPage:setCategory(source.name, source.index)
|
categoryPage:setCategory(source.name, source.index)
|
||||||
|
|
||||||
UI:setPage(categoryPage)
|
UI:setPage(categoryPage)
|
||||||
UI:pullEvents()
|
UI:start()
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ end
|
|||||||
|
|
||||||
function peripheralsPage:eventHandler(event)
|
function peripheralsPage:eventHandler(event)
|
||||||
if event.type == 'quit' then
|
if event.type == 'quit' then
|
||||||
Event.exitPullEvents()
|
UI:quit()
|
||||||
|
|
||||||
elseif event.type == 'grid_select' then
|
elseif event.type == 'grid_select' then
|
||||||
UI:setPage('methods', event.selected)
|
UI:setPage('methods', event.selected)
|
||||||
@@ -198,4 +198,4 @@ UI:setPages({
|
|||||||
methods = methodsPage,
|
methods = methodsPage,
|
||||||
})
|
})
|
||||||
|
|
||||||
UI:pullEvents()
|
UI:start()
|
||||||
|
|||||||
@@ -269,4 +269,4 @@ Event.onTimeout(.2, function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
UI:setPage(page)
|
UI:setPage(page)
|
||||||
UI:pullEvents()
|
UI:start()
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ local page = UI.Page {
|
|||||||
self.grid:draw()
|
self.grid:draw()
|
||||||
|
|
||||||
elseif event.type == 'quit' then
|
elseif event.type == 'quit' then
|
||||||
UI:exitPullEvents()
|
UI:quit()
|
||||||
|
|
||||||
else
|
else
|
||||||
return UI.Page.eventHandler(self, event)
|
return UI.Page.eventHandler(self, event)
|
||||||
|
|||||||
@@ -238,6 +238,6 @@ Event.addRoutine(function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
UI:setPage(page)
|
UI:setPage(page)
|
||||||
UI:pullEvents()
|
UI:start()
|
||||||
|
|
||||||
swarm:stop()
|
swarm:stop()
|
||||||
|
|||||||
@@ -60,4 +60,4 @@ function page:eventHandler(event)
|
|||||||
end
|
end
|
||||||
|
|
||||||
UI:setPage(page)
|
UI:setPage(page)
|
||||||
UI:pullEvents()
|
UI:start()
|
||||||
|
|||||||
@@ -292,30 +292,42 @@ function page:runScript(scriptName)
|
|||||||
print('Unable to read script file')
|
print('Unable to read script file')
|
||||||
end
|
end
|
||||||
|
|
||||||
local socket = Socket.connect(turtle.id, 161)
|
local function processVariables()
|
||||||
if not socket then
|
|
||||||
print('Unable to connect to ' .. turtle.id)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local function processVariables(script)
|
|
||||||
local variables = {
|
local variables = {
|
||||||
COMPUTER_ID = os.getComputerID(),
|
COMPUTER_ID = os.getComputerID,
|
||||||
|
GPS = function()
|
||||||
|
local pt = require('opus.gps').getPoint()
|
||||||
|
if not pt then
|
||||||
|
error('Unable to determine location')
|
||||||
|
end
|
||||||
|
return _G.textutils.serialize(pt)
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
for k,v in pairs(variables) do
|
for k,v in pairs(variables) do
|
||||||
local token = string.format('{%s}', k)
|
local token = string.format('{%s}', k)
|
||||||
script = script:gsub(token, v)
|
if script:find(token, 1, true) then
|
||||||
|
local s, m = pcall(v)
|
||||||
|
if not s then
|
||||||
|
self.notification:error(m)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
script = script:gsub(token, m)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
return true
|
||||||
return script
|
|
||||||
end
|
end
|
||||||
|
|
||||||
script = processVariables(script)
|
if processVariables(script) then
|
||||||
|
local socket = Socket.connect(turtle.id, 161)
|
||||||
|
if not socket then
|
||||||
|
self.notification:error('Unable to connect')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
socket:write({ type = 'script', args = script })
|
||||||
|
socket:close()
|
||||||
|
|
||||||
socket:write({ type = 'script', args = script })
|
self.notification:success('Sent')
|
||||||
socket:close()
|
end
|
||||||
|
|
||||||
self.notification:success('Sent')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -339,7 +351,7 @@ end
|
|||||||
|
|
||||||
function page:eventHandler(event)
|
function page:eventHandler(event)
|
||||||
if event.type == 'quit' then
|
if event.type == 'quit' then
|
||||||
UI:exitPullEvents()
|
UI:quit()
|
||||||
|
|
||||||
elseif event.type == 'tab_select' then
|
elseif event.type == 'tab_select' then
|
||||||
config.tab = event.button.text
|
config.tab = event.button.text
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
turtle.run(function()
|
|
||||||
|
|
||||||
_G.requireInjector(_ENV)
|
|
||||||
|
|
||||||
local GPS = require('opus.gps')
|
|
||||||
local Socket = require('opus.socket')
|
|
||||||
|
|
||||||
local id = {COMPUTER_ID}
|
|
||||||
|
|
||||||
if not turtle.enableGPS() then
|
|
||||||
error('turtle: No GPS found')
|
|
||||||
end
|
|
||||||
|
|
||||||
local socket = Socket.connect(id, 161)
|
|
||||||
if not socket then
|
|
||||||
error('turtle: Unable to connect to ' .. id)
|
|
||||||
end
|
|
||||||
|
|
||||||
socket:write({ type = 'gps' })
|
|
||||||
|
|
||||||
local pt = socket:read(3)
|
|
||||||
if not pt then
|
|
||||||
error('turtle: No GPS response')
|
|
||||||
end
|
|
||||||
|
|
||||||
if not turtle.pathfind(pt) then
|
|
||||||
error('Unable to go to location')
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
17
common/etc/scripts/moveTo.lua
Normal file
17
common/etc/scripts/moveTo.lua
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
local turtle = _G.turtle
|
||||||
|
|
||||||
|
turtle.run(function()
|
||||||
|
_G.requireInjector(_ENV)
|
||||||
|
|
||||||
|
local GPS = require('opus.gps')
|
||||||
|
|
||||||
|
if not turtle.enableGPS() then
|
||||||
|
error('turtle: No GPS found')
|
||||||
|
end
|
||||||
|
|
||||||
|
local pt = {GPS}
|
||||||
|
|
||||||
|
if not turtle.pathfind(pt) then
|
||||||
|
error('Unable to go to location')
|
||||||
|
end
|
||||||
|
end)
|
||||||
@@ -313,4 +313,4 @@ else
|
|||||||
end
|
end
|
||||||
|
|
||||||
UI:setPage(page)
|
UI:setPage(page)
|
||||||
UI:pullEvents()
|
UI:start()
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ _G._syslog = function(...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local s, m = pcall(function()
|
local s, m = pcall(function()
|
||||||
UI:pullEvents()
|
UI:start()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
turtle.setStatus('idle')
|
turtle.setStatus('idle')
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ local page = UI.Page {
|
|||||||
x = 1, ex = -13,
|
x = 1, ex = -13,
|
||||||
limit = 50,
|
limit = 50,
|
||||||
shadowText = 'filter',
|
shadowText = 'filter',
|
||||||
backgroundColor = colors.cyan,
|
backgroundColor = UI.colors.primary,
|
||||||
backgroundFocusColor = colors.cyan,
|
backgroundFocusColor = UI.colors.primary,
|
||||||
accelerators = {
|
accelerators = {
|
||||||
[ 'enter' ] = 'eject',
|
[ 'enter' ] = 'eject',
|
||||||
[ 'up' ] = 'grid_up',
|
[ 'up' ] = 'grid_up',
|
||||||
@@ -169,7 +169,7 @@ end
|
|||||||
|
|
||||||
function page:eventHandler(event)
|
function page:eventHandler(event)
|
||||||
if event.type == 'quit' then
|
if event.type == 'quit' then
|
||||||
UI:exitPullEvents()
|
UI:quit()
|
||||||
|
|
||||||
elseif event.type == 'setup' then
|
elseif event.type == 'setup' then
|
||||||
self.setup.form:setValues(context.state)
|
self.setup.form:setValues(context.state)
|
||||||
@@ -524,7 +524,7 @@ local programDir = fs.getDir(shell.getRunningProgram())
|
|||||||
loadDirectory(fs.combine(programDir, 'plugins/remote'))
|
loadDirectory(fs.combine(programDir, 'plugins/remote'))
|
||||||
|
|
||||||
UI:setPage(page)
|
UI:setPage(page)
|
||||||
UI:pullEvents()
|
UI:start()
|
||||||
|
|
||||||
if context.socket then
|
if context.socket then
|
||||||
context.socket:close()
|
context.socket:close()
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ local page = UI.Page {
|
|||||||
limit = 50,
|
limit = 50,
|
||||||
shadowText = 'filter',
|
shadowText = 'filter',
|
||||||
shadowTextColor = colors.gray,
|
shadowTextColor = colors.gray,
|
||||||
backgroundColor = colors.cyan,
|
backgroundColor = UI.colors.primary,
|
||||||
backgroundFocusColor = colors.cyan,
|
backgroundFocusColor = UI.colors.primary,
|
||||||
accelerators = {
|
accelerators = {
|
||||||
[ 'enter' ] = 'eject',
|
[ 'enter' ] = 'eject',
|
||||||
[ 'up' ] = 'grid_up',
|
[ 'up' ] = 'grid_up',
|
||||||
@@ -66,7 +66,7 @@ local page = UI.Page {
|
|||||||
storageStatus = UI.Text {
|
storageStatus = UI.Text {
|
||||||
x = -17, ex = -10,
|
x = -17, ex = -10,
|
||||||
textColor = colors.lime,
|
textColor = colors.lime,
|
||||||
backgroundColor = colors.cyan,
|
backgroundColor = UI.colors.primary,
|
||||||
value = '',
|
value = '',
|
||||||
},
|
},
|
||||||
amount = UI.TextEntry {
|
amount = UI.TextEntry {
|
||||||
@@ -208,7 +208,7 @@ end
|
|||||||
|
|
||||||
function page:eventHandler(event)
|
function page:eventHandler(event)
|
||||||
if event.type == 'quit' then
|
if event.type == 'quit' then
|
||||||
UI:exitPullEvents()
|
UI:quit()
|
||||||
|
|
||||||
elseif event.type == 'eject' or event.type == 'grid_select' then
|
elseif event.type == 'eject' or event.type == 'grid_select' then
|
||||||
self:eject(1)
|
self:eject(1)
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ local Util = require('opus.util')
|
|||||||
|
|
||||||
local colors = _G.colors
|
local colors = _G.colors
|
||||||
local device = _G.device
|
local device = _G.device
|
||||||
local turtle = _G.turtle
|
|
||||||
|
|
||||||
local context = Milo:getContext()
|
local context = Milo:getContext()
|
||||||
|
|
||||||
@@ -22,8 +21,8 @@ local networkPage = UI.Page {
|
|||||||
y = -2, x = 1, ex = -9,
|
y = -2, x = 1, ex = -9,
|
||||||
limit = 50,
|
limit = 50,
|
||||||
shadowText = 'filter',
|
shadowText = 'filter',
|
||||||
backgroundColor = colors.cyan,
|
backgroundColor = UI.colors.primary,
|
||||||
backgroundFocusColor = colors.cyan,
|
backgroundFocusColor = UI.colors.primary,
|
||||||
},
|
},
|
||||||
grid = UI.ScrollingGrid {
|
grid = UI.ScrollingGrid {
|
||||||
y = 2, ey = -3,
|
y = 2, ey = -3,
|
||||||
@@ -195,7 +194,6 @@ nodeWizard = UI.Page {
|
|||||||
pages = {
|
pages = {
|
||||||
general = UI.WizardPage {
|
general = UI.WizardPage {
|
||||||
index = 1,
|
index = 1,
|
||||||
backgroundColor = colors.cyan,
|
|
||||||
form = UI.Form {
|
form = UI.Form {
|
||||||
x = 2, ex = -2, y = 1, ey = 3,
|
x = 2, ex = -2, y = 1, ey = 3,
|
||||||
manualControls = true,
|
manualControls = true,
|
||||||
@@ -236,11 +234,10 @@ The settings will take effect immediately!]],
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
statusBar = UI.StatusBar {
|
statusBar = UI.StatusBar {
|
||||||
backgroundColor = colors.cyan,
|
backgroundColor = UI.colors.primary,
|
||||||
},
|
},
|
||||||
notification = UI.Notification { },
|
notification = UI.Notification { },
|
||||||
filter = UI.SlideOut {
|
filter = UI.SlideOut {
|
||||||
backgroundColor = colors.cyan,
|
|
||||||
noFill = true,
|
noFill = true,
|
||||||
menuBar = UI.MenuBar {
|
menuBar = UI.MenuBar {
|
||||||
buttons = {
|
buttons = {
|
||||||
@@ -292,7 +289,7 @@ The settings will take effect immediately!]],
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
statusBar = UI.StatusBar {
|
statusBar = UI.StatusBar {
|
||||||
backgroundColor = colors.cyan,
|
backgroundColor = UI.colors.primary,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ Right-clicking on the activity monitor will reset the totals.]]
|
|||||||
local wizardPage = UI.WizardPage {
|
local wizardPage = UI.WizardPage {
|
||||||
title = 'Activity Monitor',
|
title = 'Activity Monitor',
|
||||||
index = 2,
|
index = 2,
|
||||||
backgroundColor = colors.cyan,
|
|
||||||
[1] = UI.TextArea {
|
[1] = UI.TextArea {
|
||||||
x = 2, ex = -2, y = 2, ey = 6,
|
x = 2, ex = -2, y = 2, ey = 6,
|
||||||
marginRight = 0,
|
marginRight = 0,
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ local Event = require('opus.event')
|
|||||||
local Milo = require('milo')
|
local Milo = require('milo')
|
||||||
local UI = require('opus.ui')
|
local UI = require('opus.ui')
|
||||||
|
|
||||||
local colors = _G.colors
|
|
||||||
local device = _G.device
|
local device = _G.device
|
||||||
local fs = _G.fs
|
local fs = _G.fs
|
||||||
local os = _G.os
|
local os = _G.os
|
||||||
@@ -23,7 +22,6 @@ Backup configuration files each minecraft day.
|
|||||||
local wizardPage = UI.WizardPage {
|
local wizardPage = UI.WizardPage {
|
||||||
title = 'Backup Drive',
|
title = 'Backup Drive',
|
||||||
index = 2,
|
index = 2,
|
||||||
backgroundColor = colors.cyan,
|
|
||||||
[1] = UI.TextArea {
|
[1] = UI.TextArea {
|
||||||
x = 2, ex = -2, y = 2, ey = -2,
|
x = 2, ex = -2, y = 2, ey = -2,
|
||||||
value = string.format(template, Ansi.yellow, Ansi.reset),
|
value = string.format(template, Ansi.yellow, Ansi.reset),
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ Note that you do not need to import items from the brewing stand or export blaze
|
|||||||
local wizardPage = UI.WizardPage {
|
local wizardPage = UI.WizardPage {
|
||||||
title = 'Brewing Stand',
|
title = 'Brewing Stand',
|
||||||
index = 2,
|
index = 2,
|
||||||
backgroundColor = colors.cyan,
|
|
||||||
[1] = UI.TextArea {
|
[1] = UI.TextArea {
|
||||||
x = 2, ex = -2, y = 2, ey = -2,
|
x = 2, ex = -2, y = 2, ey = -2,
|
||||||
value = string.format(template, Ansi.yellow, Ansi.reset),
|
value = string.format(template, Ansi.yellow, Ansi.reset),
|
||||||
|
|||||||
@@ -4,12 +4,10 @@ local itemDB = require('core.itemDB')
|
|||||||
|
|
||||||
local colors = _G.colors
|
local colors = _G.colors
|
||||||
local device = _G.device
|
local device = _G.device
|
||||||
local context = Milo:getContext()
|
|
||||||
|
|
||||||
local wizardPage = UI.WizardPage {
|
local wizardPage = UI.WizardPage {
|
||||||
title = 'Level Emitter',
|
title = 'Level Emitter',
|
||||||
index = 2,
|
index = 2,
|
||||||
backgroundColor = colors.cyan,
|
|
||||||
[1] = UI.TextArea {
|
[1] = UI.TextArea {
|
||||||
x = 2, y = 1,
|
x = 2, y = 1,
|
||||||
height = 2,
|
height = 2,
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
local Ansi = require('opus.ansi')
|
local Ansi = require('opus.ansi')
|
||||||
local UI = require('opus.ui')
|
local UI = require('opus.ui')
|
||||||
|
|
||||||
local colors = _G.colors
|
|
||||||
local device = _G.device
|
local device = _G.device
|
||||||
|
|
||||||
--[[ Configuration Screen ]]
|
--[[ Configuration Screen ]]
|
||||||
@@ -14,7 +13,6 @@ Any items placed in this chest will be imported into storage.
|
|||||||
local inputChestWizardPage = UI.WizardPage {
|
local inputChestWizardPage = UI.WizardPage {
|
||||||
title = 'Input Chest',
|
title = 'Input Chest',
|
||||||
index = 2,
|
index = 2,
|
||||||
backgroundColor = colors.cyan,
|
|
||||||
[1] = UI.TextArea {
|
[1] = UI.TextArea {
|
||||||
x = 2, ex = -2, y = 2, ey = -2,
|
x = 2, ex = -2, y = 2, ey = -2,
|
||||||
value = string.format(template, Ansi.yellow, Ansi.reset),
|
value = string.format(template, Ansi.yellow, Ansi.reset),
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
local Ansi = require('opus.ansi')
|
local Ansi = require('opus.ansi')
|
||||||
local UI = require('opus.ui')
|
local UI = require('opus.ui')
|
||||||
|
|
||||||
local colors = _G.colors
|
|
||||||
|
|
||||||
local infoTab = UI.Tab {
|
local infoTab = UI.Tab {
|
||||||
tabTitle = 'Info',
|
tabTitle = 'Info',
|
||||||
index = 4,
|
index = 4,
|
||||||
backgroundColor = colors.cyan,
|
|
||||||
textArea = UI.TextArea {
|
textArea = UI.TextArea {
|
||||||
x = 2, ex = -2, y = 2, ey = -2,
|
x = 2, ex = -2, y = 2, ey = -2,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ local context = Milo:getContext()
|
|||||||
local machinesTab = UI.Tab {
|
local machinesTab = UI.Tab {
|
||||||
tabTitle = 'Machine',
|
tabTitle = 'Machine',
|
||||||
index = 3,
|
index = 3,
|
||||||
backgroundColor = colors.cyan,
|
|
||||||
grid = UI.ScrollingGrid {
|
grid = UI.ScrollingGrid {
|
||||||
x = 2, ex = -2, y = 2, ey = -2,
|
x = 2, ex = -2, y = 2, ey = -2,
|
||||||
disableHeader = true,
|
disableHeader = true,
|
||||||
|
|||||||
@@ -3,12 +3,9 @@ local itemDB = require('core.itemDB')
|
|||||||
local Milo = require('milo')
|
local Milo = require('milo')
|
||||||
local UI = require('opus.ui')
|
local UI = require('opus.ui')
|
||||||
|
|
||||||
local colors = _G.colors
|
|
||||||
|
|
||||||
local recipeTab = UI.Tab {
|
local recipeTab = UI.Tab {
|
||||||
tabTitle = 'Recipe',
|
tabTitle = 'Recipe',
|
||||||
index = 2,
|
index = 2,
|
||||||
backgroundColor = colors.cyan,
|
|
||||||
grid = UI.ScrollingGrid {
|
grid = UI.ScrollingGrid {
|
||||||
x = 2, ex = -2, y = 2, ey = -4,
|
x = 2, ex = -2, y = 2, ey = -4,
|
||||||
disableHeader = true,
|
disableHeader = true,
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ local os = _G.os
|
|||||||
local wizardPage = UI.WizardPage {
|
local wizardPage = UI.WizardPage {
|
||||||
title = 'Crafting Monitor',
|
title = 'Crafting Monitor',
|
||||||
index = 2,
|
index = 2,
|
||||||
backgroundColor = colors.cyan,
|
|
||||||
[1] = UI.TextArea {
|
[1] = UI.TextArea {
|
||||||
x = 2, ex = -2, y = 2, ey = 3,
|
x = 2, ex = -2, y = 2, ey = 3,
|
||||||
marginRight = 0,
|
marginRight = 0,
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ local STARTUP_FILE = 'usr/autorun/miloRemote.lua'
|
|||||||
local context = ({ ... })[1]
|
local context = ({ ... })[1]
|
||||||
|
|
||||||
local setup = UI.SlideOut {
|
local setup = UI.SlideOut {
|
||||||
backgroundColor = colors.cyan,
|
|
||||||
titleBar = UI.TitleBar {
|
titleBar = UI.TitleBar {
|
||||||
title = 'Remote Setup',
|
title = 'Remote Setup',
|
||||||
},
|
},
|
||||||
@@ -51,7 +50,7 @@ local setup = UI.SlideOut {
|
|||||||
[[also have an introspection module.]],
|
[[also have an introspection module.]],
|
||||||
},
|
},
|
||||||
statusBar = UI.StatusBar {
|
statusBar = UI.StatusBar {
|
||||||
backgroundColor = colors.cyan,
|
backgroundColor = UI.colors.primary,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ end
|
|||||||
local wizardPage = UI.WizardPage {
|
local wizardPage = UI.WizardPage {
|
||||||
title = 'Speaker',
|
title = 'Speaker',
|
||||||
index = 2,
|
index = 2,
|
||||||
backgroundColor = colors.cyan,
|
|
||||||
[1] = UI.Text {
|
[1] = UI.Text {
|
||||||
x = 2, y = 2,
|
x = 2, y = 2,
|
||||||
textColor = colors.yellow,
|
textColor = colors.yellow,
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ Right-clicking on the activity monitor will reset the totals.]]
|
|||||||
local wizardPage = UI.WizardPage {
|
local wizardPage = UI.WizardPage {
|
||||||
title = 'Status Monitor',
|
title = 'Status Monitor',
|
||||||
index = 2,
|
index = 2,
|
||||||
backgroundColor = colors.cyan,
|
|
||||||
[1] = UI.TextArea {
|
[1] = UI.TextArea {
|
||||||
x = 2, ex = -2, y = 2, ey = 6,
|
x = 2, ex = -2, y = 2, ey = 6,
|
||||||
marginRight = 0,
|
marginRight = 0,
|
||||||
@@ -137,12 +136,14 @@ local function createPage(node)
|
|||||||
},
|
},
|
||||||
[2] = UI.Tab {
|
[2] = UI.Tab {
|
||||||
tabTitle = 'Stats',
|
tabTitle = 'Stats',
|
||||||
|
noFill = true,
|
||||||
textArea = UI.TextArea {
|
textArea = UI.TextArea {
|
||||||
y = 3,
|
y = 3,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[3] = UI.Tab {
|
[3] = UI.Tab {
|
||||||
tabTitle = 'Storage',
|
tabTitle = 'Storage',
|
||||||
|
noFill = true,
|
||||||
grid = UI.ScrollingGrid {
|
grid = UI.ScrollingGrid {
|
||||||
y = 2,
|
y = 2,
|
||||||
columns = {
|
columns = {
|
||||||
@@ -157,6 +158,7 @@ local function createPage(node)
|
|||||||
},
|
},
|
||||||
[4] = UI.Tab {
|
[4] = UI.Tab {
|
||||||
tabTitle = 'Offline',
|
tabTitle = 'Offline',
|
||||||
|
noFill = true,
|
||||||
grid = UI.ScrollingGrid {
|
grid = UI.ScrollingGrid {
|
||||||
y = 2,
|
y = 2,
|
||||||
columns = {
|
columns = {
|
||||||
@@ -167,12 +169,14 @@ local function createPage(node)
|
|||||||
},
|
},
|
||||||
[5] = UI.Tab {
|
[5] = UI.Tab {
|
||||||
tabTitle = 'Activity',
|
tabTitle = 'Activity',
|
||||||
|
noFill = true,
|
||||||
term = UI.Embedded {
|
term = UI.Embedded {
|
||||||
--visible = true,
|
--visible = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[6] = UI.Tab {
|
[6] = UI.Tab {
|
||||||
tabTitle = 'Tasks',
|
tabTitle = 'Tasks',
|
||||||
|
noFill = true,
|
||||||
grid = UI.ScrollingGrid {
|
grid = UI.ScrollingGrid {
|
||||||
y = 2,
|
y = 2,
|
||||||
values = context.tasks,
|
values = context.tasks,
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ local device = _G.device
|
|||||||
local storageView = UI.WizardPage {
|
local storageView = UI.WizardPage {
|
||||||
title = 'Storage Options - General',
|
title = 'Storage Options - General',
|
||||||
index = 2,
|
index = 2,
|
||||||
backgroundColor = colors.cyan,
|
|
||||||
form = UI.Form {
|
form = UI.Form {
|
||||||
x = 2, ex = -2, y = 1, ey = -2,
|
x = 2, ex = -2, y = 1, ey = -2,
|
||||||
manualControls = true,
|
manualControls = true,
|
||||||
@@ -62,7 +61,6 @@ UI:getPage('nodeWizard').wizard:add({ storageGeneral = storageView })
|
|||||||
local lockView = UI.WizardPage {
|
local lockView = UI.WizardPage {
|
||||||
title = 'Storage Options - Locking',
|
title = 'Storage Options - Locking',
|
||||||
index = 3,
|
index = 3,
|
||||||
backgroundColor = colors.cyan,
|
|
||||||
form = UI.Form {
|
form = UI.Form {
|
||||||
x = 2, ex = -2, y = 1, ey = 3,
|
x = 2, ex = -2, y = 1, ey = 3,
|
||||||
manualControls = true,
|
manualControls = true,
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ local context = Milo:getContext()
|
|||||||
local wizardPage = UI.WizardPage {
|
local wizardPage = UI.WizardPage {
|
||||||
title = 'Transfer Inventory',
|
title = 'Transfer Inventory',
|
||||||
index = 2,
|
index = 2,
|
||||||
backgroundColor = colors.cyan,
|
|
||||||
grid = UI.ScrollingGrid {
|
grid = UI.ScrollingGrid {
|
||||||
y = 2, ey = -2,
|
y = 2, ey = -2,
|
||||||
values = context.storage.nodes,
|
values = context.storage.nodes,
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ local device = _G.device
|
|||||||
local wizardPage = UI.WizardPage {
|
local wizardPage = UI.WizardPage {
|
||||||
title = 'Trashcan',
|
title = 'Trashcan',
|
||||||
index = 2,
|
index = 2,
|
||||||
backgroundColor = colors.cyan,
|
|
||||||
info = UI.TextArea {
|
info = UI.TextArea {
|
||||||
x = 1, ex = -1, y = 2, ey = 4,
|
x = 1, ex = -1, y = 2, ey = 4,
|
||||||
textColor = colors.yellow,
|
textColor = colors.yellow,
|
||||||
|
|||||||
142
neural/Equipment.lua
Normal file
142
neural/Equipment.lua
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
local Event = require('opus.event')
|
||||||
|
local itemDB = require('core.itemDB')
|
||||||
|
local neural = require('neural.interface')
|
||||||
|
local UI = require('opus.ui')
|
||||||
|
local Util = require('opus.util')
|
||||||
|
|
||||||
|
local device = _G.device
|
||||||
|
|
||||||
|
neural.assertModules({
|
||||||
|
'plethora:sensor',
|
||||||
|
'plethora:kinetic',
|
||||||
|
'plethora:introspection',
|
||||||
|
})
|
||||||
|
UI:configure('Equipment', ...)
|
||||||
|
|
||||||
|
local equipment = device.neuralInterface.getEquipment()
|
||||||
|
|
||||||
|
local slots = {
|
||||||
|
'primary',
|
||||||
|
'offhand',
|
||||||
|
'boots',
|
||||||
|
'leggings',
|
||||||
|
'chest',
|
||||||
|
'helmet',
|
||||||
|
}
|
||||||
|
|
||||||
|
local page = UI.Page {
|
||||||
|
menuBar = UI.MenuBar {
|
||||||
|
buttons = {
|
||||||
|
{ text = 'Drop', event = 'drop' },
|
||||||
|
{ text = 'Suck', event = 'suck' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
grid = UI.Grid {
|
||||||
|
y = 2,
|
||||||
|
columns = {
|
||||||
|
{ heading = 'Slot', key = 'index', width = 7 },
|
||||||
|
{ heading = 'Name', key = 'displayName' },
|
||||||
|
{ heading = 'Count', key = 'count', width = 5, align = 'right' },
|
||||||
|
},
|
||||||
|
sortColumn = 'index',
|
||||||
|
accelerators = {
|
||||||
|
grid_select = 'show_detail',
|
||||||
|
},
|
||||||
|
getDisplayValues = function(_, row)
|
||||||
|
row = Util.shallowCopy(row)
|
||||||
|
if row.name then
|
||||||
|
local item = itemDB:get(
|
||||||
|
table.concat({ row.name, row.damage, row.nbtHash }, ':'),
|
||||||
|
function()
|
||||||
|
return equipment.getItemMeta(row.index)
|
||||||
|
end)
|
||||||
|
row.displayName = item.displayName
|
||||||
|
else
|
||||||
|
row.displayName = 'empty'
|
||||||
|
end
|
||||||
|
row.index = slots[row.index]
|
||||||
|
return row
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
accelerators = {
|
||||||
|
[ 'control-q' ] = 'quit',
|
||||||
|
},
|
||||||
|
detail = UI.SlideOut {
|
||||||
|
menuBar = UI.MenuBar {
|
||||||
|
buttons = {
|
||||||
|
{ text = 'Back', event = 'slide_hide' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
grid = UI.ScrollingGrid {
|
||||||
|
y = 2,
|
||||||
|
columns = {
|
||||||
|
{ heading = 'Name', key = 'name' },
|
||||||
|
{ heading = 'Value', key = 'value' },
|
||||||
|
},
|
||||||
|
sortColumn = 'name',
|
||||||
|
accelerators = {
|
||||||
|
grid_select = 'inspect',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
show = function(self, slot)
|
||||||
|
local detail = equipment.getItemMeta(slot.index)
|
||||||
|
local t = { }
|
||||||
|
for k,v in pairs(detail) do
|
||||||
|
table.insert(t, {
|
||||||
|
name = k,
|
||||||
|
value = v,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
self.grid:setValues(t)
|
||||||
|
self.grid:setIndex(1)
|
||||||
|
UI.SlideOut.show(self)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
enable = function(self)
|
||||||
|
self:refresh()
|
||||||
|
UI.Page.enable(self)
|
||||||
|
end,
|
||||||
|
refresh = function(self)
|
||||||
|
local t = { }
|
||||||
|
local list = equipment.list()
|
||||||
|
for i = 1, equipment.size() do
|
||||||
|
local v = list[i] or { }
|
||||||
|
v.index = i
|
||||||
|
table.insert(t, v)
|
||||||
|
end
|
||||||
|
self.grid:setValues(t)
|
||||||
|
self.grid:draw()
|
||||||
|
end,
|
||||||
|
eventHandler = function(self, event)
|
||||||
|
if event.type == 'quit' then
|
||||||
|
UI:quit()
|
||||||
|
|
||||||
|
elseif event.type == 'show_detail' then
|
||||||
|
if event.selected.name then
|
||||||
|
self.detail:show(event.selected)
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif event.type == 'drop' then
|
||||||
|
local selected = self.grid:getSelected()
|
||||||
|
equipment.drop(selected.index)
|
||||||
|
self:refresh()
|
||||||
|
|
||||||
|
elseif event.type == 'suck' then
|
||||||
|
local selected = self.grid:getSelected()
|
||||||
|
equipment.suck(selected.index)
|
||||||
|
self:refresh()
|
||||||
|
end
|
||||||
|
|
||||||
|
UI.Page.eventHandler(self, event)
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
Event.onInterval(1, function()
|
||||||
|
page:refresh()
|
||||||
|
page:sync()
|
||||||
|
end)
|
||||||
|
|
||||||
|
UI:setPage(page)
|
||||||
|
UI:start()
|
||||||
|
|
||||||
|
itemDB:flush()
|
||||||
@@ -182,7 +182,7 @@ end
|
|||||||
|
|
||||||
function page:eventHandler(event)
|
function page:eventHandler(event)
|
||||||
if event.type == 'quit' then
|
if event.type == 'quit' then
|
||||||
Event.exitPullEvents()
|
UI:quit()
|
||||||
|
|
||||||
elseif event.type == 'scan' then
|
elseif event.type == 'scan' then
|
||||||
self:scan()
|
self:scan()
|
||||||
@@ -211,7 +211,7 @@ Event.onTimeout(0, function()
|
|||||||
page:sync()
|
page:sync()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
UI:pullEvents()
|
UI:start()
|
||||||
|
|
||||||
if canvas then
|
if canvas then
|
||||||
canvas:clear()
|
canvas:clear()
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ end
|
|||||||
|
|
||||||
function page:eventHandler(event)
|
function page:eventHandler(event)
|
||||||
if event.type == 'quit' then
|
if event.type == 'quit' then
|
||||||
Event.exitPullEvents()
|
UI:quit()
|
||||||
|
|
||||||
elseif event.type == 'tab_activate' then
|
elseif event.type == 'tab_activate' then
|
||||||
config.activeTab = event.activated.tabTitle
|
config.activeTab = event.activated.tabTitle
|
||||||
@@ -268,7 +268,7 @@ if config.activeTab then
|
|||||||
end
|
end
|
||||||
|
|
||||||
UI:setPage(page)
|
UI:setPage(page)
|
||||||
UI:pullEvents()
|
UI:start()
|
||||||
|
|
||||||
if canvas then
|
if canvas then
|
||||||
canvas:clear()
|
canvas:clear()
|
||||||
|
|||||||
@@ -29,4 +29,10 @@
|
|||||||
run = "ores.lua",
|
run = "ores.lua",
|
||||||
requires = "neuralInterface",
|
requires = "neuralInterface",
|
||||||
},
|
},
|
||||||
|
[ "7f2465ac7cefab2766e6ee0714647089df9364b0ff09858c84b21b8a436a845d" ] = {
|
||||||
|
title = "Equipment",
|
||||||
|
category = "Neural",
|
||||||
|
run = "Equipment",
|
||||||
|
requires = "neuralInterface",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,15 @@
|
|||||||
--[[
|
--[[
|
||||||
Breed either cows or sheep.
|
Changed to use a 2-high mob (smaller mobs may work ?)
|
||||||
Must be run on a mob with the same height.
|
Updated due to entity.look working correctly now.
|
||||||
|
|
||||||
|
The mob looks head-on to the lever. Make sure the
|
||||||
|
lever is accessible by the mob.
|
||||||
|
|
||||||
|
Laser is now optional - if no laser, the mobs will be
|
||||||
|
punched (or provide a stick). Best mob may be a
|
||||||
|
skeleton (unlimited ammo).
|
||||||
|
|
||||||
|
Feeding hand has been changed to off-hand.
|
||||||
]]
|
]]
|
||||||
|
|
||||||
local Array = require('opus.array')
|
local Array = require('opus.array')
|
||||||
@@ -21,7 +30,7 @@ local WALK_SPEED = 1.5
|
|||||||
neural.assertModules({
|
neural.assertModules({
|
||||||
'plethora:sensor',
|
'plethora:sensor',
|
||||||
'plethora:scanner',
|
'plethora:scanner',
|
||||||
'plethora:laser',
|
--'plethora:laser',
|
||||||
'plethora:kinetic',
|
'plethora:kinetic',
|
||||||
'plethora:introspection',
|
'plethora:introspection',
|
||||||
})
|
})
|
||||||
@@ -29,27 +38,27 @@ neural.assertModules({
|
|||||||
local fed = { }
|
local fed = { }
|
||||||
|
|
||||||
local function resupply()
|
local function resupply()
|
||||||
local slot = neural.getEquipment().list()[1]
|
local slot = neural.getEquipment().list()[2]
|
||||||
if slot and slot.count > 32 then
|
if slot and slot.count > 32 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
print('resupplying')
|
print('resupplying')
|
||||||
for _ = 1, 2 do
|
for _ = 1, 2 do
|
||||||
local dispenser = Map.find(neural.scan(), 'name', 'minecraft:dispenser')
|
local dispenser = Map.find(neural.scan(), 'name', 'minecraft:lever')
|
||||||
if not dispenser then
|
if not dispenser then
|
||||||
print('dispenser not found')
|
print('dispenser not found')
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
if math.abs(dispenser.x) <= 1 and math.abs(dispenser.z) <= 1 then
|
if math.abs(dispenser.x) <= 1 and math.abs(dispenser.z) <= 1 then
|
||||||
neural.lookAt(dispenser)
|
neural.lookAt({ x = dispenser.x, y = dispenser.y, z = dispenser.z })
|
||||||
for _ = 1, 8 do
|
for _ = 1, 8 do
|
||||||
neural.use(0, 'off')
|
neural.use(0, 'off')
|
||||||
os.sleep(.2)
|
os.sleep(.2)
|
||||||
neural.getEquipment().suck(1, 64)
|
neural.getEquipment().suck(2, 64)
|
||||||
end
|
end
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
neural.walkTo({ x = dispenser.x, y = 0, z = dispenser.z }, WALK_SPEED)
|
neural.walkTo({ x = dispenser.x, y = 0, z = dispenser.z }, WALK_SPEED, .5)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -63,18 +72,22 @@ local function breed(entity)
|
|||||||
entity = neural.getMetaByID(entity.id)
|
entity = neural.getMetaByID(entity.id)
|
||||||
if entity then
|
if entity then
|
||||||
neural.lookAt(entity)
|
neural.lookAt(entity)
|
||||||
neural.use(1)
|
neural.use(1, 'off')
|
||||||
os.sleep(.1)
|
os.sleep(.1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function kill(entity)
|
local function kill(entity)
|
||||||
print('killing')
|
print('killing')
|
||||||
neural.walkTo(entity, WALK_SPEED, 2.5)
|
neural.walkTo(entity, WALK_SPEED, (neural.fire or neural.shoot) and 2.5 or .5)
|
||||||
entity = neural.getMetaByID(entity.id)
|
entity = neural.getMetaByID(entity.id)
|
||||||
if entity then
|
if entity then
|
||||||
neural.lookAt(entity)
|
neural.lookAt(entity)
|
||||||
neural.fireAt({ x = entity.x, y = 0, z = entity.z })
|
if neural.fire or neural.shoot then
|
||||||
|
neural.shootAt(entity)
|
||||||
|
else
|
||||||
|
neural.swing()
|
||||||
|
end
|
||||||
Sound.play('entity.firework.launch')
|
Sound.play('entity.firework.launch')
|
||||||
os.sleep(.2)
|
os.sleep(.2)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -172,11 +172,11 @@ function page:eventHandler(event)
|
|||||||
self.info:draw()
|
self.info:draw()
|
||||||
|
|
||||||
elseif event.type == 'quit' then
|
elseif event.type == 'quit' then
|
||||||
UI:exitPullEvents()
|
UI:quit()
|
||||||
end
|
end
|
||||||
|
|
||||||
UI.Page.eventHandler(self, event)
|
UI.Page.eventHandler(self, event)
|
||||||
end
|
end
|
||||||
|
|
||||||
UI:setPage(page)
|
UI:setPage(page)
|
||||||
UI:pullEvents()
|
UI:start()
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ local function buildLockScreen()
|
|||||||
#self.pass.value > 0 and
|
#self.pass.value > 0 and
|
||||||
Security.verifyPassword(SHA.compute(self.pass.value)) then
|
Security.verifyPassword(SHA.compute(self.pass.value)) then
|
||||||
|
|
||||||
UI:exitPullEvents() -- valid
|
UI:quit() -- valid
|
||||||
else
|
else
|
||||||
self.notification:error('Invalid password', math.max(counter, 2))
|
self.notification:error('Invalid password', math.max(counter, 2))
|
||||||
self:sync()
|
self:sync()
|
||||||
@@ -66,7 +66,7 @@ local function buildLockScreen()
|
|||||||
Event.onTerminate(function() return false end)
|
Event.onTerminate(function() return false end)
|
||||||
|
|
||||||
UI:setPage(page)
|
UI:setPage(page)
|
||||||
UI:pullEvents()
|
UI:start()
|
||||||
|
|
||||||
-- restart lock timer
|
-- restart lock timer
|
||||||
timer = os.startTimer(config.timeout)
|
timer = os.startTimer(config.timeout)
|
||||||
|
|||||||
@@ -189,4 +189,4 @@ end)
|
|||||||
|
|
||||||
page.grid:loadTransactions()
|
page.grid:loadTransactions()
|
||||||
UI:setPage(page)
|
UI:setPage(page)
|
||||||
UI:pullEvents()
|
UI:start()
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ local os = _G.os
|
|||||||
local wizardPage = UI.WizardPage {
|
local wizardPage = UI.WizardPage {
|
||||||
title = 'Store Front',
|
title = 'Store Front',
|
||||||
index = 2,
|
index = 2,
|
||||||
backgroundColor = colors.cyan,
|
|
||||||
form = UI.Form {
|
form = UI.Form {
|
||||||
x = 2, ex = -2, y = 1, ey = -2,
|
x = 2, ex = -2, y = 1, ey = -2,
|
||||||
manualControls = true,
|
manualControls = true,
|
||||||
@@ -90,7 +89,6 @@ end
|
|||||||
local passwordPage = UI.WizardPage {
|
local passwordPage = UI.WizardPage {
|
||||||
title = 'Krist Settings',
|
title = 'Krist Settings',
|
||||||
index = 3,
|
index = 3,
|
||||||
backgroundColor = colors.cyan,
|
|
||||||
form = UI.Form {
|
form = UI.Form {
|
||||||
x = 2, ex = -2, y = 1, ey = -2,
|
x = 2, ex = -2, y = 1, ey = -2,
|
||||||
manualControls = true,
|
manualControls = true,
|
||||||
@@ -112,7 +110,7 @@ local passwordPage = UI.WizardPage {
|
|||||||
preview = UI.TextEntry {
|
preview = UI.TextEntry {
|
||||||
formIndex = 4,
|
formIndex = 4,
|
||||||
formLabel = 'Using address', formKey = 'address',
|
formLabel = 'Using address', formKey = 'address',
|
||||||
backgroundColor = colors.cyan,
|
backgroundColor = UI.colors.primary,
|
||||||
textColor = colors.yellow,
|
textColor = colors.yellow,
|
||||||
inactive = true,
|
inactive = true,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user