• 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

Problem - Selecting the Pet with the lowest PctHPs

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