This commit is contained in:
Soph :3 2025-07-09 12:58:47 +00:00
parent 89a15d277f
commit f7bb6c8137
5 changed files with 1055 additions and 0 deletions

66
autofeed.lua Normal file
View file

@ -0,0 +1,66 @@
-- AutoFeed module for Minit
-- Copyright (C) 2023 AlexDevs
-- This software is licensed under the MIT license.
local module = {
name = "autofeed",
}
local saturation = 7
local foods = {
"golden_carrot",
"popcorn",
"cooked_beef",
"cooked_pork",
"cooked_chicken",
"baked_potato",
"cooked_cod",
"cooked_salmon",
"bread",
"melon_slice",
"cooked_rabbit",
"cooked_mutton",
}
local neural
local function has(arr, val)
for k, v in ipairs(arr) do
if val:find(v) then
return true
end
end
return false
end
local function findSlot(inventory)
local list = inventory.list()
for k, v in pairs(list) do
if has(foods, v.name) then
return k
end
end
return -1
end
local function feed()
local inventory = neural.getInventory()
local foodSlot = findSlot(inventory)
if foodSlot == -1 then
return
end
inventory.consume(foodSlot)
end
function module.setup(ni)
neural = ni
end
function module.update(meta)
if meta.food.hungry or meta.food.saturation < saturation then
feed()
end
end
return module