• 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

Problem - Selecting the Pet with the lowest PctHPs

Joined
Mar 20, 2024
RedCents
1,051¢
I got a script with the following code, which tells me all the pets in the group and their respective PctHPs:

Code:
for i=0,mq.TLO.Group.Members() do
    print('Pet ', mq.TLO.Group.Member(i).Pet.CleanName() , ' is at ', mq.TLO.Group.Member(i).Pet.PctHPs(), '% health')
end

It seems to work correctly. See screenshot below:

Screenshot 2024-03-31 225201.png

Well, now that I seem to have every pet's health, I would like to target whichever pet is lowest in health.

Any suggestion? Thanks!
 
have a variable 'currentlowest' that starts with a value of 101, then a variable to store the spawn id, and for each loop check to see if it's less than the currentlowest, if it is, then update both the currentlowest and the spawn id.

When you reach the end, you'll have the lowest stored in the spawnid and if the currentlowest is less than 100, then handle that appropriately.
 
have a variable 'currentlowest' that starts with a value of 101, then a variable to store the spawn id, and for each loop check to see if it's less than the currentlowest, if it is, then update both the currentlowest and the spawn id.

When you reach the end, you'll have the lowest stored in the spawnid and if the currentlowest is less than 100, then handle that appropriately.

Hmmmm I am not sure I follow. Would you terribly mind to rephrase that for me please? I am still struggling with the coding concepts hehe :)

Thank you!
 
Hmmmm I am not sure I follow. Would you terribly mind to rephrase that for me please? I am still struggling with the coding concepts hehe :)

Thank you!
Not going to test the syntax, but something like:

Lua:
lowestPctIndex = 0
lowestPct = mq.TLO.Group.Member(0).Pet.PctHPs()

for i=1,mq.TLO.Group.Members() do
    if mq.TLO.Group.Member(i).Pet.PctHPs() < lowestPetPct then
       lowestPct = mq.TLO.Group.Member(i).Pet.PctHPs()
       lowestPctIndex = i
    end
end

On completion, lowestPctIndex will be the group member with the lowest health pet. Disclaimer - this code doesn't check that a member has a pet, so I don't know what happens for that case.
 
Not going to test the syntax, but something like:

Lua:
lowestPctIndex = 0
lowestPct = mq.TLO.Group.Member(0).Pet.PctHPs()

for i=1,mq.TLO.Group.Members() do
    if mq.TLO.Group.Member(i).Pet.PctHPs() < lowestPetPct then
       lowestPct = mq.TLO.Group.Member(i).Pet.PctHPs()
       lowestPctIndex = i
    end
end

On completion, lowestPctIndex will be the group member with the lowest health pet. Disclaimer - this code doesn't check that a member has a pet, so I don't know what happens for that case.

Worked like a charm. Thanks!
 
Problem - Selecting the Pet with the lowest PctHPs

Users who are viewing this thread

Back
Top
Cart