From 074e0742d5f9b24f056ae23e8b2d356933daea27 Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Wed, 1 May 2019 00:17:37 -0400 Subject: [PATCH] neural cleanup --- neural/apis/interface.lua | 1 - {ignore => neural}/mobPickup.lua | 30 +++++++++++++++++++----------- neural/mobRancher.lua | 12 +++++++++--- 3 files changed, 28 insertions(+), 15 deletions(-) rename {ignore => neural}/mobPickup.lua (68%) diff --git a/neural/apis/interface.lua b/neural/apis/interface.lua index b295bd7..e049404 100644 --- a/neural/apis/interface.lua +++ b/neural/apis/interface.lua @@ -1,5 +1,4 @@ local Angle = require('neural.angle') -local Util = require('util') local os = _G.os local peripheral = _G.peripheral diff --git a/ignore/mobPickup.lua b/neural/mobPickup.lua similarity index 68% rename from ignore/mobPickup.lua rename to neural/mobPickup.lua index 9be0ace..7af0f37 100644 --- a/ignore/mobPickup.lua +++ b/neural/mobPickup.lua @@ -1,40 +1,48 @@ +--[[ + Pickup items from a flat area and drop into a hopper. + Must be a 1 high mob +]] + local neural = require('neural.interface') local Point = require('point') local Sound = require('sound') local Util = require('util') -local device = _G.device -local os = _G.os +local os = _G.os -local scanner = device['plethora:scanner'] -local sensor = device['plethora:sensor'] +neural.assertModules({ + 'plethora:sensor', + 'plethora:scanner', + 'plethora:kinetic', + 'plethora:introspection', +}) local function dropOff() print('dropping') - local blocks = scanner.scan() + local blocks = neural.scan() local b = Util.find(blocks, 'name', 'minecraft:hopper') if b then neural.walkTo({ x = b.x, y = 0, z = b.z }) - blocks = scanner.scan() + blocks = neural.scan() b = Util.find(blocks, 'name', 'minecraft:hopper') if b and math.abs(b.x) < 1 and math.abs(b.z) < 1 then print('dropped') - sensor.getEquipment().drop(1) - sensor.getEquipment().drop(2) + neural.getEquipment().drop(1) + neural.getEquipment().drop(2) os.sleep(1) end end end local function pickup(id) - local b = sensor.getMetaByID(id) + local b = neural.getMetaByID(id) if b then neural.walkTo(b) - local amount = sensor.getEquipment().suck() + local amount = neural.getEquipment().suck() print('sucked: ' .. amount) if amount > 0 then Sound.play('entity.item.pickup') @@ -44,7 +52,7 @@ local function pickup(id) end while true do - local sensed = Util.reduce(sensor.sense(), function(acc, s) + local sensed = Util.reduce(neural.sense(), function(acc, s) s.y = Util.round(s.y) if s.y == 0 and s.name == 'Item' then acc[s.id] = s diff --git a/neural/mobRancher.lua b/neural/mobRancher.lua index f932e9d..ee990af 100644 --- a/neural/mobRancher.lua +++ b/neural/mobRancher.lua @@ -1,11 +1,17 @@ +--[[ + Breed either cows or sheep. + Must be run on a mob with the same height. +]] + local neural = require('neural.interface') local Sound = require('sound') local Util = require('util') local os = _G.os +local BREEDING = 'Cow' local WALK_SPEED = 1.5 -local MAX_COWS = 12 +local MAX_GROWN = 12 neural.assertModules({ 'plethora:sensor', @@ -71,7 +77,7 @@ end local function getEntities() return Util.filter(neural.sense(), function(entity) - if entity.name == 'Cow' and entity.y > -.5 then + if entity.name == BREEDING and entity.y > -.5 then return true end end) @@ -101,7 +107,7 @@ while true do local entities = getEntities() - if Util.size(entities) > MAX_COWS then + if Util.size(entities) > MAX_GROWN then kill(randomEntity(entities)) else local entity = getHungry(entities)