Module common.lua
Functions
| cmer.rnd (tab, errval) | Returns a weighted random table element. |
| cmer.compare_pos (pos1, pos2) | Compares two positions. |
| cmer.findTarget (search_obj, pos, radius, search_type, ignore_mob[, xray], no_count) | Returns table of found objects (as ObjectRef) and boolean player_near. |
| cmer.dropItems (pos, drops) | Drops items at position pos. |
Functions
- cmer.rnd (tab, errval)
-
Returns a weighted random table element.
chance_sum of table must be 1.
Example: cmer.rnd({elem1 = {chance = 0.7}, {elem2 = {chance = 0.3}})
Parameters:
- tab
- errval
Returns:
-
Weighted random table element.
- cmer.compare_pos (pos1, pos2)
-
Compares two positions.
Parameters:
- pos1 pos
- pos2 pos
Returns:
-
bool
trueif pos1 == pos2. - cmer.findTarget (search_obj, pos, radius, search_type, ignore_mob[, xray], no_count)
-
Returns table of found objects (as ObjectRef) and boolean player_near.
Parameters:
- search_obj
Searching object. Can be
nil. - pos pos Starting position for search radius.
- radius int Radius for searching in blocks/node.
- search_type
string
Specifies returned object requirements(One of all, hostile (ignores
ignore_mobif specified), nonhostile, player, mates (requiresignore_mobspecifies)). - ignore_mob
Specifies creature that is ignored or searched, depending on
search_type. - xray
bool
Allows searching through blocks/nodes (default:
false). (optional) - no_count Skips collecting loop and returns just the boolean player_near.
Returns:
-
Table of found objects (as
ObjectRef) and boolean player_near. - search_obj
Searching object. Can be
- cmer.dropItems (pos, drops)
-
Drops items at position
pos.Parameters:
- pos pos Where to drop items.
- drops
table
List of item
DropDef.