efilnikufecin
Member
Cannot apply int [item] to return_table[] (Item_usage.ash, line 32)
Line 32 contains:
Doesn't extract_meat have an int type return?
Line 32 contains:
Code:
return_table[touse].meat_gained = return_table[touse].meat_gained + extract_meat( source );
Doesn't extract_meat have an int type return?
Code:
typedef int [item] itemset;
record data
{
int total_used;
int meat_gained;
itemset items_acquired;
};
data [item] return_table;
if (!file_to_map( "itemusage.txt", return_table ))
{
print ("File not loaded, A new file will be created.");
}
//multi_use builds a map of items obtained when using an item
boolean multi_use(int quant, item touse)
{
//return true if we asked to use 0 of the item (we did use 0)
if(quant == 0) {return true;}
//return false if we dont have enough
if(quant > item_amount(touse)) {return false;}
string source = visit_url("multiuse.php?action=useitem&pwd=&quantity=" + quant + "&whichitem=" + item_to_int(touse));
//if the response does not contain either "You gain" or "You acquire" then we assume failure, return false
if(!contains_text(source, "You gain") || !contains_text(source, "You acquire")) {return false;}
itemset got_these = extract_items( source );
foreach key in got_these
{
return_table[touse].items_acquired[key] = return_table[touse].items_acquired[key] + got_these[key];
}
return_table[touse].meat_gained = return_table[touse].meat_gained + extract_meat( source );
return_table[touse].total_used = return_table[touse].total_used + quant;
map_to_file(return_table, "itemusage.txt");
clear(got_these);
source = '';
return true;
}