• You've discovered RedGuides, an EverQuest multi-boxing and scripting community 🧙‍♀️⚙️. We want you to play several EQ characters at once, come join us and say hello! 👋

  • A TLP without truebox has thawed (Very Vanilla ready)
    Frostreaver

Lua - Lua Snips and discussion

table.sort(a) in Lua by itself. sorts the table. duh..

but if I make another table from the originating table and sort the original table, it sorts the new array also.. not cool!..
 
gotta be something wrong with this, how can I call myself..

Code:
local function return_rows(p_id)
    local m = {}
    local counter = 0
    for r in db:nrows(
                 "SELECT * FROM MasterCompTable WHERE ItemID !=0 AND RecipeID =" ..
                     p_id .. " ORDER BY ItemID DESC") do
        if not ((string.find(r.ItemName, "Tool") or
            string.find(r.ItemName, "Jewel") or
            string.find(r.ItemName, "Cake Round") or
            string.find(r.ItemName, "File") or
            string.find(r.ItemName, "Dairy Spoon"))) then
            print("\ag", r.ItemName)
            local a
               if r.ItemID > 0 then
                a = return_row_count(r.ItemID)
                if a > 0 then return_rows(r.ItemID) end
            end
        end
    end
end

it's like it runs instances of itself.. that is .. cool
 
Last edited:
because no one asked.. the deepest layered recipe so far is Desiccated Velium and Platinum which has 8 layers

1633362357770.png
 
so let's say you call a function that is from a required file from whatever you called it from.. and you are trying to determine an event but it is in a do while

Code:
function library.ClearCursor()
    local flag = 1
    while mq.TLO.Cursor.ID() do
        mq.cmd('/autoinv')
        event()
        if mq.TLO.Me.FreeInventory() == 0 then
            print("\ayALERT: TCN_LIBRARY Inventory Free Slots: ",
                  mq.TLO.Me.FreeInventory())
            flag = 0
            break
        end
        mq.delay(500)
    end
    mq.delay(1)
    return flag
end

but it won't do an event because.. when you say mq.doevents() for the calling script

but if you make this function and have the do while call the function it will capture the event and return or break out to the original caller

Code:
local function event()
    mq.doevents()
    return
end

useful for when you are waiting for something to happen but can't break out because you don't know the status
 
want to make sure this is.. ok. is there a better way?

Code:
local bank_item_slot = mq.TLO.FindItemBank(id).InvSlot()-40
mq.cmd('/notify BigBankWnd BIGB_BankSlot'..bank_item_slot..' leftmouseup')

so this is ok if, you don't use the shared bank and the item is not in a bag :p

I wrote a way better routine
 
Last edited:
How do you tell if an item is in a shared bank slot or bank slot..

ItemSlot and ItemSlot2 return numbers that do not help.. nor does InvSlot..

was trying to find a way to "read" the location from the find window based on the selected item..

I can index it and select it but I can't figure out which bank it is in

Code:
    local bank_index =  mq.TLO.Window('FindItemWnd').Child('FIW_ItemList').List('=' ..
ItemToGrab,
2)()
 
How do you tell if an item is in a shared bank slot or bank slot..

ItemSlot and ItemSlot2 return numbers that do not help.. nor does InvSlot..

was trying to find a way to "read" the location from the find window based on the selected item..

I can index it and select it but I can't figure out which bank it is in

Code:
    local bank_index =  mq.TLO.Window('FindItemWnd').Child('FIW_ItemList').List('=' ..
ItemToGrab,
2)()


I have an ugly way which is to cycle through all the bank and shared bank slots to find the type of bank it is in, but there must be a better way
 
Code:
 local l_item_location = mq.TLO.Window('FindItemWnd').Child('FIW_ItemList')
                                .List(bank_index, 4)()
    -- Is it a shared bank slot
    if string.find(l_item_location, "SharedBank") then
        bank_area = "sharedbank"
    end
 
Last edited:
Code:
local function GrabGuildItemID(p_item, p_qty)
    if not mq.TLO.Window.GuildBankWnd.Open() then
        mq.cmd('/nomodkey /click right target')
        mq.delay(1000)
    end
    local ItemToGrab = p_item
    -- Find item index in guild bank
    local guild_bank_index = mq.TLO.Window('GuildBankWnd').Child(
                                 'GBANK_ItemList').List('=' .. ItemToGrab, 2)()
    -- Display free slots in guild bank
    -- print(mq.TLO.Window('GuildBankWnd').Child('GBANK_ItemScreen').Child('GBANK_ItemButtonScreen').Child('GBANK_BankCountLabel').Text())
    -- split/merge stacks
    if guild_bank_index == 0 or guild_bank_index == nil then return end
    --- Select item
    mq.cmd('/nomodkey /notify GuildBankWnd GBANK_ItemList listselect ',
           guild_bank_index)
    -- Quantity
    print("Quantity: ", mq.TLO.Window('GuildBankWnd').Child('GBANK_ItemList')
              .List(guild_bank_index, 3)())
    -- Click withdrawal
    mq.cmd('/notify GuildBankWnd GBANK_WithdrawButton leftmouseup')
    mq.delay(500)
    mq.cmd('/notify QuantityWnd QTYW_slider newvalue', p_qty)
    mq.delay(500)
    -- Click Accept
    mq.cmd('/nomodkey /notify QuantityWnd QTYW_Accept_Button leftmouseup')
    -- Auto-Inventory
    mq.delay(500)
    mq.cmd('/autoinv')
    return
end

Very little error checking will just grab an item based on quantity from the guild banker..

have the guild banker targeted

Usage: GrabGuildItemID("Tacos",5)


I think this is wrong
haven't tested if not mq.TLO.Window.GuildBankWnd.Open() then

and this is right
or if not mq.TLO.Window('GuildBankWnd').Open() then
but have not tested.. the prior for validity
 
Last edited:
Code:
mq.cmd('/bct blippy //lua run who.lua',(final_missing_array),'')

I am trying to pass any array via bc to a Lua.. it shows up on the other end as a table but I can't get anything out of it..

I have read about some Lua c++ function but wanted to know if it could do it natively..
 
Last edited:
you can't. That command doesn't transfer data, it just sends the text string you give it.

Thank you sir.. I guess the next best thing is to write a csv and then read it in the other Lua.. instead of banging away..
 
random pok forges!

Code:
           local random = math.random(1, 3)
            local forge_nav = {"-94 1430 -105", "-422 552 -121", "-351 759 -94"}
            local nav_string = '/nav loc ' .. forge_nav[random] ..
                                   " | log = off"
            local path_length = mq.TLO.Nav.PathLength('loc ' ..
                                                          forge_nav[random])()
            mq.cmd(nav_string)
            while mq.TLO.Nav.Active() do
                path_length = mq.TLO.Nav
                                  .PathLength('loc ' .. forge_nav[random])()
                if path_length < 9 then
                    mq.cmd('/nav stop')
                    break
                end
                mq.delay(1)
            end
            mq.delay(1)
 
Working that crescent reach elevator...

Code:
local function elevator_action()
    local tick = 0
    local setting = 0
    local cur_z = mq.TLO.Switch.Z()
    while true do
        cur_z = mq.TLO.Switch.Z()
        mq.delay(5)
        tick = mq.TLO.Switch.Z()
        if cur_z > tick then
            print(cur_z, " Going down")
            setting = -89.5
            break
        end
        if tick > cur_z then
            print(cur_z, " Going up")
            setting = 10.5
            break
        end
        if cur_z == 10.5 or cur_z == -89.5 then
            setting = cur_z
            --   print "Not moving"
            break
        end
        mq.delay(1)
    end
    cur_z = mq.TLO.Switch.Z()
    while cur_z ~= setting do cur_z = mq.TLO.Switch.Z() end
    return setting
end
-- Go to floor 1
local function crescent_reach_floor_1()
    -- already there
    if mq.TLO.Me.Z() < -70 then return end
    local cur_z = mq.TLO.Switch.Z()
    mq.cmd('/nav locyx -1313 -1523')
    while mq.TLO.Nav.Active() do mq.delay(1) end
    print "Staged"
    -- check elevator status
    local setting = elevator_action()
    -- print(setting)
    if setting == -89.5 then
        -- print "Bottom Floor"
        mq.cmd('/squelch /doortarget id 11')
        mq.delay(5)
        -- Click switch
        mq.cmd('/squelch /click left door')
        mq.delay(100)
        mq.cmd('/squelch /doortarget id 1')
        cur_z = mq.TLO.Switch.Z()
        -- Wait for it to come down
        while true do
            cur_z = mq.TLO.Switch.Z()
            if cur_z == 10.5 then
                setting = 10.5
                break
            end
        end
    end
    if setting == 10.5 then
        -- Hop on and click
        mq.cmd('/moveto loc -1306 -1540')
        mq.delay(2000)
        mq.cmd('/squelch /doortarget id 11')
        mq.delay(5)
        -- Click switch
        mq.cmd('/squelch /click left door')
        mq.delay(100)
        mq.cmd('/squelch /doortarget id 1')
        while true do
            cur_z = mq.TLO.Switch.Z()
            if cur_z == -89.5 then
                mq.delay(100)
                print("Getting Off This Crazy Thing")
                mq.cmd('/squelch /moveto loc -1305 -1496')
                mq.delay(4000)
                break
            end
        end
    end
end
--- go to floor 2
local function crescent_reach_floor_2()
    if mq.TLO.Me.Z() > 10 then return end
    local cur_z = mq.TLO.Switch.Z()
    mq.cmd('/squelch /doortarget id 1')
    -- print "Stage"
    mq.cmd('/squelch /nav locyx -1313 -1523')
    mq.delay(100)
    while mq.TLO.Nav.Active() do mq.delay(1) end
    -- print "Staged"
    print "Checking Elevator Status"
    local setting = elevator_action()
    if setting == 10.5 then
        -- print "Top Floor"
        mq.cmd('/squelch /doortarget id 11')
        mq.delay(5)
        -- Click switch
        mq.cmd('/squelch /click left door')
        mq.delay(100)
        mq.cmd('/squelch /doortarget id 1')
        cur_z = mq.TLO.Switch.Z()
        -- Wait for it to come down
        while true do
            cur_z = mq.TLO.Switch.Z()
            if cur_z == -89.5 then
                setting = -89.5
                break
            end
        end
    end
    if setting == -89.5 then
        -- Hop on
        mq.cmd('/squelch /nav locyx -1306 -1540')
        mq.delay(2000)
        while true do
            cur_z = mq.TLO.Switch.Z()
            if cur_z == 10.5 then
                mq.delay(100)
                -- Get off
                mq.cmd('/squelch /moveto loc -1305 -1496')
                mq.delay(4000)
                break
            end
        end
    end
end
 
Lua-ized way to check faction

Code:
local l_faction_index = mq.TLO.Window('FactionWnd/FAC_FactionList').Items()
for x = 1, l_faction_index do
    local l_faction_name = mq.TLO.Window('FactionWnd/FAC_FactionList')
                               .List(x, 1)()
    local l_faction_reaction = mq.TLO.Window('FactionWnd/FAC_FactionList').List(
                                   x, 2)()
    local l_faction_search = "Coalition of Tradefolk"
    if l_faction_name == l_faction_search then
        print(l_faction_name, " ", l_faction_reaction)
    end
end
 
Lua-ized way to check faction

Code:
local l_faction_index = mq.TLO.Window('FactionWnd/FAC_FactionList').Items()
for x = 1, l_faction_index do
    local l_faction_name = mq.TLO.Window('FactionWnd/FAC_FactionList')
                               .List(x, 1)()
    local l_faction_reaction = mq.TLO.Window('FactionWnd/FAC_FactionList').List(
                                   x, 2)()
    local l_faction_search = "Coalition of Tradefolk"
    if l_faction_name == l_faction_search then
        print(l_faction_name, " ", l_faction_reaction)
    end
end
Keep in mind you have to open the faction window 1 time for it to populate/update
 
It's has been vertiable ages since I have posted...

I am using imgui to do cool things..

Code:
local function do_cool_things(p_var)
mq.delay(3000000)
return
end

    if ImGui.Button('Start Query Toon Inventory') then
      do_cool_things(1)
    end

What is happening, I click the button and it totally ignores the mq.delay in the called function. I figured since I ran it out of the gui it would behave. I was incorrect..

I also am a bit dense when it comes to how to use mq.TLO.Lua

Has anyone grabbed and used icons from eq in imgui?
 
A function called from within another block of code is still executing within that block.

Is it best to have a separate Lua do the work for a GUI? I wanted to pass variables and arrays to the GUI, should I have the gui itself be required for use? or standalone?
 
Is it best to have a separate lua do the work for a GUI? I wanted to pass variables and arrays to the GUI, should I have the gui itself be required for use? or standalone?

you can pass information through variables but you cannot do any delays inside of imgui. you'd hang the whole game and so that isn't allowed. If you want to do something like that. The idea is that imgui runs in its own little execution thread, and has access to your variables, but it runs separately from the rest of the script. So do all the WORK in the rest of the script, and let the ImGui do the UI and none of the work.
 
this is what I am trying to do..

1634801272871.png

use dannet to query the list from find item (screen) on another toon and then populate an array which is used in imgui, it loads at runtime which is slow.. and I would like it to update when you select another peer. I think I may be exceeding the limitations of capability, but not my imagination.

I am not sure if .received in DanNet can help or not, but the execution is way too fast for queries..

I want to be able to pick a character, pick from their inventory list, and tell them to bring it to me on DanNet.. I have it working for solo items..

I had a lot of ideas, all of them bad..

such as, asking another char to run a Lua that makes an array and then sends them 1 by 1 and I write each item to disk. bad option 2 was concat a giant string and send that which is a ghetto array being sent over DanNet.

option 3.. make a fake "delay" (i.e.) don't allow or update a gui item until the process request has been completed.
 
Last edited:
Code:
local function faction_search(p_faction)
    local l_faction_index = mq.TLO.Window('FactionWnd/FAC_FactionList').Items()
    if l_faction_index == 0 or l_faction_index == nil then
        mq.cmd('/windowstate FactionWnd open')
        mq.delay(500)
        mq.cmd('/windowstate FactionWnd close')
    end
    local l_faction_reaction = nil
    for x = 1, l_faction_index do
        local l_faction_name = mq.TLO.Window('FactionWnd/FAC_FactionList').List(
                                   x, 1)()
      l_faction_reaction = mq.TLO.Window('FactionWnd/FAC_FactionList')
                                       .List(x, 2)()
        -- local l_faction_search = "Coalition of Tradefolk"
        local l_faction_search = p_faction
        if l_faction_name == l_faction_search then
           -- print(l_faction_name, " ", l_faction_reaction)
            break
        end
    end
return l_faction_reaction
end

cleaned up for Sic
 
Code:
   local function script_status(p_script_name)
    local script = p_script_name
    -- print("passed: ", p_script_name)
    if mq.TLO.Lua.Script(string.upper(script)).Status() == "RUNNING" then
        script = string.upper(script)
        return script
    end
    if mq.TLO.Lua.Script(string.lower(script)).Status() == "RUNNING" then
        script = string.lower(script)
        return script
    end
    return nil
end

Usage: local x = script_status("toolbag")

returns case of script if it is running .. useful for when you /Lua run toolbag or /Lua run TOOLBAG and want to know the status of the script..
 
Method to sort and add up counts of like item and populate results into a new table

Output:

1634844441523.png

Code:
local function return_string(str, int)
    local counter = 0
    for word in string.gmatch(str, '([^,]+)') do
        counter = counter + 1
        if counter == int then return word end
    end
end
local function return_number(str, int)
    if int == nil or str == nil then return 0 end
    local counter = 0
    for number in string.gmatch(str, '([^,]+)') do
        counter = counter + 1
        if counter == int then return tonumber(number) end
    end
    --  return 0
end
local temp_unsorted_array = {}
table.insert(temp_unsorted_array, "Taco,1234,4")
table.insert(temp_unsorted_array, "Burrito,2234,33")
table.insert(temp_unsorted_array, "Tostada,3234,27")
table.insert(temp_unsorted_array, "Taco,1234,7")
table.insert(temp_unsorted_array, "Burrito,2234,4")
print("\atUnsorted and counts not added")
for x = 1, #temp_unsorted_array do print(temp_unsorted_array[x]) end
table.sort(temp_unsorted_array)
-- Format for temp_sorted_array ItemName, ItemID, ItemCount
if temp_unsorted_array[1] ~= nil then
    local temp_array = {}
    local temp_item_count = 0
    local add_item_count = 0
    local last_temp_item_id = 0
    local temp_item_id
    local temp_item_name
    for z = 1, #temp_unsorted_array do
        temp_item_id = lib.return_number(temp_unsorted_array[z], 2)
        if last_temp_item_id ~= temp_item_id then
            for x = 1, #temp_unsorted_array do
                if temp_item_id == return_number(temp_unsorted_array[x], 2) then
                    temp_item_name =
                        return_string(temp_unsorted_array[x], 1)
                    --  print("temp id: ", temp_item_id, " last id: ",
                    --       last_temp_item_id)
                    temp_item_count = return_number(temp_unsorted_array[x],
                                                        3)
                    add_item_count = add_item_count + temp_item_count
                end
            end
        end
        last_temp_item_id = temp_item_id
        if add_item_count > 0 then
            local table_string = temp_item_name .. "," .. temp_item_id .. "," ..
                                     add_item_count
            table.insert(temp_array, table_string)
            --  print (add_item_count)
            add_item_count = 0
        end
    end
    print("\atSorted with proper counts")
    for y = 1, #temp_array do print("\ag", temp_array[y]) end
end
 
Method to sort and add up counts of like item and populate results into a new table

Output:

View attachment 34261

Code:
local function return_string(str, int)
    local counter = 0
    for word in string.gmatch(str, '([^,]+)') do
        counter = counter + 1
        if counter == int then return word end
    end
end
local function return_number(str, int)
    if int == nil or str == nil then return 0 end
    local counter = 0
    for number in string.gmatch(str, '([^,]+)') do
        counter = counter + 1
        if counter == int then return tonumber(number) end
    end
    --  return 0
end
local temp_unsorted_array = {}
table.insert(temp_unsorted_array, "Taco,1234,4")
table.insert(temp_unsorted_array, "Burrito,2234,33")
table.insert(temp_unsorted_array, "Tostada,3234,27")
table.insert(temp_unsorted_array, "Taco,1234,7")
table.insert(temp_unsorted_array, "Burrito,2234,4")
print("\atUnsorted and counts not added")
for x = 1, #temp_unsorted_array do print(temp_unsorted_array[x]) end
table.sort(temp_unsorted_array)
-- Format for temp_sorted_array ItemName, ItemID, ItemCount
if temp_unsorted_array[1] ~= nil then
    local temp_array = {}
    local temp_item_count = 0
    local add_item_count = 0
    local last_temp_item_id = 0
    local temp_item_id
    local temp_item_name
    for z = 1, #temp_unsorted_array do
        temp_item_id = lib.return_number(temp_unsorted_array[z], 2)
        if last_temp_item_id ~= temp_item_id then
            for x = 1, #temp_unsorted_array do
                if temp_item_id == return_number(temp_unsorted_array[x], 2) then
                    temp_item_name =
                        return_string(temp_unsorted_array[x], 1)
                    --  print("temp id: ", temp_item_id, " last id: ",
                    --       last_temp_item_id)
                    temp_item_count = return_number(temp_unsorted_array[x],
                                                        3)
                    add_item_count = add_item_count + temp_item_count
                end
            end
        end
        last_temp_item_id = temp_item_id
        if add_item_count > 0 then
            local table_string = temp_item_name .. "," .. temp_item_id .. "," ..
                                     add_item_count
            table.insert(temp_array, table_string)
            --  print (add_item_count)
            add_item_count = 0
        end
    end
    print("\atSorted with proper counts")
    for y = 1, #temp_array do print("\ag", temp_array[y]) end
end
Bubble-sort?
 
why not just report the bug that the lookup is case sensitive instead?

tbh, I didn't know it was a 'bug' I thought it was the way it worked.. I am pretty sure if you

mq.cmd('/Lua run tacos) and mq.cmd('/Lua run TACOS') you would want to be able to delineate between the two.. why you would do this , no one knows..
 
Find the nearest vendor who has a path and return the name

Code:
-- Return nearest vendor with a path
local function nearest_vendor_spawn()
    -- Variables
    local suitable_vendor = 0
    local nearest_vendor_name
    local nearest_vendor_dist
    local nearest_vendor_path
    local nearest_vendor_id
    for c = 1, mq.TLO.SpawnCount('Merchant')() do
        print(mq.TLO.NearestSpawn(c, 'Merchant').DisplayName())
        print(mq.TLO.NearestSpawn(c, 'Merchant').ID())
        nearest_vendor_id = mq.TLO.NearestSpawn(c, 'Merchant').ID()
        mq.delay(1)
        nearest_vendor_path = mq.TLO.Nav
                                  .PathExists('id ' .. nearest_vendor_id)()
        -- print("Path Exists ", nearest_vendor_path)
        -- Select a vendor
        if nearest_vendor_path then
            nearest_vendor_id = mq.TLO.NearestSpawn(c, 'Merchant').ID()
            nearest_vendor_name = mq.TLO.NearestSpawn(c, 'Merchant')
                                      .DisplayName()
            nearest_vendor_dist = math.ceil(
                                      mq.TLO.Spawn(nearest_vendor_id).Distance())
            print("We found a suitable vendor and their name is: ",
                  nearest_vendor_name, " Distance: ", nearest_vendor_dist)
            suitable_vendor = 1
            break
        end
    end
    -- Unable to find vendor with path
    if suitable_vendor == 0 then
        print "We were unable to find a suitable vendor"
        return nil
    end
    -- print(nearest_vendor_name, " ", nearest_vendor_dist, " ", nearest_vendor_id)
    return nearest_vendor_name
end

Usage:

local find_vendor = nearest_vendor_spawn()

if find_vendor ~= nil then
-- we can navigate to the spawn
end
 
Select available item in inventory by name to be sold to vendor

Code:
local function select_inventory_item(p_item_name)
    local p_item_id = mq.TLO.FindItem(p_item_name).ID()
    --  print (p_item_name," ",p_item_id)
    -- Determine specific slot item is in
    -- If there is nothing in inventory - return
    if mq.TLO.FindItemCount(p_item_id)() < 1 or
        mq.TLO.FindItemCount(p_item_id)() == nil then return end
    repeat
        local slot1 = mq.TLO.FindItem(p_item_id).ItemSlot()
        local slot2 = mq.TLO.FindItem(p_item_id).ItemSlot2() + 1
        -- Open bag if it is in a bag and not open
        if slot2 ~= 0 then
            local pack = mq.TLO.FindItem(p_item_id).ItemSlot() - 22
            if mq.TLO.Window('pack' .. pack).Open() == nil then
                mq.cmd('/nomodkey /itemnotify ' .. slot1 .. ' rightmouseup')
                mq.delay(500)
            end
            -- Select the item in bag
            mq.cmd('/nomodkey /itemnotify in pack' .. pack .. " " .. slot2 ..
                       ' leftmouseup')
            mq.delay(500)
        else
            -- Select item in inventory slot
            mq.cmd('/nomodkey /itemnotify ' .. slot1 .. ' leftmouseup')
            mq.delay(500)
        end
        mq.delay(1)
    until mq.TLO.Merchant.SelectedItem() ~= nil
    return
end

Usage:

must have vendor window open...

select_inventory_item("Small Block of Clay")

Will open bags as needed...
 
Revisited the script status checking

(Totally over-engineered interim solution) if you didn't know how you invoked the script (i.e. /lua run TACOS or /lua run tacos or even /lua run TacOs)
or how the user invoked it..

Code:
-- return lua script status
local function script_status(p_script_name, p_squelch)
    -- print("passed: ", p_script_name)
    if mq.TLO.Lua.Script(string.upper(p_script_name)).Status() == "RUNNING" then
        if p_squelch == 1 then
            print(msg, "\agScript: \at", p_script_name, "\ag running")
        end
        return mq.TLO.Lua.Script(p_script_name).PID(),
               mq.TLO.Lua.Script(p_script_name).Status()
    end
    if mq.TLO.Lua.Script(string.lower(p_script_name)).Status() == "RUNNING" then
        if p_squelch == 1 then
            print(msg, "\agScript: \at", p_script_name, "\ag running")
        end
        return mq.TLO.Lua.Script(p_script_name).PID(),
               mq.TLO.Lua.Script(p_script_name).Status()
    end
    local pid_array = mq.TLO.Lua.PIDs()
    local delimiter = ","
    local pid_table = {};
    for match in (pid_array .. delimiter):gmatch("(.-)" .. delimiter) do
        if match ~= nil then table.insert(pid_table, match); end
    end
    local flag = 0
    local get_pid_name
    if pid_table[1] ~= nil then
        for c = 1, #pid_table do
            get_pid_name = mq.TLO.Lua.Script(pid_table[c]).Name()
            if get_pid_name ~= nil then
                local lower_pid_name = string.lower(get_pid_name)
                local lower_script_name = string.lower(p_script_name)
               -- print(lower_pid_name, " ", lower_script_name)
                if lower_pid_name == lower_script_name then
                    flag = 1
                   -- print(get_pid_name, " ", pid_table[c])
                    break
                end
            end
        end
    else
        return nil, nil
    end
    if flag == 1 then
        return mq.TLO.Lua.Script(get_pid_name).PID(),
               mq.TLO.Lua.Script(get_pid_name).Status()
    end
    return nil, nil
end

Usage:

local script_pid, script_status = script_status('TaCos',1)

returns the PID for the queried name and the status of it.

if it is not running or not found it returns nil


Why does this matter currently.. you can use it to pause or stop a Lua based on a PID no matter what weird way the user ran it..
 
Last edited:
Remove levitation buffs

Code:
local function drop_levitation_buffs()
    for i = 1, 42 do
        if mq.TLO.Me.Buff(i)() ~= nil then
        --    print(mq.TLO.Me.Buff(i).HasSPA(57)(), " ", mq.TLO.Me.Buff(i))
            if mq.TLO.Me.Buff(i).HasSPA(57)() then
                mq.cmd('/removebuff ', mq.TLO.Me.Buff(i))
            end
            mq.delay(1)
        end
    end
    for i = 1, 30 do
        if mq.TLO.Me.Song(i)() ~= nil then
         --   print(mq.TLO.Me.Song(i).HasSPA(57)(), " ", mq.TLO.Me.Song(i))
            if mq.TLO.Me.Song(i).HasSPA(57)() then
                mq.cmd('/removebuff ', mq.TLO.Me.Song(i))
            end
            mq.delay(1)
        end
    end
end

drop_levitation_buffs()
 
Remove levitation buffs

Code:
local function drop_levitation_buffs()
    for i = 1, 42 do
        if mq.TLO.Me.Buff(i)() ~= nil then
        --    print(mq.TLO.Me.Buff(i).HasSPA(57)(), " ", mq.TLO.Me.Buff(i))
            if mq.TLO.Me.Buff(i).HasSPA(57)() then
                mq.cmd('/removebuff ', mq.TLO.Me.Buff(i))
            end
            mq.delay(1)
        end
    end
    for i = 1, 30 do
        if mq.TLO.Me.Song(i)() ~= nil then
         --   print(mq.TLO.Me.Song(i).HasSPA(57)(), " ", mq.TLO.Me.Song(i))
            if mq.TLO.Me.Song(i).HasSPA(57)() then
                mq.cmd('/removebuff ', mq.TLO.Me.Song(i))
            end
            mq.delay(1)
        end
    end
end

drop_levitation_buffs()
there is the /removelev command
 
on fv.. people are 'helpful' so I will still need that code to check if they are casting it on me to be 'helpful' , in lieu of
mq.cmd('/removebuff ', mq.TLO.Me.Buff(i))
I will just use
mq.cmd('/removelev')


I spend most of my time in TLO and DataTypes.. but thanky for bringing me back to slash..
 
Code:
local function drop_levitation_buffs()
    for i = 1, 42 do
        if mq.TLO.Me.Buff(i)() ~= nil then
            --    print(mq.TLO.Me.Buff(i).HasSPA(57)(), " ", mq.TLO.Me.Buff(i))
            if mq.TLO.Me.Buff(i).HasSPA(57)() then
                mq.cmd('/removelev')
mq.delay(1000)
                break
            end
            mq.delay(1)
        end
    end
    for i = 1, 30 do
        if mq.TLO.Me.Song(i)() ~= nil then
            --   print(mq.TLO.Me.Song(i).HasSPA(57)(), " ", mq.TLO.Me.Song(i))
            if mq.TLO.Me.Song(i).HasSPA(57)() then
                mq.cmd('/removelev')
mq.delay(1000)
                break
            end
            mq.delay(1)
        end
    end
end

added break to exit after the match
 
wheels are re-invented in different shapes in new languages..

just go crazy and destroy mod rods in lieu of blocking buffs

Code:
-- rods/wands to destroy
local rods = {64951, 52817, 3426, 52709, 57264, 52674, 99783, 76503}


   while mq.TLO.Cursor.ID() do
        for c = 1, #rods do
            if mq.TLO.Cursor.ID() == rods[c] then
                print( "\ap[\arDestroying: \ap \ap[\awSilly ",
                      mq.TLO.Cursor, "\ap]")
                mq.delay(1000)
                mq.cmd('/destroy')
                mq.delay(1000)
                break
            end
mq.cmd('/autoinv')
        end
    end
 
Code:
local function block_cursor_loot()
    local spells_to_block = {
        52, 53, 55, 56, 1503, 2538, 6893, 6895, 10763, 10764, 10765, 3188, 50,
        10700, 27465
    }
    for x = 1, #spells_to_block do
        mq.cmd('/blockspell add me ', spells_to_block[x])
        mq.delay(1000)
    end
end

block_cursor_loot()
 
Lua - Lua Snips and discussion

Users who are viewing this thread

Back
Top
Cart