Module Util

Some general utility functions.

Functions

collectRectTiles (x, y, width, height[, noCorners=false]) Collects all tile positions along a rectangle.
unite (table1[, table2[, ...]]) Unites acces on multiple tables.
optStorage (Source, Name[, A]) Returns the named content of a storage table.


Functions

collectRectTiles (x, y, width, height[, noCorners=false])
Collects all tile positions along a rectangle. The listing is in clock-wise order and starts at the top left corner of the rectangle.

Parameters:

  • x number X component of a tile position.
  • y number Y component of a tile position.
  • width number Width of the rect.
  • height number Height of the rect.
  • noCorners bool If true the corners won't be included. (default false)

Returns:

    array An array of {x, y} positions.
unite (table1[, table2[, ...]])
Unites acces on multiple tables. For read access the value of the first table that contains the queried key will be returned. For write access the value is written into all tables using the provided key.

Parameters:

  • table1 table
  • table2 table (optional)
  • ... (optional)

Usage:

    local a = { x = 42 }
    local b = { y = 43 }
    local m = unite(a, b)
    print(m.x)  --Prints 42
    print(m.y)  --Prints 43
    m.z = 7
    print(m.z)  --Prints 7
    print(a.z)  --Prints 7
    print(b.z)  --Prints 7
    
    
optStorage (Source, Name[, A])
Returns the named content of a storage table. If no such entry exists it will be created by a given constructor, saved into the table and returned.

Parameters:

  • Source table table.
  • Name string of the entry to load.
  • A function or table function that returns a new object or the object itself. (optional)

Returns:

    anything The object that's effectively in src[name] after the call.
generated by LDoc 1.4.3 Last updated 2019-07-28 16:08:29