mirror of
https://github.com/kepler155c/opus
synced 2024-12-25 16:10:26 +00:00
new icon set + scanning miner
This commit is contained in:
parent
e6a98b34cb
commit
ecb3af4672
@ -144,14 +144,21 @@ function Point.calculateMoves(pta, ptb, distance)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if ptb.heading then
|
if not ptb.heading then
|
||||||
if heading ~= ptb.heading then
|
return moves, heading, moves
|
||||||
moves = moves + Point.calculateTurns(heading, ptb.heading)
|
|
||||||
heading = ptb.heading
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return moves, heading
|
-- calc turns as slightly less than moves
|
||||||
|
local weighted = moves
|
||||||
|
if heading ~= ptb.heading then
|
||||||
|
local turns = Point.calculateTurns(heading, ptb.heading)
|
||||||
|
moves = moves + turns
|
||||||
|
local wturns = { [0] = 0, [1] = .9, [2] = 1.9 }
|
||||||
|
weighted = weighted + wturns[turns]
|
||||||
|
heading = ptb.heading
|
||||||
|
end
|
||||||
|
|
||||||
|
return moves, heading, weighted
|
||||||
end
|
end
|
||||||
|
|
||||||
-- given a set of points, find the one taking the least moves
|
-- given a set of points, find the one taking the least moves
|
||||||
@ -164,7 +171,7 @@ function Point.closest(reference, pts)
|
|||||||
for _,pt in pairs(pts) do
|
for _,pt in pairs(pts) do
|
||||||
local distance = Point.turtleDistance(reference, pt)
|
local distance = Point.turtleDistance(reference, pt)
|
||||||
if distance < lm then
|
if distance < lm then
|
||||||
local m = Point.calculateMoves(reference, pt, distance)
|
local _, _, m = Point.calculateMoves(reference, pt, distance)
|
||||||
if m < lm then
|
if m < lm then
|
||||||
lpt = pt
|
lpt = pt
|
||||||
lm = m
|
lm = m
|
||||||
|
@ -32,9 +32,9 @@ local config = {
|
|||||||
Config.load('Overview', config)
|
Config.load('Overview', config)
|
||||||
|
|
||||||
local applications = { }
|
local applications = { }
|
||||||
|
local extSupport = Util.getVersion() >= 1.76
|
||||||
|
|
||||||
local function loadApplications()
|
local function loadApplications()
|
||||||
|
|
||||||
local requirements = {
|
local requirements = {
|
||||||
turtle = function() return turtle end,
|
turtle = function() return turtle end,
|
||||||
advancedTurtle = function() return turtle and term.isColor() end,
|
advancedTurtle = function() return turtle and term.isColor() end,
|
||||||
@ -117,7 +117,7 @@ local function parseIcon(iconText)
|
|||||||
icon = NFT.parse(iconText)
|
icon = NFT.parse(iconText)
|
||||||
if icon then
|
if icon then
|
||||||
if icon.height > 3 or icon.width > 8 then
|
if icon.height > 3 or icon.width > 8 then
|
||||||
error('Invalid size')
|
error('Must be an NFT image - 3 rows, 8 cols max')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return icon
|
return icon
|
||||||
@ -174,6 +174,10 @@ local page = UI.Page {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if extSupport then
|
||||||
|
page.container.backgroundColor = colors.black
|
||||||
|
end
|
||||||
|
|
||||||
UI.Icon = class(UI.Window)
|
UI.Icon = class(UI.Window)
|
||||||
UI.Icon.defaults = {
|
UI.Icon.defaults = {
|
||||||
UIElement = 'Icon',
|
UIElement = 'Icon',
|
||||||
@ -194,7 +198,6 @@ function UI.Icon:eventHandler(event)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function page.container:setCategory(categoryName, animate)
|
function page.container:setCategory(categoryName, animate)
|
||||||
|
|
||||||
-- reset the viewport window
|
-- reset the viewport window
|
||||||
self.children = { }
|
self.children = { }
|
||||||
self.offy = 0
|
self.offy = 0
|
||||||
@ -231,7 +234,10 @@ function page.container:setCategory(categoryName, animate)
|
|||||||
for _,program in ipairs(filtered) do
|
for _,program in ipairs(filtered) do
|
||||||
|
|
||||||
local icon
|
local icon
|
||||||
if program.icon then
|
if extSupport and program.iconExt then
|
||||||
|
icon = parseIcon(program.iconExt)
|
||||||
|
end
|
||||||
|
if not icon and program.icon then
|
||||||
icon = parseIcon(program.icon)
|
icon = parseIcon(program.icon)
|
||||||
end
|
end
|
||||||
if not icon then
|
if not icon then
|
||||||
@ -344,7 +350,6 @@ function page:resize()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function page:eventHandler(event)
|
function page:eventHandler(event)
|
||||||
|
|
||||||
if event.type == 'tab_select' then
|
if event.type == 'tab_select' then
|
||||||
self.container:setCategory(event.button.text, true)
|
self.container:setCategory(event.button.text, true)
|
||||||
self.container:draw()
|
self.container:draw()
|
||||||
@ -455,7 +460,10 @@ function editor:enable(app)
|
|||||||
self.form:setValues(app)
|
self.form:setValues(app)
|
||||||
|
|
||||||
local icon
|
local icon
|
||||||
if app.icon then
|
if extSupport and app.iconExt then
|
||||||
|
icon = parseIcon(app.iconExt)
|
||||||
|
end
|
||||||
|
if not icon and app.icon then
|
||||||
icon = parseIcon(app.icon)
|
icon = parseIcon(app.icon)
|
||||||
end
|
end
|
||||||
self.form.image:setImage(icon)
|
self.form.image:setImage(icon)
|
||||||
@ -479,7 +487,6 @@ function editor:updateApplications(app)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function editor:eventHandler(event)
|
function editor:eventHandler(event)
|
||||||
|
|
||||||
if event.type == 'form_cancel' or event.type == 'cancel' then
|
if event.type == 'form_cancel' or event.type == 'cancel' then
|
||||||
UI:setPreviousPage()
|
UI:setPreviousPage()
|
||||||
|
|
||||||
@ -501,13 +508,17 @@ function editor:eventHandler(event)
|
|||||||
local s, m = pcall(function()
|
local s, m = pcall(function()
|
||||||
local iconLines = Util.readFile(fileName)
|
local iconLines = Util.readFile(fileName)
|
||||||
if not iconLines then
|
if not iconLines then
|
||||||
error('Unable to load file')
|
error('Must be an NFT image - 3 rows, 8 cols max')
|
||||||
end
|
end
|
||||||
local icon, m = parseIcon(iconLines)
|
local icon, m = parseIcon(iconLines)
|
||||||
if not icon then
|
if not icon then
|
||||||
error(m)
|
error(m)
|
||||||
end
|
end
|
||||||
self.form.values.icon = iconLines
|
if extSupport then
|
||||||
|
self.form.values.iconExt = iconLines
|
||||||
|
else
|
||||||
|
self.form.values.icon = iconLines
|
||||||
|
end
|
||||||
self.form.image:setImage(icon)
|
self.form.image:setImage(icon)
|
||||||
self.form.image:draw()
|
self.form.image:draw()
|
||||||
end)
|
end)
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
{
|
{
|
||||||
[ "53ebc572b4a44802ba114729f07bdaaf5409a9d7" ] = {
|
[ "53ebc572b4a44802ba114729f07bdaaf5409a9d7" ] = {
|
||||||
|
title = "Network",
|
||||||
category = "Apps",
|
category = "Apps",
|
||||||
icon = "\0304 \030 \
|
icon = "\0304 \030 \
|
||||||
\030f \0304 \0307 \030 \031 \031f)\
|
\030f \0304 \0307 \030 \031 \031f)\
|
||||||
\030f \0304 \0307 \030 \031f)",
|
\030f \0304 \0307 \030 \031f)",
|
||||||
title = "Network",
|
iconExt = "\030 \031f \0305\031f\140\030f\0315\137\144\
|
||||||
|
\030 \031f\030f\0314\131\131\0304\031f\148\030 \0305\155\150\149\
|
||||||
|
\030 \031f\030f\0310\147\0300\031f\141\0304\149\0307\0318\149\030 ",
|
||||||
run = "Network.lua",
|
run = "Network.lua",
|
||||||
},
|
},
|
||||||
c7116629a6a855cb774d9c7c8ad822fd83c71fb5 = {
|
c7116629a6a855cb774d9c7c8ad822fd83c71fb5 = {
|
||||||
@ -21,6 +24,9 @@
|
|||||||
icon = "\0301\03171\03180\030 \031 \
|
icon = "\0301\03171\03180\030 \031 \
|
||||||
\0301\03181\030 \031 \
|
\0301\03181\030 \031 \
|
||||||
\0301\03170\03180\03171\0307\031f>",
|
\0301\03170\03180\03171\0307\031f>",
|
||||||
|
iconExt = "\031f\128\0315\152\131\131\132\031f\128\
|
||||||
|
\0315\139\159\129\0305\031f\159\129\139\
|
||||||
|
\031f\128\0315\136\0305\031f\143\143\030f\0315\134\031f\128",
|
||||||
run = "http://pastebin.com/raw/UzGHLbNC",
|
run = "http://pastebin.com/raw/UzGHLbNC",
|
||||||
},
|
},
|
||||||
c47ae15370cfe1ed2781eedc1dc2547d12d9e972 = {
|
c47ae15370cfe1ed2781eedc1dc2547d12d9e972 = {
|
||||||
@ -29,6 +35,9 @@
|
|||||||
icon = " \031f?\031 \
|
icon = " \031f?\031 \
|
||||||
\031f?\031 \
|
\031f?\031 \
|
||||||
\031f?",
|
\031f?",
|
||||||
|
iconExt = "\0300\031f\129\030f\0310\131\0300\031f\148\030f\0310\148\
|
||||||
|
\030 \031 \0300\031f\131\030f\0310\142\129\
|
||||||
|
\030 \031 \0300\031f\131\030f\128",
|
||||||
run = "Help.lua",
|
run = "Help.lua",
|
||||||
},
|
},
|
||||||
b0832074630eb731d7fbe8074de48a90cd9bb220 = {
|
b0832074630eb731d7fbe8074de48a90cd9bb220 = {
|
||||||
@ -53,6 +62,9 @@
|
|||||||
icon = " \0307\031f| \
|
icon = " \0307\031f| \
|
||||||
\0307\031f---o\030 \031 \
|
\0307\031f---o\030 \031 \
|
||||||
\0307\031f| ",
|
\0307\031f| ",
|
||||||
|
iconExt = "\0318\138\0308\031f\130\0318\128\031f\129\030f\0318\133\
|
||||||
|
\0318\143\0308\128\0317\143\0318\128\030f\143\
|
||||||
|
\0318\138\135\143\139\133",
|
||||||
run = "System.lua",
|
run = "System.lua",
|
||||||
},
|
},
|
||||||
c5497bca58468ae64aed6c0fd921109217988db3 = {
|
c5497bca58468ae64aed6c0fd921109217988db3 = {
|
||||||
@ -69,6 +81,9 @@
|
|||||||
icon = "\030f\031f \0315/\
|
icon = "\030f\031f \0315/\
|
||||||
\030f\031f \0315/\\/ \
|
\030f\031f \0315/\\/ \
|
||||||
\030f\0315/\031f ",
|
\030f\0315/\031f ",
|
||||||
|
iconExt = "\031f\128\128\0305\159\030f\128\0305\159\030f\0315\134\031f\128\
|
||||||
|
\031f\128\0315\152\129\137\0305\031f\158\139\030f\0315\144\
|
||||||
|
\0315\134\031f\128\128\128\128\0305\154\030f\0315\144",
|
||||||
run = "Tasks.lua",
|
run = "Tasks.lua",
|
||||||
},
|
},
|
||||||
[ "6ce6c512ea433a7fc5c8841628e7696cd0ff7f2b" ] = {
|
[ "6ce6c512ea433a7fc5c8841628e7696cd0ff7f2b" ] = {
|
||||||
@ -77,6 +92,9 @@
|
|||||||
icon = "\0300\0317==\031 \0307 \
|
icon = "\0300\0317==\031 \0307 \
|
||||||
\0300\0317====\
|
\0300\0317====\
|
||||||
\0300\0317====",
|
\0300\0317====",
|
||||||
|
iconExt = "\030 \031f\0300\031f\136\140\132\0308\130\030f\0318\144\
|
||||||
|
\030 \031f\030f\0310\157\0300\031f\147\030f\0310\142\143\149\
|
||||||
|
\030 \031f\0300\031f\136\140\132\140\030f\0310\149",
|
||||||
run = "Files.lua",
|
run = "Files.lua",
|
||||||
},
|
},
|
||||||
[ "7fddb7d8d1d60b1eeefa9af01082e0811d4b484d" ] = {
|
[ "7fddb7d8d1d60b1eeefa9af01082e0811d4b484d" ] = {
|
||||||
@ -127,6 +145,9 @@
|
|||||||
icon = "\030d \030 \030e \030 \
|
icon = "\030d \030 \030e \030 \
|
||||||
\030d \030 \
|
\030d \030 \
|
||||||
\030d ",
|
\030d ",
|
||||||
|
iconExt = "\030 \031f\0305\031f\151\030f\0315\135\131\0305\031f\146\
|
||||||
|
\030 \031f\030f\0315\130\141\0305\031f\139\030f\0315\130\
|
||||||
|
\030 \031f\0305\031f\146\143\030f\0315\158\031e\130",
|
||||||
run = "/rom/programs/fun/worm",
|
run = "/rom/programs/fun/worm",
|
||||||
},
|
},
|
||||||
[ "9f46ca3ef617166776ef6014a58d4e66859caa62" ] = {
|
[ "9f46ca3ef617166776ef6014a58d4e66859caa62" ] = {
|
||||||
@ -135,6 +156,9 @@
|
|||||||
icon = " \030f \
|
icon = " \030f \
|
||||||
\030f \0307 \
|
\030f \0307 \
|
||||||
\030f \0307 \0300 ",
|
\030f \0307 \0300 ",
|
||||||
|
iconExt = "\031f\128\0307\143\131\131\131\131\143\030f\128\
|
||||||
|
\0307\031f\129\0317\128\0319\136\0309\031b\136\132\0307\0319\132\0317\128\031f\130\
|
||||||
|
\0317\130\143\0307\128\128\128\128\030f\143\129",
|
||||||
run = "/rom/programs/fun/dj",
|
run = "/rom/programs/fun/dj",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -662,11 +662,11 @@ function turtle._goto(pt)
|
|||||||
local dx, dy, dz, dh = pt.x, pt.y, pt.z, pt.heading
|
local dx, dy, dz, dh = pt.x, pt.y, pt.z, pt.heading
|
||||||
if not turtle.gotoSingleTurn(dx, dy, dz, dh) then
|
if not turtle.gotoSingleTurn(dx, dy, dz, dh) then
|
||||||
if not gotoMultiTurn(dx, dy, dz) then
|
if not gotoMultiTurn(dx, dy, dz) then
|
||||||
return false
|
return false, 'Failed to reach location'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
turtle.setHeading(dh)
|
turtle.setHeading(dh)
|
||||||
return true
|
return pt
|
||||||
end
|
end
|
||||||
|
|
||||||
-- avoid lint errors
|
-- avoid lint errors
|
||||||
@ -738,6 +738,8 @@ function turtle.getSlot(indexOrId, slots)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- inconsistent return value
|
||||||
|
-- null is returned if indexOrId is a string and no item is present
|
||||||
return {
|
return {
|
||||||
qty = 0, -- deprecate
|
qty = 0, -- deprecate
|
||||||
count = 0,
|
count = 0,
|
||||||
@ -794,8 +796,12 @@ function turtle.getSummedInventory()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function turtle.has(item, count)
|
function turtle.has(item, count)
|
||||||
local slot = turtle.getSummedInventory()[item]
|
if item:match('.*:%d') then
|
||||||
return slot and slot.count >= (count or 1)
|
local slot = turtle.getSummedInventory()[item]
|
||||||
|
return slot and slot.count >= (count or 1)
|
||||||
|
end
|
||||||
|
local slot = turtle.getSlot(item)
|
||||||
|
return slot and slot.count > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function turtle.getFilledSlots(startSlot)
|
function turtle.getFilledSlots(startSlot)
|
||||||
@ -966,6 +972,18 @@ function turtle.addWorldBlock(pt)
|
|||||||
Pathing.addBlock(pt)
|
Pathing.addBlock(pt)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local movementStrategy = turtle.pathfind
|
||||||
|
|
||||||
|
function turtle.setMovementStrategy(strategy)
|
||||||
|
if strategy == 'pathing' then
|
||||||
|
movementStrategy = turtle.pathfind
|
||||||
|
elseif strategy == 'goto' then
|
||||||
|
movementStrategy = turtle._goto
|
||||||
|
else
|
||||||
|
error('Invalid movement strategy')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function turtle.faceAgainst(pt, options) -- 4 sided
|
function turtle.faceAgainst(pt, options) -- 4 sided
|
||||||
options = options or { }
|
options = options or { }
|
||||||
options.dest = { }
|
options.dest = { }
|
||||||
@ -980,7 +998,7 @@ function turtle.faceAgainst(pt, options) -- 4 sided
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
return turtle.pathfind(Point.closest(turtle.point, options.dest), options)
|
return movementStrategy(Point.closest(turtle.point, options.dest), options)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- move against this point
|
-- move against this point
|
||||||
@ -1012,7 +1030,7 @@ function turtle.moveAgainst(pt, options) -- 6 sided
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
return turtle.pathfind(Point.closest(turtle.point, options.dest), options)
|
return movementStrategy(Point.closest(turtle.point, options.dest), options)
|
||||||
end
|
end
|
||||||
|
|
||||||
local actionsAt = {
|
local actionsAt = {
|
||||||
@ -1097,7 +1115,7 @@ local function _actionAt(action, pt, ...)
|
|||||||
direction = 'up'
|
direction = 'up'
|
||||||
end
|
end
|
||||||
|
|
||||||
if turtle.pathfind(apt) then
|
if movementStrategy(apt) then
|
||||||
return action[direction](...)
|
return action[direction](...)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user