this new data/parm thing confuses my simple caveman brain...

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

Moderator: MacroQuest Developers

code4food
orc pawn
orc pawn
Posts: 24
Joined: Fri Feb 20, 2004 12:31 pm

this new data/parm thing confuses my simple caveman brain...

Post by code4food » Mon May 24, 2004 10:55 am

building a merchant dumpster diving script, and having 2 problems (so far)
1. can't for the life of me figure out how to get merchant.item[ITEMNAME] to do, well, anything. i'm assuming there's a way to get it to select the ITEMNAME (or return something if the merchant doesn't have the item), but all the ways i tried only gave me error messages.
2. the read ini sub i grabbed from snippets doesn't seem to be testing the section names correctly

Code: Select all

#turbo 40
#event Broke "#*#can't afford to buy them#*#"
#event Full "#*#no more room#*#" 

Sub Main(PurchaseType)
   /if (!${Defined[PurchaseType]}) {
    /echo Usage: /macro dumpster <Purchase Type>
    /endmacro
   }
   /declare loopcount int outer 0
   /call ReadINI dumpster.ini ${PurchaseType}
   /if (!${Defined[PurchaseArray]}) {
      /echo Ini Read Error, ending macro...
      /endmacro
   }
   /if (${Merchant.Open}) {
   /for loopcount 1 to $(PurchaseArray.Size)
    /echo Looking for ${PurchaseArray[${loopcount}]}
    ${Merchant.Item[${PurchaseArray[${loopcount}]}]}
   /next loopcount
   }
/return


|--------------------------------------------------------------------------------
|SUB: Reading from an INI File
|--------------------------------------------------------------------------------
Sub ReadINI(FileName,SectionName)
|Does the key exist?
  /echo Reading ${SectionName} information from ${FileName}
  /if (${Ini[${FileName},${SectionName},-1,NO].Equal[NO]}) {
    /echo Section Name not valid
    /return
  }
  /declare nValues int local 1
  /declare KeySet string local ${Ini[${FileName},${SectionName}]}
| Sets KeySet. This will be a single string of all the KeyNames in the ini.
| Ex) KeySet = KeyName1|KeyName2||

  :CounterLoop
| Using the Arg function, count how many different Values there are.
    /if (!${KeySet.Arg[${nValues},|].Length}) {
      /varcalc nValues ${nValues}-1
      /goto :MakeArray
    }
    /varcalc nValues ${nValues}+1
  /goto :CounterLoop 

  :MakeArray
    /if (!${nValues}) /return
    /declare nArray int local
| Declare the array now that we know the size. Can be int or string
    /declare PurchaseArray[${nValues}] string outer
| Set back through the ini, this time filling in the array with the values
    /for nArray 1 to ${nValues}
      /varset PurchaseArray[${nArray}] ${Ini[${FileName},${SectionName},${KeySet.Arg[${nArray},|]},NULL]}
    /next nArray
/return 

Sub Event_Broke
   /echo Error: You are out of money!
   /beep
   /endmacro
/return

Sub Event_Full
   /echo Error: Your inventory is full!
   /beep
   /endmacro
/return

Code: Select all

[Test]
Item1=Fishing Grubs

Preocts
a snow griffon
a snow griffon
Posts: 312
Joined: Thu Jan 29, 2004 1:02 pm

Post by Preocts » Mon May 24, 2004 1:01 pm

merchant
- Members:
...bool Open: Merchant open?
...float Markup: The amount used to calculate item values on this merchant (Markup is what your charisma, faction, etc change). Markup*Cost=Merchant's sell price. Cost*(1/Markup)=Your sell price. Markup of 1.05 is highest no matter what, so there might not be any actual cap based on charisma.
...int Items: Item count on the merchant
...item Item[n]: nth item on the merchant
...item Item[name]: Finds an item by partial name at this merchant (use merchant.Item[=name] for exact)

- To String: FALSE, except if a merchant is open gives TRUE

item
- Members:
...int ID: Item ID
...string Name: Name
...bool Lore: Lore?
...bool NoDrop: No drop?
...bool NoRent: No rent?
...bool Magic: Magic?
...int Value: Item value in copper
...int Size: Item size
...int Weight: Item weight
...int Stack: Stack count
...string Type: Type
...int Charges: Charges
...string LDoNTheme: "Non-LDON" "Deepest Guk" "Miragul's" "Mistmoore" "Rujarkian" "Takish"
...string DMGBonusType: None Magic Fire Cold Poison Disease
...bool Stackable: Stackable?
...int Container: Number of slots, if this is a container
...int Items: Number of items, if this is a container
...item Item[n]: nth contained item, if this is a container
...invslot InvSlot: Inventory slot for this item
...int BuyPrice: Price to buy this item at this merchant
...int SellPrice: Price to sell this item at this merchant
...spell Spell: Spell effect
...float CastTime: Spell effect's cast time
...string EffectType: Spell effect type
- To String: Same as Name
Cool. Let's start here. You are thinking that ${Params} interact somehow with the game or your macro. Please understand you are mistaken. They are simply carriers of information, at your beck and call whenever you need them. They cannot selete items in a merchant, but they can tell you if the merchant has said items. Please note the red lines above.

${Merchant} alone... False or True dependant on whether a merchant window is open.
${Merchant.Item[name]} alone, returns an item value which has even more information.
${Merchant.Item[name].ID} alone, returns the ID of the item you just searched for in .Item[name] on your Merchant. ((following this?))
IF the merchant has the item you searched for then there will be an ID. If the merchant DOESN'T have the item then there won't be an ID. Throw this into an /if statement and you have a good way to check whether or not an item exists on a merchant.

Code: Select all

/if (${Merchant.Item[MyItem].ID}) {
  /echo The item is there, now what?
  /echo Oh yeah, it's in merchant slot ${Merchant.Item[Name].InvSlot}
  /itemnotify ${Merchant.Item[Name].InvSlot} leftmouseup
  /echo And I just clicked it for you.
} else {
  /echo The item is not to be found on this merchant.
}
rawr

code4food
orc pawn
orc pawn
Posts: 24
Joined: Fri Feb 20, 2004 12:31 pm

Post by code4food » Mon May 24, 2004 1:41 pm

excellent, i had originally tried something like that if statement (but it didn't have the ID part), but didn't think to use the Item properties. thank you.