Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.

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
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
local function event()
mq.doevents()
return
end
local bank_item_slot = mq.TLO.FindItemBank(id).InvSlot()-40
mq.cmd('/notify BigBankWnd BIGB_BankSlot'..bank_item_slot..' leftmouseup')
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)()
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
mq.cmd('/bct blippy //lua run who.lua',(final_missing_array),'')
you can't. That command doesn't transfer data, it just sends the text string you give it.
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)
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
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/updateLua-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
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
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?

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
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
why not just report the bug that the lookup is case sensitive instead?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..

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?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
why not just report the bug that the lookup is case sensitive instead?
-- 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
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
-- 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
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
there is theRemove 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()
/removelev commandlocal 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
-- 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
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
