milo: unassign machine

This commit is contained in:
kepler155c@gmail.com
2019-05-07 07:14:30 -04:00
parent e61940a7aa
commit 8ea2598254
2 changed files with 13 additions and 7 deletions

View File

@@ -10,8 +10,9 @@ local Util = require('util')
local os = _G.os
local BREEDING = 'Rabbit'
local WALK_SPEED = 2
local MAX_GROWN = 18
local WALK_SPEED = 1.3
local MAX_GROWN = 100
local BREED_DELAY = 120
neural.assertModules({
'plethora:sensor',
@@ -46,7 +47,7 @@ local function breed(entity)
entity.lastFed = os.clock()
fed[entity.id] = entity
neural.walkTo(entity, WALK_SPEED, 1)
neural.walkTo(entity, WALK_SPEED, .5)
entity = neural.getMetaByID(entity.id)
if entity and not entity.isChild then
neural.lookAt(entity)
@@ -57,7 +58,7 @@ end
local function kill(entity)
print('killing')
neural.walkTo(entity, WALK_SPEED, 2.5)
neural.walkTo(entity, WALK_SPEED, 2)
entity = neural.getMetaByID(entity.id)
if entity and not entity.isChild then
neural.lookAt(entity)
@@ -77,7 +78,8 @@ end
local function getHungry(entities)
for _,v in pairs(entities) do
if not fed[v.id] or os.clock() - fed[v.id].lastFed > 90 then
if not fed[v.id] or
os.clock() - fed[v.id].lastFed > BREED_DELAY then
return v
end
end

View File

@@ -51,11 +51,15 @@ end
function machinesTab:eventHandler(event)
if event.type == 'grid_select' then
Craft.machineLookup[self.item.key] = event.selected.name
if event.selected.name == Craft.machineLookup[self.item.key] then
Craft.machineLookup[self.item.key] = nil
else
Craft.machineLookup[self.item.key] = event.selected.name
end
Util.writeTable(Craft.MACHINE_LOOKUP, Craft.machineLookup)
self.grid:draw()
self:emit({ type = 'info_message', message = 'Machine saved' })
self:emit({ type = 'info_message', message = 'Saved' })
return true
end