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 true if 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_mob if specified), nonhostile, player, mates (requires ignore_mob specifies)).
  • 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.
cmer.dropItems (pos, drops)
Drops items at position pos.

Parameters:

  • pos pos Where to drop items.
  • drops table List of item DropDef.
generated by LDoc 1.4.6 Last updated 2021-06-01 20:03:03