spaces->tab, equipper improvements, supertreefarm rewrite, follow improvements, sensor cleanup, milo multiple items allowed in recipes, remote canvas access

This commit is contained in:
kepler155c@gmail.com
2019-06-18 15:23:20 -04:00
parent 3b9b509429
commit 045b32884f
162 changed files with 20448 additions and 20286 deletions

View File

@@ -1,6 +1,6 @@
--[[
Breed either cows or sheep.
Must be run on a mob with the same height.
Breed either cows or sheep.
Must be run on a mob with the same height.
]]
local neural = require('neural.interface')
@@ -14,107 +14,107 @@ local WALK_SPEED = 1.5
local MAX_GROWN = 12
neural.assertModules({
'plethora:sensor',
'plethora:scanner',
'plethora:laser',
'plethora:kinetic',
'plethora:introspection',
'plethora:sensor',
'plethora:scanner',
'plethora:laser',
'plethora:kinetic',
'plethora:introspection',
})
local fed = { }
local function resupply()
local slot = neural.getEquipment().list()[1]
if slot and slot.count > 32 then
return
end
print('resupplying')
for _ = 1, 2 do
local dispenser = Map.find(neural.scan(), 'name', 'minecraft:dispenser')
if not dispenser then
print('dispenser not found')
break
end
if math.abs(dispenser.x) <= 1 and math.abs(dispenser.z) <= 1 then
neural.lookAt(dispenser)
for _ = 1, 8 do
neural.use(0, 'off')
os.sleep(.2)
neural.getEquipment().suck(1, 64)
end
break
else
neural.walkTo({ x = dispenser.x, y = 0, z = dispenser.z }, WALK_SPEED)
end
end
local slot = neural.getEquipment().list()[1]
if slot and slot.count > 32 then
return
end
print('resupplying')
for _ = 1, 2 do
local dispenser = Map.find(neural.scan(), 'name', 'minecraft:dispenser')
if not dispenser then
print('dispenser not found')
break
end
if math.abs(dispenser.x) <= 1 and math.abs(dispenser.z) <= 1 then
neural.lookAt(dispenser)
for _ = 1, 8 do
neural.use(0, 'off')
os.sleep(.2)
neural.getEquipment().suck(1, 64)
end
break
else
neural.walkTo({ x = dispenser.x, y = 0, z = dispenser.z }, WALK_SPEED)
end
end
end
local function breed(entity)
print('breeding')
entity.lastFed = os.clock()
fed[entity.id] = entity
print('breeding')
entity.lastFed = os.clock()
fed[entity.id] = entity
neural.walkTo(entity, WALK_SPEED, 1)
entity = neural.getMetaByID(entity.id)
if entity then
neural.lookAt(entity)
neural.use(1)
os.sleep(.1)
end
neural.walkTo(entity, WALK_SPEED, 1)
entity = neural.getMetaByID(entity.id)
if entity then
neural.lookAt(entity)
neural.use(1)
os.sleep(.1)
end
end
local function kill(entity)
print('killing')
neural.walkTo(entity, WALK_SPEED, 2.5)
entity = neural.getMetaByID(entity.id)
if entity then
neural.lookAt(entity)
neural.fireAt({ x = entity.x, y = 0, z = entity.z })
Sound.play('entity.firework.launch')
os.sleep(.2)
end
print('killing')
neural.walkTo(entity, WALK_SPEED, 2.5)
entity = neural.getMetaByID(entity.id)
if entity then
neural.lookAt(entity)
neural.fireAt({ x = entity.x, y = 0, z = entity.z })
Sound.play('entity.firework.launch')
os.sleep(.2)
end
end
local function getEntities()
return Map.filter(neural.sense(), function(entity)
if entity.name == BREEDING and entity.y > -.5 then
return true
end
end)
return Map.filter(neural.sense(), function(entity)
if entity.name == BREEDING and entity.y > -.5 then
return true
end
end)
end
local function getHungry(entities)
for _,v in pairs(entities) do
if not fed[v.id] or os.clock() - fed[v.id].lastFed > 60 then
return v
end
end
for _,v in pairs(entities) do
if not fed[v.id] or os.clock() - fed[v.id].lastFed > 60 then
return v
end
end
end
local function randomEntity(entities)
local r = math.random(1, Map.size(entities))
local i = 1
for _, v in pairs(entities) do
i = i + 1
if i > r then
return v
end
end
local r = math.random(1, Map.size(entities))
local i = 1
for _, v in pairs(entities) do
i = i + 1
if i > r then
return v
end
end
end
while true do
resupply()
resupply()
local entities = getEntities()
local entities = getEntities()
if Map.size(entities) > MAX_GROWN then
kill(randomEntity(entities))
else
local entity = getHungry(entities)
if entity then
breed(entity)
else
os.sleep(5)
end
end
if Map.size(entities) > MAX_GROWN then
kill(randomEntity(entities))
else
local entity = getHungry(entities)
if entity then
breed(entity)
else
os.sleep(5)
end
end
end