• 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

Python3 - Do my toons have this item???

Joined
Dec 28, 2019
RedCents
4,627¢
Tonight I had a few beers and maybe a shot of whiskey or two and was trying to collect some items. I was looking through my groups bags to see if everyone had a collection and decided to write a script to do that for me, cause its a PITA to look through your bags.

I wrote a python script that will show me all the items that all six of my toons have in inventory. This can be used for different things, but I wrote it mainly for collections. Maybe you'll find it useful if you like Python. I know most people have shifted to Lua and this is totally doable in Lua. Like I said already, I've had a few beers and don't know Lua as well as others, so I wrote this in python. Just trying to give back to the community.

Assumptions:
  1. Your running MacroQuest
  2. Your running Lootly
  3. You have added the collections for the zone your in to your Lootly_Loot.ini file, Example:
    Code:
    Votive Candle=Keep|1
  4. You have a version of Python 3.x installed
  5. You need to dump your inventory on all your toons
  6. Then run this python script (after following the instructions in the script)
  7. I also utilize VS Code for my scripts


[CODE lang="python" title="RG_weHaveSix.py"]
# Requirements as I run it.... YMMV
# Windows 11
# Python 3.9.13 - you can have lower or higher version of Python 3
# Lootly
#
# Run the following command on your six toon team, depending on which in game broadcast you use
# Dannet: /dgga /outputfile inventory
# or
# EQBC: /bcga /outputfile inventory
import re

####################
# Replace with your path to your Lootly INI file
lootlyPath = 'C:\\Games\\MQ2Next\\config\\Lootly_Loot.ini'
# Replace with your path to Everquest
eqPath = 'C:\\Games\\Everquest\\'
# Replace with your character names in your group
Goup1 = ['Tank', 'DPS1', 'DPS2', 'CC', 'Utility', 'Healer']
# Replace "server" with the server you play on
f_Inventory = '_server-Inventory.txt'
# Replace "Tank" with the name of your main looter
focusPlayer = 'Tank'
# Replace with items that you DON'T want to match on
ignore = "(Tailored Legendary Backpack|Heroic Satchel of the Adventurer|\
Extraplanar Trade Satchel|Scuffed Journeyman's Rucksack|\
Scuffed Journeyman's Rucksack|Primary Anchor Transport Device|\
Fellowship Registration Insignia|Philter of Major Translocation|\
Extraplanar Trade Satchel|Gouda Cheese|Modulation Shard|Philter of the Ant|\
Bottle of Milk|Dire Tuning Crystal)"
####################

#################################################################################################################
# Don't edit below this line unless your customizing this script, which you will be responsible for supporting. #
#################################################################################################################
lootlyData = []
tankInv = []
othersInv = []
weHaveSix = []

# Populate lootlyData list
def listLootly(data):
for obj in data:
obj = obj.strip()
lootlyData.append(obj)

# Lets get data from the Lootly.ini
def getLootlyData():
with open(lootlyPath, 'r') as data:
lines = data.readlines()
listLootly(lines)

# Get the tanks inventory and append to tankInv
def getTankInv():
tankInvFile = eqPath + focusPlayer + f_Inventory
with open(tankInvFile, 'r') as data:
for line in data:
line = line.strip()

m1 = re.search('(Empty)', line)
m2 = re.search(rf"^(.*{ignore}.*)$", line)
m3 = re.search('^(General)\s+(\d+)(-Slot\d+\s+|\s+)(\w+\D\w+\D+)(\d+)\s+(\d+)\s+(\d+)$', line)

if m1:
continue
elif m2:
continue
elif m3:
tankInv.append(f"{m3.group(4)}")

# Inventory all toons except the focusePlayer(Tank) and append to othersInv
def getToonsInvetory():
for name in Goup1:
if name == focusPlayer:
continue
else:
playerInv = eqPath + name + f_Inventory
with open(playerInv, 'r') as data:
for line in data:

m1 = re.search('(Empty)', line)
m2 = re.search(rf"^(.*{ignore}.*)$", line)
m3 = re.search('^(General)\s+(\d+)(-Slot\d+\s+|\s+)(\w+\D\w+\D+)(\d+)\s+(\d+)\s+(\d+)$', line)

if m1:
continue
elif m2:
continue
elif m3:
#print(f"{m3.group(4)}")
othersInv.append(f"{m3.group(4)}")

# Find items that all toons have and append to weHaveSix list
def findSixItems():
count = 0
for tank in tankInv:
count = 1
for other in othersInv:
if tank == other:
count = count+1
if count >= 6:
weHaveSix.append(tank)

# Loop through your results and count your findings of six
def loop(y):
c = 0
for x in y:
c = c+1
z = x.strip()
print(f"{c}: {z}")

# execute your defined functions
getLootlyData()
getTankInv()
getToonsInvetory()
findSixItems()
loop(weHaveSix)
[/CODE]


Example of output from VS Code:
Code:
PS Z:\Scripts> & C:/Users/Taz/AppData/Local/Microsoft/WindowsApps/python3.9.exe z:/Scripts/Python/Everquest/RG_weHaveSix.py
1: Votive Candle
2: Candelabra
3: Golden Censer
4: Medallion of the Dragon
5: Writ of the Scale
6: Vestment of the Dragon
7: Blood Chalice
8: Kneeling Pad
9: Piece of a Medallion
PS Z:\Scripts>

-Taz
 
Last edited:
Thanks @Szazor

Looking at this with clear eyes now, I see a few things I can clean up in this. I think I'll also add some automation, consume the collectable on all toons, then backup and edit the lootly INI to set the consumed item to "=Ignore".

I'll eventually rewrite this in Lua, I need to start writing stuff in Lua anyway, no better way to learn

-Taz
 
Fyi, I wrote a Lua that does give you a return on items in inventory in game when you want to search by name or id across all of your toons.


And Sic has the plugin mq2status which gives you similar information as well, perhaps not in the format you were looking for, but it saves searching inventories and external files, but it goes by individual name only, not sets, or collectibles only necessarily.
 
If you can code while 3 sheets to the wind then you get a red cent from me! If I tried to code under the influence I would probably literally have stuff like (a miracle occurs) as actual lines of code and not know why a miracle wasn't happening to make the code work.
1677618484046.png
I'm sure I saw that exact code on the internet somewhere!!

I believe this comic is by Sidney Harris.
 
Python3 - Do my toons have this item???

Users who are viewing this thread

Back
Top
Cart