This script will it eat food directly from ground/floor. It will search for one of the listed foods on the sqms around your character.
local FOODS = { 3578, 3582, 3577, 3725 } -- List of food ids.
local EAT_TIME = { Min = 300, Max = 480, } -- In SECONDS. Time to wait after eating food to eat again.
local EAT_TRIES = { Min = 3, Max = 8, } -- How tries to eat
local STOP_FULL = true -- Stop if you are full msg appears.
NEXT_EAT_TIME = NEXT_EAT_TIME or 1
if connected() and runningtime() >= NEXT_EAT_TIME then
local tiles = gettiles()
local player_x = posx()
local player_y = posy()
local player_z = posz()
local food_location = { id = 0, x = 0, y = 0 }
for _, tile in ipairs(tiles) do
if math.abs(tile.posx - player_x) <= 1 and math.abs(tile.posy - player_y) <= 1 and tile.posz == player_z and tile.itemcount > 1 then
for __, item in ipairs(tile.items) do
if table.find(FOODS, item.id) ~= nil then
food_location.id = item.id
food_location.x = tile.posx
food_location.y = tile.posy
break
end
end
end
if food_location.x > 0 then
break
end
end
if food_location.x > 0 then
for i = 1, random(EAT_TRIES.Min, EAT_TRIES.Max) do
useitem(food_location.id, ground(food_location.x, food_location.y, player_z))
wait(400, 800)
if STOP_FULL and statusmessage() == 'You are full.' then
break
end
end
NEXT_EAT_TIME = runningtime() + random(EAT_TIME.Min, EAT_TIME.Max)
end
end