1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Greetings Guest!!

    In order to combat SPAM on the forums, all users are required to have a minimum of 2 posts before they can submit links in any post or thread.

    Dismiss Notice
  3. Greetings Guest, Having Login Issues? Check this thread!
    Dismiss Notice
  4. Hail Guest!,
    Please take a moment to read this post reminding you all of the importance of Account Security.
    Dismiss Notice
  5. Author Wes Locher has teamed up with Stratics for a giveaway of his new book Braving Britannia. This book explores the history and impact of Ultima Online and includes interviews from current and past dev team members as well as many UO and Stratics community members. Click here for more details!
    Dismiss Notice

EC - Target lowest health pet, custom function

Discussion in 'UO Tamer' started by pgib, Dec 23, 2011.

  1. pgib

    pgib Guest

    Second time i look at LUA, so this might be the least elegant function ever seen: targets the pet that has the lowest health in you current set of followers.

    (in PetWindow.lua)
    function PetWindow.GetPetHealth(petId)
    	local h = WindowData.MobileStatus[petId].CurrentHealth
    	return h
    function PetWindow.TargetLowestHealthPet()
    	local targetId = nil
    	local lowestHealth = -1
    	local i
    	for i=1,PetWindow.totalPets do
    		local id = WindowData.Pets.PetId[i]
    		local health = PetWindow.GetPetHealth(id)
    		if((lowestHealth == -1) or (health < lowestHealth)) then
    			targetId = id
    			lowestHealth = health
    	if(targetId ~= nil) then
    Then i use it in a macro like this:

    Slot 1: script PetWindow.TargetLowestHealthPet()
    Slot 2: bandage selected target

    I find it quite useful when i take my dogs out, I'm still testing it, works well so far.

    EDIT: of course it was fraught with problems (the table is used as reference didn't keep track of changes in the pet set, maybe). Now it works even after changing the pets. Sorry but coding for the EC is like moving blindfolded with a dark sky in a foggy night under heavy rain.
  2. Pinco

    Pinco UOEC Modder
    Stratics Veteran Stratics Legend

    Jul 25, 2005
    Likes Received:
    nice idea, I think I'm going to expand it :p