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

View File

@ -1,18 +1,15 @@
require = requireInjector(getfenv(1))
local Point = require('point')
local checkedNodes = { }
local nodes = { }
local checkedNodes, nodes
local function addNode(node)
local key = table.concat({ node.x, node.z }, ':')
for i = 0, 3 do
local hi = turtle.getHeadingInfo(i)
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
nodes[key] = testNode
end
@ -20,17 +17,30 @@ local function addNode(node)
end
local function findObsidian()
while true do
local _,b = turtle.inspectDown()
repeat
local node = { x = turtle.point.x, z = turtle.point.z }
local key = table.concat({ node.x, node.z }, ':')
checkedNodes[key] = true
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
turtle.digDown()
addNode(node)
else
turtle.digDown()
end
print(string.format('%d nodes remaining', Util.size(nodes)))
@ -43,16 +53,35 @@ local function findObsidian()
if not turtle.gotoPoint(node) then
break
end
end
until turtle.abort
end
turtle.reset()
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
error(m)
end
turtle.goto(0, 0, 0, 0)
turtle.reset()

View File

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

View File

@ -1464,6 +1464,10 @@ end
function UI.Grid:setParent()
UI.Window.setParent(self)
self:update()
end
function UI.Grid:resize()
UI.Window.resize(self)
if not self.pageSize then
if self.disableHeader then
@ -2287,6 +2291,7 @@ function UI.Tabs:setParent()
if child ~= self.tabBar then
child.y = 2
child.height = self.height - 1
child:resize()
end
end
end
@ -3061,6 +3066,9 @@ function UI.Form:setValues(values)
self.values = values
for k,child in pairs(self.children) do
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 ''
end
end

View File

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