From e07298a9c42d93cbc9fc964504081d95b135c50c Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Mon, 7 Jan 2019 13:56:51 -0500 Subject: [PATCH] tweaks + simplify rancher (no xp collection) --- farms/rancher.lua | 57 ++++---------------------------------- farms/superTreefarm.lua | 2 +- milo/plugins/craftTask.lua | 6 ++-- 3 files changed, 8 insertions(+), 57 deletions(-) diff --git a/farms/rancher.lua b/farms/rancher.lua index dfe5603..12ce325 100644 --- a/farms/rancher.lua +++ b/farms/rancher.lua @@ -1,5 +1,3 @@ -_G.requireInjector(_ENV) - local Adapter = require('chestAdapter18') local Config = require('config') local Peripheral = require('peripheral') @@ -52,22 +50,12 @@ local function equip(side, item, rawName) turtle.select(1) end -local function getLocalName() - if not device.wired_modem then - error('wired modem or chest not found') - end - return device.wired_modem.getNameLocal() -end - equip('left', 'minecraft:diamond_sword') equip('right', 'plethora:sensor', 'plethora:module:3') local sensor = device['plethora:sensor'] -local c = Peripheral.lookup('type/minecraft:chest') or error('Missing chest') -local directions = { top = 'down', bottom = 'up' } -local direction = directions[c.side] or getLocalName() -local chest = Adapter({ side = c.side, direction = direction }) or error('missing chest') +local chest = Adapter({ side = 'bottom', direction = 'up' }) or error('missing chest') if not fs.exists(STARTUP_FILE) then Util.writeFile(STARTUP_FILE, @@ -76,53 +64,23 @@ shell.openForegroundTab('rancher.lua')]]) print('Autorun program created: ' .. STARTUP_FILE) end -local dispenser = Peripheral.lookup('type/minecraft:dispenser') -local integrator = Peripheral.lookup('type/redstone_integrator') - -local function pulse() - integrator.setOutput('north', true) - os.sleep(.25) - integrator.setOutput('north', false) -end - -local function turnOffWater() - if dispenser then - local list = dispenser.list() - if list[1].name == 'minecraft:bucket' then - pulse() - os.sleep(2) - end - end -end - -local function turnOnWater() - if dispenser then - if dispenser.list()[1].name == 'minecraft:water_bucket' then - pulse() - end - end -end - local function getAnimalCount() local blocks = sensor.sense() local grown = 0 local babies = 0 - local xpCount = 0 Util.filterInplace(blocks, function(v) if v.name == config.animal then if v.y > -.5 then grown = grown + 1 end if v.y < -.5 then babies = babies + 1 end return v.y > -.5 - elseif v.name == 'XPOrb' then - xpCount = xpCount + 1 end end) - Util.print('%d grown, %d babies, %d xp', grown, babies, xpCount) + Util.print('%d grown, %d babies', grown, babies) - return #blocks, xpCount + return #blocks end local function butcher() @@ -160,10 +118,10 @@ local function breed() end local s, m = turtle.run(function() - turnOffWater() + print('Configured animal: ' .. config.animal) repeat - local animalCount, xpCount = getAnimalCount() + local animalCount = getAnimalCount() if animalCount > config.max_animals then turtle.setStatus('Butchering') butcher() @@ -176,11 +134,6 @@ local s, m = turtle.run(function() turtle.setStatus('Breeding') breed() end - if xpCount > 2 then - turnOnWater() - os.sleep(8) - turnOffWater() - end os.sleep(5) until turtle.isAborted() end) diff --git a/farms/superTreefarm.lua b/farms/superTreefarm.lua index c2a8da7..5c8ea3e 100644 --- a/farms/superTreefarm.lua +++ b/farms/superTreefarm.lua @@ -476,7 +476,7 @@ local function findDroppedSaplings() local sensed = Util.reduce(raw, function(acc, b) Point.rotate(b, state.home.heading) b.x = Util.round(b.x) + turtle.point.x - b.y = math.floor(b.y) + turtle.point.y + b.y = math.ceil(b.y) + turtle.point.y b.z = Util.round(b.z) + turtle.point.z if b.y == 0 and string.find(b.displayName, 'sapling', 1, true) then b.sapling = true diff --git a/milo/plugins/craftTask.lua b/milo/plugins/craftTask.lua index 89e0d6d..e6a96bb 100644 --- a/milo/plugins/craftTask.lua +++ b/milo/plugins/craftTask.lua @@ -57,17 +57,15 @@ end end function craftTask:cycle() - local playSound = true - for _,key in pairs(Util.keys(context.craftingQueue)) do local item = context.craftingQueue[key] if item.requested - item.crafted > 0 then local recipe = Craft.findRecipe(key) if recipe then - if playSound then + if not item.playedSound then Sound.play('entity.experience_orb.pickup') - playSound = false + item.playedSound = true end self:craft(recipe, item)