neural cleanup
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
local Angle = require('neural.angle')
|
||||
local Util = require('util')
|
||||
|
||||
local os = _G.os
|
||||
local peripheral = _G.peripheral
|
||||
|
||||
@@ -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
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user