neural cleanup
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
local Angle = require('neural.angle')
|
local Angle = require('neural.angle')
|
||||||
local Util = require('util')
|
|
||||||
|
|
||||||
local os = _G.os
|
local os = _G.os
|
||||||
local peripheral = _G.peripheral
|
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 neural = require('neural.interface')
|
||||||
local Point = require('point')
|
local Point = require('point')
|
||||||
local Sound = require('sound')
|
local Sound = require('sound')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
local device = _G.device
|
local os = _G.os
|
||||||
local os = _G.os
|
|
||||||
|
|
||||||
local scanner = device['plethora:scanner']
|
neural.assertModules({
|
||||||
local sensor = device['plethora:sensor']
|
'plethora:sensor',
|
||||||
|
'plethora:scanner',
|
||||||
|
'plethora:kinetic',
|
||||||
|
'plethora:introspection',
|
||||||
|
})
|
||||||
|
|
||||||
local function dropOff()
|
local function dropOff()
|
||||||
print('dropping')
|
print('dropping')
|
||||||
|
|
||||||
local blocks = scanner.scan()
|
local blocks = neural.scan()
|
||||||
local b = Util.find(blocks, 'name', 'minecraft:hopper')
|
local b = Util.find(blocks, 'name', 'minecraft:hopper')
|
||||||
|
|
||||||
if b then
|
if b then
|
||||||
neural.walkTo({ x = b.x, y = 0, z = b.z })
|
neural.walkTo({ x = b.x, y = 0, z = b.z })
|
||||||
|
|
||||||
blocks = scanner.scan()
|
blocks = neural.scan()
|
||||||
b = Util.find(blocks, 'name', 'minecraft:hopper')
|
b = Util.find(blocks, 'name', 'minecraft:hopper')
|
||||||
if b and math.abs(b.x) < 1 and math.abs(b.z) < 1 then
|
if b and math.abs(b.x) < 1 and math.abs(b.z) < 1 then
|
||||||
print('dropped')
|
print('dropped')
|
||||||
sensor.getEquipment().drop(1)
|
neural.getEquipment().drop(1)
|
||||||
sensor.getEquipment().drop(2)
|
neural.getEquipment().drop(2)
|
||||||
os.sleep(1)
|
os.sleep(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function pickup(id)
|
local function pickup(id)
|
||||||
local b = sensor.getMetaByID(id)
|
local b = neural.getMetaByID(id)
|
||||||
if b then
|
if b then
|
||||||
neural.walkTo(b)
|
neural.walkTo(b)
|
||||||
|
|
||||||
local amount = sensor.getEquipment().suck()
|
local amount = neural.getEquipment().suck()
|
||||||
print('sucked: ' .. amount)
|
print('sucked: ' .. amount)
|
||||||
if amount > 0 then
|
if amount > 0 then
|
||||||
Sound.play('entity.item.pickup')
|
Sound.play('entity.item.pickup')
|
||||||
@@ -44,7 +52,7 @@ local function pickup(id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
while true do
|
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)
|
s.y = Util.round(s.y)
|
||||||
if s.y == 0 and s.name == 'Item' then
|
if s.y == 0 and s.name == 'Item' then
|
||||||
acc[s.id] = s
|
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 neural = require('neural.interface')
|
||||||
local Sound = require('sound')
|
local Sound = require('sound')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
local os = _G.os
|
local os = _G.os
|
||||||
|
|
||||||
|
local BREEDING = 'Cow'
|
||||||
local WALK_SPEED = 1.5
|
local WALK_SPEED = 1.5
|
||||||
local MAX_COWS = 12
|
local MAX_GROWN = 12
|
||||||
|
|
||||||
neural.assertModules({
|
neural.assertModules({
|
||||||
'plethora:sensor',
|
'plethora:sensor',
|
||||||
@@ -71,7 +77,7 @@ end
|
|||||||
|
|
||||||
local function getEntities()
|
local function getEntities()
|
||||||
return Util.filter(neural.sense(), function(entity)
|
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
|
return true
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@@ -101,7 +107,7 @@ while true do
|
|||||||
|
|
||||||
local entities = getEntities()
|
local entities = getEntities()
|
||||||
|
|
||||||
if Util.size(entities) > MAX_COWS then
|
if Util.size(entities) > MAX_GROWN then
|
||||||
kill(randomEntity(entities))
|
kill(randomEntity(entities))
|
||||||
else
|
else
|
||||||
local entity = getHungry(entities)
|
local entity = getHungry(entities)
|
||||||
|
|||||||
Reference in New Issue
Block a user