Page 1 of 1

Request: INI point-in-the-right-direction.

Posted: Thu Jun 03, 2004 6:25 am
by MoonRaverX
Alrighty, I have something in mind I want to write out, and now comes the INI stuff. Out of everything I've done, I've always used declares. I dont' know the first thing about INI's.

I saw the topic in the snippets about ini's, but it seems it only works with a file such as:

Code: Select all

[SomeHeader]
Item1=Value
Item2=Value
The well known (by now) hunter macro seems to only use that include, as it uses 2 seperate ini's 1 for loot and 1 for mobs. I did see where a forage macro had the item name actually be a string to check against, which is nice, and then a tradeskill macro did alot, but had admitted errors.

If I wanted to say, do something like this...

Code: Select all

[Main]
healspell=Tnarg's Mending
ddspell=Spear of Torment
hpmin=50 

[Area1]
mob1=a_rat
mob2=a_snake

[Area1]
loot1=whiskers
loot2=scales
A) Is it possible
B) How would I differentiate headings

Final note, if I can get this working, I want to write an include called Ini.inc that has the working subs with a how-to, to make it simpler (is that a word?) for others to use ini's (if they can use the search function).

The abilitie to do this would be nice...
define main_array
read ini for main area (general setup info)
read ini for data specific to the current zone... much like the hunter macro.
return a 1 for success or something else for errors

And no, my goal isn't just another mod of the hunter script. This is something I'd like to have to use where I want to, and once working, will give the ini.inc to the community.

Posted: Thu Jun 03, 2004 6:52 am
by blueninja
string Ini[filename,section,key,default]: Reads from an ini file. section, key, and default do not need to be given. section and key may be set to -1 to skip them and give a new value. If section or key are not given, multiple values are read...
filename - obvious
section - what's in between the brackets
key - what's before the =
default - what to return if the key can't be found in that section

So basically in your example

Code: Select all

${Ini[myfile.ini,main,healspell]}
would return Tnarg's mending and

Code: Select all

${Ini[myfile.ini,Area1,loot1]}
would return whiskers..

You have 2 [Area1] in your ini example which seems kind of pointless :) ..

Posted: Thu Jun 03, 2004 2:09 pm
by Jerle69
Rogue Helper makes extensive use of two INI files, and is about to have more stuff jammed into the settings file soon. You can take a look at it for some examples.

Posted: Fri Jun 04, 2004 5:37 pm
by MoonRaverX
My goal was to get a somewhat working single ini file for multiple uses. And yes, I know I had 2 area1's, didn't know you could look for 2 types under it so easily.

With the examples provided, going to take a crack at the whetstone after work.