package management

This commit is contained in:
kepler155c
2018-11-03 18:14:11 -04:00
parent aa66b1c663
commit 1f7ef4a483
124 changed files with 1274 additions and 9 deletions

9
forestry/.package Normal file
View File

@@ -0,0 +1,9 @@
{
required = {
'opus-develop-1.8',
},
title = 'Forestry mod applications',
repository = 'kepler155c/opus-apps/develop1.8/forestry',
description = [[ ... ]],
licence = 'MIT',
}

106
forestry/alveary.lua Normal file
View File

@@ -0,0 +1,106 @@
_G.requireInjector(_ENV)
local Event = require('event')
local UI = require('ui')
redstone.setBundledOutput('bottom', 0)
local function regulate(humidity, heat)
local heater = heat == 'Up 1' or heat == 'Both 1'
local lava = heat == 'Both 1'
local water = humidity == 'Up 1'
local c = colors.combine(
lava and colors.green or 0,
heater and colors.red or 0,
water and colors.blue or 0)
redstone.setBundledOutput('bottom', c)
end
function create(alveary, terminal)
local window = UI.Window({
alveary = alveary,
parent = UI.Device({
device = terminal,
textScale = 0.5,
backgroundColor = colors.green
}),
progressBar = UI.ProgressBar({
y = 3,
x = 2, ex = -2,
}),
--[[
heater = UI.Button {
x = 2, y = -2, width = 7,
text = 'heater',
},
humidifier = UI.Button {
x = 2, y = -4,
text = 'Humidify',
},
dehumidifier = UI.Button {
x = 2, y = -6,
text = 'Dehumidify',
},
--]]
})
function window:draw()
local queen = self.alveary.getQueen()
if not queen then
self:clear(colors.black)
regulate()
else
self.backgroundColor = self.alveary.canBreed() and colors.green or colors.red
self:clear()
local percDone = 100 - math.floor(queen.health * 100 / queen.maxHealth)
if not queen.canSpawn then
percDone = 0
end
self.progressBar.value = percDone
--self.progressBar:draw()
for _,c in pairs(self.children) do
c:draw()
end
self:centeredWrite(2, queen.displayName)
self:centeredWrite(4, percDone .. '%')
self:write(1, 6, 'Generation: ' .. queen.generation)
self:setCursorPos(1, 7)
if queen.active then
regulate(
queen.active.humidityTolerance,
queen.active.temperatureTolerance)
if queen.active.flowerProvider ~= 'Flowers' then
self:print(queen.active.flowerProvider .. '\n')
end
if queen.active.effect ~= 'None' then
self:print('Effect: ' .. queen.active.effect)
end
else
self:print('(pure)')
end
end
end
return window
end
local pages = {
create(device.items, device.monitor),
--create(device.items_6, device.monitor_22),
--create(device.items_5, device.monitor_21),
}
Event.onInterval(5, function()
for _,v in pairs(pages) do
v:draw()
v:sync()
end
end)
UI:pullEvents()

176
forestry/beeInfo.lua Normal file
View File

@@ -0,0 +1,176 @@
_G.requireInjector(_ENV)
local Event = require('event')
local UI = require('ui')
local Util = require('util')
local chest = peripheral.wrap('bottom')
local data
local monitor = UI.Device({
deviceType = 'monitor',
textScale = .5
})
UI:setDefaultDevice(monitor)
local breedingPage = UI.Page({
titleBar = UI.TitleBar(),
grid = UI.Grid({
columns = {
{ heading = ' ', key = 'chance' },
{ heading = 'Princess', key = 'princess', },
{ heading = 'Drone', key = 'drone' },
{ heading = 'Result', key = 'result', },
},
y = 2, ey = -8,
sortColumn = 'result',
autospace = true
}),
specialConditions = UI.Window({
backgroundColor = colors.red,
y = -7,
height = 2
}),
buttons = UI.Window({
y = monitor.height - 4,
width = monitor.width,
height = 5,
backgroundColor = colors.gray,
prevButton = UI.Button({
event = 'previous',
x = 2,
y = 2,
height = 3,
width = 5,
text = ' < '
}),
resetButton = UI.Button({
event = 'clear',
x = 8,
y = 2,
height = 3,
width = monitor.width - 14,
text = 'Clear'
}),
nextButton = UI.Button({
event = 'next',
x = monitor.width - 5,
y = 2,
height = 3,
width = 5,
text = ' > '
})
})
})
function breedingPage:getBreedingData()
self.grid.values = { }
local stacks = chest.getAllStacks(false)
local stack = stacks[1]
self.titleBar.title = stack.individual.displayName
if stack.individual.active then
end
for _,d in pairs(data) do
if d.allele1 == stack.individual.displayName or
d.allele2 == stack.individual.displayName then
local ind = ''
if d.specialConditions then
ind = '*'
end
table.insert(self.grid.values, {
princess = d.allele1 .. ind,
drone = d.allele2,
result = d.result,
chance = d.chance .. '%',
specialConditions = d.specialConditions
})
end
end
self.grid.index = 1
self.grid:adjustWidth()
self.grid:update()
self:draw()
self:sync()
end
function breedingPage.specialConditions:draw()
local selected = self.parent.grid:getSelected()
if selected and selected.specialConditions then
local sc = ''
if selected.specialConditions then
for _,v in ipairs(selected.specialConditions) do
if sc ~= '' then
sc = sc .. ', '
end
sc = sc .. v
end
end
self:clear()
self:setCursorPos(2, 1)
self:print(sc)
else
self:clear(colors.red)
end
end
function breedingPage.grid:draw()
UI.Grid.draw(self)
self.parent.specialConditions:draw()
end
function breedingPage:eventHandler(event)
if event.type == 'next' then
self.grid:setPage(self.grid:getPage() + 1)
elseif event.type == 'previous' then
self.grid:setPage(self.grid:getPage() - 1)
elseif event.type == 'clear' then
self.grid:setTable({})
self.grid:draw()
elseif event.type == 'grid_focus_row' then
self.specialConditions:draw()
else
return UI.Page.eventHandler(self, event)
end
return false
end
Event.on('turtle_inventory', function()
local slot = turtle.selectSlotWithQuantity(1)
if slot then
turtle.dropDown()
breedingPage:getBreedingData()
turtle.suckDown()
turtle.drop()
end
end)
if not fs.exists('.bee.data') then
local p = peripheral.wrap("back")
local data = p.getBeeBreedingData()
local t = { }
for _,d in pairs(data) do
d = Util.shallowCopy(d)
if type(d.specialConditions) == 'string' then
if d.specialConditions == '[]' then
d.specialConditions = ''
end
end
if #d.specialConditions == 0 then
d.specialConditions = nil
else
d.specialConditions = Util.shallowCopy(d.specialConditions)
end
table.insert(t, d)
end
Util.writeTable('.bee.data', t)
else
data = Util.readTable('.bee.data')
end
UI:setPage(breedingPage)
UI:pullEvents()

34
forestry/filing.lua Normal file
View File

@@ -0,0 +1,34 @@
_G.requireInjector(_ENV)
local Event = require('event')
local Util = require('util')
local chest = peripheral.wrap('top')
function getOpenChestSlot(stacks)
for i = 1, chest.getInventorySize() do
if not stacks[i] then
return i
end
end
end
Event.on('turtle_inventory', function()
for i = 1, 16 do
if turtle.getItemCount(i) > 0 then
chest.pullItem('down', i, 1)
os.sleep(.5)
local stacks = chest.getAllStacks(false)
local _,slot = Util.find(stacks, 'qty', 2)
if slot then
print('Duplicate')
chest.pushItem('north', slot, 1)
else
print('New Serum')
end
end
end
end)
Event.pullEvents()

34
forestry/serums.lua Normal file
View File

@@ -0,0 +1,34 @@
_G.requireInjector(_ENV)
local Event = require('event')
local Util = require('util')
local chest = peripheral.wrap('top')
function getOpenChestSlot(stacks)
for i = 1, chest.getInventorySize() do
if not stacks[i] then
return i
end
end
end
Event.on('turtle_inventory', function()
for i = 1, 16 do
if turtle.getItemCount(i) > 0 then
local stacks = chest.getAllStacks(false)
local slot = getOpenChestSlot(stacks)
chest.pullItemIntoSlot('down', i, 1, slot)
local serum = chest.getStackInSlot(slot)
if Util.find(stacks, 'nbt_hash', serum.nbt_hash) then
print('Duplicate')
chest.pushItem('north', slot, 1)
else
print('New Serum')
end
end
end
end)
Event.pullEvents()