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

