bug fixes storage mgr

This commit is contained in:
kepler155c@gmail.com 2017-04-22 00:51:27 -04:00
parent c57ff1541b
commit 8774d98009
5 changed files with 82 additions and 29 deletions

View File

@ -16,7 +16,7 @@ multishell.setTitle(multishell.getCurrent(), 'Storage Manager')
function getItem(items, inItem, ignoreDamage) function getItem(items, inItem, ignoreDamage)
for _,item in pairs(items) do for _,item in pairs(items) do
if item.name == inItem.name then if item.name == inItem.name then
if ignoreDamage and ignoreDamage == 'yes' then if ignoreDamage then
return item return item
elseif item.damage == inItem.damage and item.nbtHash == inItem.nbtHash then elseif item.damage == inItem.damage and item.nbtHash == inItem.nbtHash then
return item return item
@ -111,7 +111,7 @@ function getAutocraftItems(items)
for _,res in pairs(t) do for _,res in pairs(t) do
if res.auto and res.auto == 'yes' then if res.auto then
res.count = 4 -- this could be higher to increase autocrafting speed res.count = 4 -- this could be higher to increase autocrafting speed
table.insert(itemList, res) table.insert(itemList, res)
end end
@ -125,7 +125,7 @@ local function getItemWithQty(items, res, ignoreDamage)
if item then if item then
if ignoreDamage and ignoreDamage == 'yes' then if ignoreDamage then
local count = 0 local count = 0
for _,v in pairs(items) do for _,v in pairs(items) do
@ -163,7 +163,7 @@ function watchResources(items)
end end
if res.low and item.count < res.low then if res.low and item.count < res.low then
if res.ignoreDamage and res.ignoreDamage == 'yes' then if res.ignoreDamage then
item.damage = 0 item.damage = 0
end end
table.insert(itemList, { table.insert(itemList, {
@ -201,7 +201,7 @@ itemPage = UI.Page {
x = 5, y = 3, width = UI.term.width - 10, height = 3, x = 5, y = 3, width = UI.term.width - 10, height = 3,
}, },
form = UI.Form { form = UI.Form {
x = 4, y = 5, height = 10, rex = -4, x = 4, y = 6, height = 10, rex = -4,
[1] = UI.TextEntry { [1] = UI.TextEntry {
width = 7, width = 7,
backgroundColor = colors.gray, backgroundColor = colors.gray,
@ -213,8 +213,8 @@ itemPage = UI.Page {
formLabel = 'Autocraft', formKey = 'auto', formLabel = 'Autocraft', formKey = 'auto',
nochoice = 'No', nochoice = 'No',
choices = { choices = {
{ name = 'Yes', value = 'yes' }, { name = 'Yes', value = true },
{ name = 'No', value = 'no' }, { name = 'No', value = false },
}, },
help = 'Craft until out of ingredients' help = 'Craft until out of ingredients'
}, },
@ -223,8 +223,8 @@ itemPage = UI.Page {
formLabel = 'Ignore Dmg', formKey = 'ignoreDamage', formLabel = 'Ignore Dmg', formKey = 'ignoreDamage',
nochoice = 'No', nochoice = 'No',
choices = { choices = {
{ name = 'Yes', value = 'yes' }, { name = 'Yes', value = true },
{ name = 'No', value = 'no' }, { name = 'No', value = false },
}, },
help = 'Ignore damage of item' help = 'Ignore damage of item'
}, },
@ -241,7 +241,6 @@ itemPage = UI.Page {
[5] = UI.Chooser { [5] = UI.Chooser {
width = 25, width = 25,
formLabel = 'RS Device', formKey = 'rsDevice', formLabel = 'RS Device', formKey = 'rsDevice',
nochoice = 'No',
--choices = devices, --choices = devices,
help = 'Redstone Device' help = 'Redstone Device'
}, },
@ -288,6 +287,10 @@ function itemPage:enable(item)
end end
end end
if Util.size(devices) == 0 then
table.insert(devices, { name = 'None found', values = '' })
end
UI.Page.enable(self) UI.Page.enable(self)
self:focusFirst() self:focusFirst()
end end
@ -304,7 +307,8 @@ function itemPage:eventHandler(event)
local values = self.form.values local values = self.form.values
local t = Util.readTable('resource.limits') or { } local t = Util.readTable('resource.limits') or { }
for k,v in pairs(t) do for k,v in pairs(t) do
if v.name == values.name and v.damage == values.damage then if uniqueKey(v) == uniqueKey(values) then
--if v.name == values.name and v.damage == values.damage then
t[k] = nil t[k] = nil
break break
end end
@ -316,8 +320,14 @@ function itemPage:eventHandler(event)
for _,key in pairs(keys) do for _,key in pairs(keys) do
filtered[key] = values[key] filtered[key] = values[key]
end end
filtered.low = tonumber(filtered.low)
filtered.limit = tonumber(filtered.limit)
if filtered.ignoreDamage and filtered.ignoreDamage == 'yes' then filtered.ignoreDamage = filtered.ignoreDamage == true
filtered.auto = filtered.auto == true
filtered.rsControl = filtered.rsControl == true
if filtered.ignoreDamage then
filtered.damage = 0 filtered.damage = 0
end end

View File

@ -1,18 +1,15 @@
require = requireInjector(getfenv(1)) require = requireInjector(getfenv(1))
local Point = require('point') local Point = require('point')
local checkedNodes = { } local checkedNodes, nodes
local nodes = { }
local function addNode(node) local function addNode(node)
local key = table.concat({ node.x, node.z }, ':')
for i = 0, 3 do for i = 0, 3 do
local hi = turtle.getHeadingInfo(i) local hi = turtle.getHeadingInfo(i)
local testNode = { x = node.x + hi.xd, z = node.z + hi.zd } local testNode = { x = node.x + hi.xd, z = node.z + hi.zd }
key = table.concat({ testNode.x, testNode.z }, ':') local key = table.concat({ testNode.x, testNode.z }, ':')
if not checkedNodes[key] then if not checkedNodes[key] then
nodes[key] = testNode nodes[key] = testNode
end end
@ -20,17 +17,30 @@ local function addNode(node)
end end
local function findObsidian() local function findObsidian()
while true do repeat
local _,b = turtle.inspectDown()
local node = { x = turtle.point.x, z = turtle.point.z } local node = { x = turtle.point.x, z = turtle.point.z }
local key = table.concat({ node.x, node.z }, ':') local key = table.concat({ node.x, node.z }, ':')
checkedNodes[key] = true checkedNodes[key] = true
nodes[key] = nil nodes[key] = nil
local _,b = turtle.inspectDown()
if b and (b.name == 'minecraft:lava' or b.name == 'minecraft:flowing_lava') then
if turtle.selectSlot('minecraft:water_bucket') then
turtle.up()
turtle.placeDown()
os.sleep(2)
turtle.placeDown()
turtle.down()
_, b = turtle.inspectDown()
end
end
if b and b.name == 'minecraft:obsidian' then if b and b.name == 'minecraft:obsidian' then
turtle.digDown() turtle.digDown()
addNode(node) addNode(node)
else
turtle.digDown()
end end
print(string.format('%d nodes remaining', Util.size(nodes))) print(string.format('%d nodes remaining', Util.size(nodes)))
@ -43,16 +53,35 @@ local function findObsidian()
if not turtle.gotoPoint(node) then if not turtle.gotoPoint(node) then
break break
end end
until turtle.abort
end
end end
turtle.reset() turtle.reset()
turtle.setPolicy(turtle.policies.digOnly) turtle.setPolicy(turtle.policies.digOnly)
local s, m = turtle.run(function() findObsidian() end) local s, m = turtle.run(function()
repeat
checkedNodes = { }
nodes = { }
local _,b = turtle.inspectDown()
if not b or b.name ~= 'minecraft:obsidian' then
break
end
findObsidian()
if not turtle.selectSlot('minecraft:water_bucket') then
break
end
turtle.goto(0, 0)
turtle.placeDown()
os.sleep(2)
turtle.placeDown()
turtle.down()
until turtle.abort
end)
turtle.goto(0, 0, 0, 0)
turtle.reset()
if not s and m then if not s and m then
error(m) error(m)
end end
turtle.goto(0, 0, 0, 0)
turtle.reset()

View File

@ -48,12 +48,15 @@ function RefinedProvider:getCachedItemDetails(item)
detail.id = detail.name detail.id = detail.name
detail.qty = detail.count detail.qty = detail.count
detail.display_name = detail.displayName detail.display_name = detail.displayName
detail.nbtHash = item.nbtHash
self.cache[key] = detail self.cache[key] = detail
end end
end end
end end
return detail if detail then
return Util.shallowCopy(detail)
end
end end
function RefinedProvider:listItems() function RefinedProvider:listItems()

View File

@ -1464,6 +1464,10 @@ end
function UI.Grid:setParent() function UI.Grid:setParent()
UI.Window.setParent(self) UI.Window.setParent(self)
self:update() self:update()
end
function UI.Grid:resize()
UI.Window.resize(self)
if not self.pageSize then if not self.pageSize then
if self.disableHeader then if self.disableHeader then
@ -2287,6 +2291,7 @@ function UI.Tabs:setParent()
if child ~= self.tabBar then if child ~= self.tabBar then
child.y = 2 child.y = 2
child.height = self.height - 1 child.height = self.height - 1
child:resize()
end end
end end
end end
@ -3061,6 +3066,9 @@ function UI.Form:setValues(values)
self.values = values self.values = values
for k,child in pairs(self.children) do for k,child in pairs(self.children) do
if child.formKey then if child.formKey then
-- this should be child:setValue(self.values[child.formKey])
-- so chooser can set default choice if null
-- null should be valid as well
child.value = self.values[child.formKey] or '' child.value = self.values[child.formKey] or ''
end end
end end

View File

@ -91,13 +91,16 @@ function os.isPocket()
end end
function os.getVersion() function os.getVersion()
local version
if _CC_VERSION then if _CC_VERSION then
return tonumber(_CC_VERSION) version = tonumber(_CC_VERSION)
end end
if _HOST then if _HOST then
return tonumber(_HOST:gmatch('[%d]+%.?[%d][%d]', '%1')()) version = tonumber(_HOST:gmatch('[%d]+%.?[%d][%d]', '%1')())
end end
return 1.7
return version or 1.7
end end
function os.registerApp(entry) function os.registerApp(entry)