Difference between revisions of "Item drops array"
Jump to navigation
Jump to search
imported>Heeheehee (New function, new page!) |
imported>Heeheehee m |
||
Line 9: | Line 9: | ||
function1={{Function| | function1={{Function| | ||
+ | name={{#var:name}}| | ||
+ | aggregate={{#var:aggregate}}| | ||
+ | return_type={{#var:return_type}}| | ||
+ | return_also={{#var:return_also}} | ||
+ | }}| | ||
+ | function2={{Function| | ||
name={{#var:name}}| | name={{#var:name}}| | ||
aggregate={{#var:aggregate}}| | aggregate={{#var:aggregate}}| |
Revision as of 07:21, 5 April 2010
Function Syntax
int [item] item_drops_array()
int [item] item_drops_array(monster m )
Returns an array of records with three fields:
record {
item drop;
int rate;
string type;
}
Since this is the first function to return a record, it cannot be stored to a variable, and thus the only way to access the data is by iterating over the elements in the record.
Code Samples
Prints all information Mafia has regarding the item drops of a certain monster.
void drops(monster mob){
print("Monster: " + mob);
foreach index, rec in item_drops_array(mob)
print("item: "+rec.drop+", drop rate: "+rec.rate+", type: "+rec.type);
}
See Also
Special
The zero-parameter form returns the last monster encountered (the current one, if used in combat).