Page 1 of 1

Stop a macro run when out of needed item

Posted: Fri Jul 13, 2012 8:34 pm
by sirkitesalot
I am looking to stop a macro when you run out of ammo, potions, or food that is needed for the bot.

When the trigger is found then the bot either retreats to a "safeplace" waypoint or recalls and then camps out. I have the recall and camp out part down but would love to not trigger the recall rather to retreat to a "safe place" and then camp as long as there is no ago if agro kill the attacker(s) and then camp.

any pointers would be greatly appricated.

Re: Stop a macro run when out of needed item

Posted: Fri Jul 13, 2012 9:32 pm
by lisa
I would say to add code to onleavecombat for checking the items you require, since it will be in the profile then you can specify the actual items instead of trying to allow for all potions.

Then just create a WP to go to your "safe" place and then log out when you get there.

Re: Stop a macro run when out of needed item

Posted: Sun Jul 15, 2012 8:12 pm
by sirkitesalot
Thank you for the point in the right direction here is what I am working with

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints>
   <onLoad>

startGMDetect()

-- 0 = white / 1 = green / 2 = blue / 3 = purple / 4 = orange / 5 = gold
   
changeProfileOption("INV_AUTOSELL_ENABLE",true)
changeProfileOption("AUTO_ELITE_FACTOR", 8)

function CleanBagS()
   for i, item in pairs(inventory.BagSlot) do
      if item.SlotNumber >= settings.profile.options.INV_AUTOSELL_FROMSLOT + 60 and
      settings.profile.options.INV_AUTOSELL_TOSLOT + 60 >= item.SlotNumber then
         if item:isType("Runes") then 
            item:delete()
         end 
         if ( item:isType("Weapons") or item:isType("Armor") ) and (1000 > item.Worth and 3 > item.Quality)then
            item:delete()
         end
         if item:isType("Potions") and (45 > item.RequiredLvl and item.RequiredLvl > 10) then
            item:delete()
         end         
         if item:isType("Arrow") and (45 > item.RequiredLvl and item.RequiredLvl > 10) then
            item:delete()
         end 
         if item.Name == "Item2" then
            item:delete()
         end 
         if item.Name == "Item1" then
            item:delete()
         end 
      end
   end
end   

oldOnLeaveCombat = settings.profile.events.onLeaveCombat;

settings.profile.events.onLeaveCombat = function()
--add code here

--This is where I am lost I am not sure of a good way to look for a potion that could be anyplace in a bag or check for ammo in ammo slot or in a bag or quiver in bag someplace.
-- envisioned logic
-- If ammo slot = 0 and bag slot 30 to 180 no ammo bag then load waypoint and quit else continue below.

CleanBagS()
loadPaths("Path2");

--call profile on leave combat
  if (oldOnLeaveCombat and (type(oldOnLeaveCombat)=='function')) then
    oldOnLeaveCombat();
  end;
end

   </onLoad>
	<!-- #  1 --><waypoint x="" z="" y="">	</waypoint>
	<!-- #  2 --><waypoint x="" z="" y="">	</waypoint>
</waypoints>

Re: Stop a macro run when out of needed item

Posted: Sun Jul 15, 2012 9:04 pm
by lisa
sirkitesalot wrote:This is where I am lost I am not sure of a good way to look for a potion that could be anyplace

Code: Select all

inventory:itemTotalCount(itemNameOrId, range)
So let's just say the potion you use is called "Big Pot"

Code: Select all

if 5 >= inventory:itemTotalCount("Big Pot") then
--go do something else, out of pots
end