zapgroups.txt

mredge73

Member
Can anyone help me with the zapgroups.txt file. I want to load it into a map that I can use in an ash script. It is not a tab spaced list like every other list in the data folder so I don't really know how to go about loading it into a map where I can make use of it.

Here is how I load the list concoctions.txt; I want to do something similar for the zapgroups.txt :
Code:
[COLOR=DarkSlateBlue]record
{
string type;
item basic;
item garnish;
}[item] Ingrediants;
file_to_map("concoctions.txt", Ingrediants);[/COLOR]

item BreakDown=$item[ pink pony ];

item Base1=Ingrediants[BreakDown].basic;
item Garnish1=Ingrediants[BreakDown].garnish;
int cost1= historical_price(Base1)+historical_price(Garnish1)+(historical_price($item[bartender-in-the-box])/90);

print("Breakdown of "+BreakDown+" which is a "+Ingrediants[BreakDown].type);
print(Base1,"blue");
print(Garnish1,"blue");
print(cost1,"blue");
 

Attachments

  • zapgroups.txt
    10.1 KB · Views: 265

jasonharper

Developer
It is utterly impossible to read the current zapgroups.txt into a map. Even if the file used tabs instead of commas, you couldn't usefully read it, since the lines don't have a fixed number of fields (and some of the tiny plastic zap groups have 50 or so items!).

Your reading of concoctions.txt is broken for much the same reason - there's no upper bound to how many ingredient fields there are on a line. Fortunately, you can get the full list via get_ingredients().
 

mredge73

Member
Your reading of concoctions.txt is broken for much the same reason - there's no upper bound to how many ingredient fields there are on a line. Fortunately, you can get the full list via get_ingredients().
I guess you are right on that one, but it does work great for most items. I only really use that example for food and drinks (non-fishy) that only have 2 ingredients.

It is very unfortunate that ash cannot make use of zap groups with the included data files. Well maybe there is another way...
Any suggestions?
 

slyz

Developer
Did you check out what Heeheehee did for monsters.txt in his profit_fx.ash ? He did just what aqua suggested apparently.

In the case of zapgroups.txt though, all you have is one string per line, so it won't load into a map. You would need at least 2 fields on each line.

I don't think ASH has a 'none' type, (I also tried defining an empty record), and even if it did, I don't know if a none[string] map would trick file_to_map().

You could do a custom zapgroups.txt by adding a number followed by a tab on each line though. That sounds like something a powerful text editor or a linux script could do.
 

jasonharper

Developer
r8189 adds get_related(item, "zap") which will return a map with all the other members of the item's zap group as keys. The map will be empty for items not known to be zappable. The second parameter can also be "fold" to get the fold group, which is also problematic to read with file_to_map().
 

heeheehee

Developer
Staff member
Did you check out what Heeheehee did for monsters.txt in his profit_fx.ash ? He did just what aqua suggested apparently.

...

You could do a custom zapgroups.txt by adding a number followed by a tab on each line though. That sounds like something a powerful text editor or a linux script could do.

Wow, my script got mentioned. But the only reason I had to parse monsters.txt was because of the way that item_drops() works (it overwrites items that are dropped by one monster more than once, so bloopers and other similar monsters would've seemed less profitable than they really are).
 
Last edited:
Top