• Hail, we're RedGuides. We want you to play six (yes, 6!) EverQuest characters at once. We have scripts and a friendly community to help, please join our playstyle and say hello! 👋
  • We've added LLM sections to our Terms & Rules and Resource Rules, for everyone's sanity & in-game safety.
    Read more
    a. Do not replace your voice with an LLM. This goes for your posts and your scripts. Drafting and editing with a tool is fine, but don't take you out of what you share.
    b. Do not replace your EQ character's voice with an LLM. We don't want scripts that speak over /ooc, /shout or other public channels. This has been an unwritten rule that's kept casino scripts off the site for decades, but we're now compelled to make it clear: keep automated communication private.

    Why Does RG Review Scripts?
    Nearly every LLM-written Lua script we see is making your character do impossible things, and rarely in a way that's beneficial to you. We've seen heavy server hammering, /target over impossible distances when /nav spawn would passively accomplish the same thing, a spawn search that fires 20+ times per second, and other pointless actions that are likely annoying GMs.

    You are welcome to use LLMs as a tool to structure, draft, and edit your work, but please read critically before hitting /lua run

milk_cookie_manager.lua

My first attempt at a Lua script so be gentle. So far it has behaved as expected for me. Maintains 5 cookies/milk in your inventory at all times unless you are invisible.

milk_cookies_manager.lua
Lua:
-- cookie_milk_manager.lua version 1.4 (uses FindItemCount)
-- Maintains 5 Fresh Cookies and 5 Warm Milk in inventory
-- Summons only when needed
-- Auto-inventories summoned items
-- Does not summon while invisible

local mq = require("mq")

local COOKIE_ITEM_NAME = "Fresh Cookie"
local MILK_ITEM_NAME = "Warm Milk"
local COOKIE_CLICKY = "Fresh Cookie Dispenser"
local MILK_CLICKY = "Warm Milk Dispenser"
local TARGET_COOKIE_COUNT = 5
local TARGET_MILK_COUNT = 5

---@return number
local function getItemCount(itemName)
    local count = mq.TLO.FindItemCount(string.format("=%s", itemName))() or 0
    -- mq.cmdf("/echo Counted %d of %s", count, itemName)
    return count
end

---@param itemName string
local function useClicky(itemName)
    local item = mq.TLO.FindItem(itemName)
    if item() and item.Clicky.Spell() and item.TimerReady() then
        mq.cmdf("/useitem \"%s\"", itemName)
        mq.delay(1500)
        moveItemFromCursor()
    end
end

function moveItemFromCursor()
    local cursorItem = mq.TLO.Cursor
    if cursorItem() then
        if cursorItem.Name() == COOKIE_ITEM_NAME or cursorItem.Name() == MILK_ITEM_NAME then
            mq.cmd("/autoinventory")
            mq.delay(300)
        end
    end
end

local function maintainFoodAndDrink()
    while true do
        -- Skip checks while invisible
        if not mq.TLO.Me.Invis() then
            local cookieCount = getItemCount(COOKIE_ITEM_NAME)
            local milkCount = getItemCount(MILK_ITEM_NAME)

            if cookieCount < TARGET_COOKIE_COUNT then
                useClicky(COOKIE_CLICKY)
            end

            if milkCount < TARGET_MILK_COUNT then
                useClicky(MILK_CLICKY)
            end
        end

        mq.delay(2000) -- Check every 2 seconds
    end
end

maintainFoodAndDrink()
 
Last edited:
I have found a small caveat with this script. If there is an empty main inventory slot rather than all full with bags or something, it will autoinventory the milk/cookie into that slot and not be found/counted towards the required 5 in inventory. It only counts if they are inside a bag.

Updated the script to use FindItemCount which correctly identifies the item regardless if it is in a main inventory slot or inside of a bag. Tested to make sure it works in all situations now.
 
Last edited:
milk_cookie_manager.lua

Users who are viewing this thread

Back
Top
Cart