Checking for item in a slot?

Need help with a macro you are writing? Ask here!

Moderator: MacroQuest Developers

Bigguy70
a ghoul
a ghoul
Posts: 85
Joined: Tue Sep 27, 2005 9:08 am

Checking for item in a slot?

Post by Bigguy70 » Mon Oct 03, 2005 6:36 pm

http://www.macroquest2.com/wiki/index.p ... troduction

How would I check to see if there is an item in my toon's Neck slot? I'm writing a sub to summon Focus necklace for my mage.

will go like this:

If neck slot empty
cast summon focus item
autoinventory
loop back up to check slot
return

think it will use InvSlot Neck .. just don't know how :roll:

I know the sntax for the body just can't figure out the syntax for
If neck slot empty.

User avatar
fearless
Not a Psychic
Posts: 2684
Joined: Wed Mar 10, 2004 3:52 pm

Post by fearless » Mon Oct 03, 2005 7:21 pm

!${InvSlot[neck].Item.ID}
Reading . . . it's not just for me.

[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
[quote="Ccomp5950"]Fearless showed me the light, you too shall learn.[/quote]

Bigguy70
a ghoul
a ghoul
Posts: 85
Joined: Tue Sep 27, 2005 9:08 am

Post by Bigguy70 » Tue Oct 04, 2005 1:39 am

Thank you fearless for the help, now to take my script to the next step,

I need to check for leftear slot AND check for Tarnished bauble,

here is the script I have so far

Code: Select all

|--------------------------------------------------------------------------------------------------------------------------|
| GearUp.mac -- Ver 1.0 --  10-4-2005
| by Bigguy70 
| Based off of                                                                         |
| MakeDinner.mac -- Ver 1.0 -- Written by Jaq -- 06/01/2005                                                                |
| Posted by Jaq @ http://www.macroquest2.com/phpBB2/viewtopic.php?t=11535&highlight=makedinner                             |
| Ver 1.1 Updated by Bigguy70 10-2-2005                                                                                    |
|                                                                                                                          |
| This is a simple macro that will summon food and drink.                 |
| Usage: /mac MakeDinner <NumFood> <NumDrink>  -- If no params are given it will default to 20 of each.                    |
| Requires: spell_rouitines.inc                                                                                            |
| You may customize this macro for your needs.     |
| You can change the default declares as follows:                                                                          |
|   FoodAmt: Default number of foods to summon if no params given.                                                         |
|   DrinkAmt:  Default number of drinks to summon if no params given.                                                      |
|   BAAmt: Number of bandaids                                                                                              |
|   SummonOne: Name of spell set that contains summon spells.                                                              |
|   NormalSet: Name of set to load after summoning items.                                                                  |
|   Foodspell: What spell to use to summon foods.                                                                          |
|   DrinkSpell:  What spell to use to summon drinks.                                                                       |
|   BASpell: Name of spell to summon Bandaids.                                                                             |
|   FoodCastAmt:  How many foods does the specified food spell summon.                                                     |
|   DrinkCastAmt:  How Many drinks does teh specified drink spell summon.                                                  |
|   FoodCastType: Type of food item summoned by spell, used to check what you have on hand                                 |
|   DrinkCastType: Type of drink summoned                                                                                  |
| Note: I do not play a mage, but am aware they may have 1 spell that summons both.  I would like to add code for that     |
| if someone can provide some simple info on how the spell works for mages, or if this would even be useful.               |
|                                                                                                                          |
| Macro inspired by MQ2FeedMe ~ cuz now I have a good reason to have some free food on me ~ thanks for that plug.          |
|                                                                                                                          |
| -- Jaq                                                                                                                   |
|--------------------------------------------------------------------------------------------------------------------------|

#include spell_routines.inc

Sub Main

|~~~~~~~~~~~~~~~~~~
|~~~  DECLARES  ~~~
|~~~~~~~~~~~~~~~~~~
|--------------- Customizable Declares ----------------------|
   /declare  FoodAmt        int outer 20
   /declare  DrinkAmt       int outer 20
   /declare  BAAmt          int outer 40
   /declare  SummonOne      string outer "gearup"
   /declare  NormalSet      string outer "n"	
   /declare  FoodSpell      string outer "Summon Food"
   /declare  DrinkSpell     string outer "Summon Drink"
   /declare  BASpell        string outer "Summon Bandages"
   /declare  NeckSpell      string outer "Summon Brass Choker"
   /declare  ShoulderSpell	string outer "Summon Linen Mantle"
   /declare  BACastAmt      int outer 5	
   /declare  FoodCastAmt    int outer 1
   /declare  DrinkCastAmt   int outer 1
   /declare  FoodCastType   string outer "Bread"
   /declare  DrinkCastType  string outer "Water"
|---------- End of Customizable Declares --------------------|

   /declare  FoodCnt        int outer 0
   /declare  DrinkCnt       int outer 0
   /declare  BACnt          int outer 0
   /declare  OldSpell       string outer

|~~~~~~~~~~~~~~~~~~~~~
|~~~  MAIN SCRIPT  ~~~
|~~~~~~~~~~~~~~~~~~~~~

   /if (${Defined[Param0]}) {
      /varset FoodAmt ${Param0}
   }
   /if (${Defined[Param1]}) {
      /varset DrinkAmt ${Param1}
   }

   /loadspells ${SummonOne}
:Loadspell
   /if ( ${Window[SpellBookWnd].Open}) {
            /goto :loadspell
         } 
  
   /call SummonFood
   /call SummonDrink
   /call BA
   /call Neck
   /call shoulder
   
   /loadspells ${NormalSet}
/endmacro

|~~~~~~~~~~~~~~~~~~~~~~
|~~~  CALLED SUBS  ~~~~
|~~~~~~~~~~~~~~~~~~~~~~

Sub SummonFood
:foodloop
   /call PutInBag
   /varcalc FoodCnt ${FindItemCount[${FoodCastType}]}+${FoodCastAmt}
   /delay 5s ${Me.SpellReady[${FoodSpell}]}
   /if (${FoodCnt}<=${FoodAmt}) {
   	  /call cast ${FoodSpell}
      /goto :foodloop
   } 
/return

Sub SummonDrink
:drinkloop
   /call PutInBag
   /varcalc DrinkCnt ${FindItemCount[${DrinkCastType}]}+${DrinkCastAmt}
   /delay 5s ${Me.SpellReady[${DrinkSpell}]}   
   /if (${DrinkCnt}<=${DrinkAmt}) {
   	   /call cast ${DrinkSpell}
      /goto :drinkloop
   } 
/return

Sub BA
:loopba
   /call PutInBag
   /varcalc BACnt ${FindItemCount[Bandage]}+${BACastAmt}
   /delay 5s ${Me.SpellReady[${BASpell}]}   
   /if (${BACnt}<=${BAAmt}) {
   	  /call cast ${BASpell}
      /goto :loopba
   }
/return

Sub Neck
:neckloop
  /call PutInBag
  /if (!${InvSlot[neck].Item.ID}) {
  	/delay 5s ${Me.SpellReady[${NeckSpell}]}
  	/call cast ${NeckSpell}
  	/goto :neckloop
  }
/return

Sub Shoulder
:Shoulderloop
  /call PutInBag
  /if (!${InvSlot[Shoulder].Item.ID}) {
  	/delay 5s ${Me.SpellReady[${ShoulderSpell}]}
  	/call cast ${ShoulderSpell}
  	/goto :Shoulderloop
  }
/return

Sub PutInBag
  :Loop
   /if (${Cursor.ID}) {
     /autoinv
     /delay 2s !${Cursor.ID}
     /goto :Loop
  }
/return

|** 1.1 made the Varibles = total on hand after script is ran.
	cleaned up a few lines.  **|

I plan to some day make the script automaticly pick best focus items available based on char lvl & spells available in spell book but for now its all coded in the Declare section of the script.

User avatar
gimp
a grimling bloodguard
a grimling bloodguard
Posts: 584
Joined: Fri Oct 29, 2004 9:28 am
Location: internet

Post by gimp » Tue Oct 04, 2005 9:51 pm

Bigguy70 wrote:I need to check for leftear slot AND check for Tarnished bauble,

Code: Select all

/if (${InvSlot[leftear].Item.Name.Equal[Tarnished Bauble]}) {
  ...
}

Bigguy70
a ghoul
a ghoul
Posts: 85
Joined: Tue Sep 27, 2005 9:08 am

Post by Bigguy70 » Wed Oct 05, 2005 4:00 pm

Thanks for the info Gimp I'll probably need that info someday but I wasn't clear enough in my question. I need to check that the leftear slot is empty and that I don't have the Bauble any where in my inventory.

User avatar
gimp
a grimling bloodguard
a grimling bloodguard
Posts: 584
Joined: Fri Oct 29, 2004 9:28 am
Location: internet

Post by gimp » Wed Oct 05, 2005 4:53 pm

Bigguy70 wrote:Thanks for the info Gimp I'll probably need that info someday but I wasn't clear enough in my question. I need to check that the leftear slot is empty and that I don't have the Bauble any where in my inventory.
okay, that's

Code: Select all

/if (!${InvSlot[leftear].Item.ID} && !${FindItem[=Tarnished Bauble].InvSlot}) {
  ...
}
mq2 code can look pretty neat sometimes :)

User avatar
fearless
Not a Psychic
Posts: 2684
Joined: Wed Mar 10, 2004 3:52 pm

Post by fearless » Wed Oct 05, 2005 5:03 pm

gimp wrote:
Bigguy70 wrote:Thanks for the info Gimp I'll probably need that info someday but I wasn't clear enough in my question. I need to check that the leftear slot is empty and that I don't have the Bauble any where in my inventory.
okay, that's

Code: Select all

/if (!${InvSlot[leftear].Item.ID} && !${FindItem[=Tarnished Bauble].InvSlot}) {
  ...
}
mq2 code can look pretty neat sometimes :)
!${FindItem[=Tarnished Bauble].InvSlot}?
Reading . . . it's not just for me.

[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
[quote="Ccomp5950"]Fearless showed me the light, you too shall learn.[/quote]

User avatar
gimp
a grimling bloodguard
a grimling bloodguard
Posts: 584
Joined: Fri Oct 29, 2004 9:28 am
Location: internet

Post by gimp » Wed Oct 05, 2005 5:34 pm

fearless wrote:!${FindItem[=Tarnished Bauble].InvSlot}?
no, he asked "I need to check that the leftear slot is empty"

User avatar
fearless
Not a Psychic
Posts: 2684
Joined: Wed Mar 10, 2004 3:52 pm

Post by fearless » Wed Oct 05, 2005 5:52 pm

I meant the = in the []
Reading . . . it's not just for me.

[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
[quote="Ccomp5950"]Fearless showed me the light, you too shall learn.[/quote]

User avatar
gimp
a grimling bloodguard
a grimling bloodguard
Posts: 584
Joined: Fri Oct 29, 2004 9:28 am
Location: internet

Post by gimp » Wed Oct 05, 2005 7:17 pm

fearless wrote:I meant the = in the []
tfm says:
item FindItem[ [=]name]



access to type(s): item



Object which is the found item on your character, a corpse, or a merchant by partial name match. Using =name will only find exact match

User avatar
fearless
Not a Psychic
Posts: 2684
Joined: Wed Mar 10, 2004 3:52 pm

Post by fearless » Wed Oct 05, 2005 7:27 pm

My bad . .. I've never needed to use finditem before. /shrug
Reading . . . it's not just for me.

[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
[quote="Ccomp5950"]Fearless showed me the light, you too shall learn.[/quote]

Bigguy70
a ghoul
a ghoul
Posts: 85
Joined: Tue Sep 27, 2005 9:08 am

Post by Bigguy70 » Thu Oct 06, 2005 6:24 am

Thanks for all the help folks, the reason for needing to check for the bauble is because its lore and while I pretty sure I could do a /doevents for lore I'd be wasting the mana when I can just check for it before hand.

User avatar
gimp
a grimling bloodguard
a grimling bloodguard
Posts: 584
Joined: Fri Oct 29, 2004 9:28 am
Location: internet

Post by gimp » Thu Oct 06, 2005 6:34 am

Bigguy70 wrote:Thanks for all the help folks, the reason for needing to check for the bauble is because its lore and while I pretty sure I could do a /doevents for lore I'd be wasting the mana when I can just check for it before hand.
btw just looked on lucy i suppose the item u mean is "Jolum's Tarnished Bauble"

in that case, code should be

Code: Select all

/if (!${InvSlot[leftear].Item.ID} && !${FindItem[=Jolum's Tarnished Bauble].InvSlot}) {
  ..
}