farm chorus fruit
This commit is contained in:
@@ -9,7 +9,8 @@ local os = _G.os
|
|||||||
local peripheral = _G.peripheral
|
local peripheral = _G.peripheral
|
||||||
local turtle = _G.turtle
|
local turtle = _G.turtle
|
||||||
|
|
||||||
local CONFIG_FILE = 'usr/config/farm'
|
local CONFIG_FILE = 'usr/config/farmer'
|
||||||
|
local STARTUP_FILE = 'usr/autorun/farmer.lua'
|
||||||
|
|
||||||
local scanner = device['plethora:scanner'] or
|
local scanner = device['plethora:scanner'] or
|
||||||
turtle.equip('right', 'plethora:module:2') and device['plethora:scanner'] or
|
turtle.equip('right', 'plethora:module:2') and device['plethora:scanner'] or
|
||||||
@@ -27,16 +28,25 @@ local crops = Util.readTable(CONFIG_FILE) or {
|
|||||||
['minecraft:cocoa'] =
|
['minecraft:cocoa'] =
|
||||||
{ seed = 'minecraft:dye:3', mature = 8, action = 'pick' },
|
{ seed = 'minecraft:dye:3', mature = 8, action = 'pick' },
|
||||||
['minecraft:reeds'] = { action = 'bash' },
|
['minecraft:reeds'] = { action = 'bash' },
|
||||||
|
['minecraft:chorus_flower'] = { action = 'bash' },
|
||||||
|
['minecraft:chorus_plant'] =
|
||||||
|
{ seed = 'minecraft:chorus_flower', mature = 0, action = 'bash-smash', },
|
||||||
['minecraft:melon_block'] = { action = 'smash' },
|
['minecraft:melon_block'] = { action = 'smash' },
|
||||||
['minecraft:pumpkin'] = { action = 'smash' },
|
['minecraft:pumpkin'] = { action = 'smash' },
|
||||||
['minecraft:chest'] = { action = 'drop' },
|
['minecraft:chest'] = { action = 'drop' },
|
||||||
['minecraft:cactus'] = { action = 'bump' },
|
['minecraft:cactus'] = { action = 'smash' },
|
||||||
}
|
}
|
||||||
|
|
||||||
if not fs.exists(CONFIG_FILE) then
|
if not fs.exists(CONFIG_FILE) then
|
||||||
Util.writeTable(CONFIG_FILE, crops)
|
Util.writeTable(CONFIG_FILE, crops)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not fs.exists(STARTUP_FILE) then
|
||||||
|
Util.writeFile(STARTUP_FILE,
|
||||||
|
[[os.sleep(1)
|
||||||
|
shell.openForegroundTab('packages/farms/farmer.lua')]])
|
||||||
|
end
|
||||||
|
|
||||||
local retain = Util.transpose {
|
local retain = Util.transpose {
|
||||||
"minecraft:diamond_pickaxe",
|
"minecraft:diamond_pickaxe",
|
||||||
"plethora:module:2",
|
"plethora:module:2",
|
||||||
@@ -70,6 +80,16 @@ local function scan()
|
|||||||
if b.action == 'drop' then
|
if b.action == 'drop' then
|
||||||
return doDropOff and b.y == -1
|
return doDropOff and b.y == -1
|
||||||
end
|
end
|
||||||
|
if b.action == 'bash-smash' then
|
||||||
|
if b.y == -1 then
|
||||||
|
b.action = 'smash'
|
||||||
|
end
|
||||||
|
if b.y == 0 then
|
||||||
|
b.action = 'bash'
|
||||||
|
end
|
||||||
|
return b.action ~= 'bash-smash'
|
||||||
|
end
|
||||||
|
|
||||||
if b.action == 'smash' then
|
if b.action == 'smash' then
|
||||||
return b.y == -1
|
return b.y == -1
|
||||||
end
|
end
|
||||||
@@ -128,7 +148,12 @@ local function harvest(blocks)
|
|||||||
end
|
end
|
||||||
|
|
||||||
elseif b.action == 'smash' then
|
elseif b.action == 'smash' then
|
||||||
turtle.digDownAt(b)
|
if turtle.digDownAt(b) then
|
||||||
|
if crops[b.name].seed then
|
||||||
|
turtle.placeDown(crops[b.name].seed)
|
||||||
|
turtle.select(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
elseif b.action == 'plant' then
|
elseif b.action == 'plant' then
|
||||||
if turtle.digDownAt(b) then
|
if turtle.digDownAt(b) then
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
local Craft = require('craft2')
|
local Craft = require('craft2')
|
||||||
local itemDB = require('itemDB')
|
|
||||||
local Event = require('event')
|
local Event = require('event')
|
||||||
local Milo = require('milo')
|
local Milo = require('milo')
|
||||||
local Sound = require('sound')
|
local Sound = require('sound')
|
||||||
@@ -14,35 +13,12 @@ local string = _G.string
|
|||||||
local displayModes = {
|
local displayModes = {
|
||||||
[0] = { text = 'A', help = 'Showing all items' },
|
[0] = { text = 'A', help = 'Showing all items' },
|
||||||
[1] = { text = 'I', help = 'Showing inventory items' },
|
[1] = { text = 'I', help = 'Showing inventory items' },
|
||||||
[2] = { text = 'C', help = 'Showing craftable items' },
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local function filterItems(t, filter)
|
|
||||||
if filter or displayMode > 0 then
|
|
||||||
local r = { }
|
|
||||||
if filter then
|
|
||||||
filter = filter:lower()
|
|
||||||
end
|
|
||||||
for _,v in pairs(t) do
|
|
||||||
if not filter or string.find(v.lname, filter, 1, true) then
|
|
||||||
if not displayMode or
|
|
||||||
displayMode == 0 or
|
|
||||||
displayMode == 1 and v.count > 0 or
|
|
||||||
displayMode == 2 and v.has_recipe then
|
|
||||||
table.insert(r, v)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return r
|
|
||||||
end
|
|
||||||
return t
|
|
||||||
end
|
|
||||||
|
|
||||||
local listingPage = UI.Page {
|
local listingPage = UI.Page {
|
||||||
menuBar = UI.MenuBar {
|
menuBar = UI.MenuBar {
|
||||||
buttons = {
|
buttons = {
|
||||||
{ text = 'Learn', event = 'learn' },
|
{ text = 'Learn', event = 'learn' },
|
||||||
--{ text = 'Forget', event = 'forget' },
|
|
||||||
{ text = 'Craft', event = 'craft' },
|
{ text = 'Craft', event = 'craft' },
|
||||||
{ text = 'Edit', event = 'details' },
|
{ text = 'Edit', event = 'details' },
|
||||||
{ text = 'Refresh', event = 'refresh', x = -12 },
|
{ text = 'Refresh', event = 'refresh', x = -12 },
|
||||||
@@ -222,7 +198,7 @@ function listingPage:eventHandler(event)
|
|||||||
self:setFocus(self.statusBar.filter)
|
self:setFocus(self.statusBar.filter)
|
||||||
|
|
||||||
elseif event.type == 'toggle_display' then
|
elseif event.type == 'toggle_display' then
|
||||||
displayMode = (displayMode + 1) % 3
|
displayMode = (displayMode + 1) % 2
|
||||||
Util.merge(event.button, displayModes[displayMode])
|
Util.merge(event.button, displayModes[displayMode])
|
||||||
event.button:draw()
|
event.button:draw()
|
||||||
self:applyFilter()
|
self:applyFilter()
|
||||||
@@ -308,6 +284,25 @@ function listingPage:refresh(force)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function listingPage:applyFilter()
|
function listingPage:applyFilter()
|
||||||
|
local function filterItems(t, filter)
|
||||||
|
if filter or displayMode > 0 then
|
||||||
|
local r = { }
|
||||||
|
if filter then
|
||||||
|
filter = filter:lower()
|
||||||
|
end
|
||||||
|
for _,v in pairs(t) do
|
||||||
|
if not filter or string.find(v.lname, filter, 1, true) then
|
||||||
|
if displayMode == 0 or
|
||||||
|
displayMode == 1 and v.count > 0 then
|
||||||
|
table.insert(r, v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return r
|
||||||
|
end
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
local t = filterItems(self.allItems, self.filter)
|
local t = filterItems(self.allItems, self.filter)
|
||||||
self.grid:setValues(t)
|
self.grid:setValues(t)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user