matt.chugg
Moderator
if there a way to get the associated effect of an item, for example
effect_of_item($item[purple snowcone]) == $effect[purple tongue]
effect_of_item($item[purple snowcone]) == $effect[purple tongue]
record effectentry {
string name;
string filename;
string descid;
string command;
};
effectentry[int] statuseffects;
file_to_map("statuseffects.txt", statuseffects);
effect[item] item2effect;
matcher cmdparser = create_matcher("(use|chew|eat|drink) (\\d+ )?([^;]+)", "");
foreach id in statuseffects {
effectentry e = statuseffects[id];
cmdparser.reset(e.command);
if (!cmdparser.find()) continue; // not a recognized command
item itm = to_item(cmdparser.group(3));
if (itm == $item[none]) continue; // failed to parse somehow
item2effect[itm] = to_effect(e.name);
}
// Testing:
foreach itm in item2effect {
print(itm + " => " + item2effect[itm]);
}