Module PlanetsLib.objects

PlanetsLib.objects Aliases: PlanetsLib.rro Designed to simplify table manipulation, with preventing crashes when applying functions en masse the first priority.

This library abstracts away object references, asserting that two tables with identical contents are equal to each other. This library has been bundled with PlanetsLib to make it easier to port features from MeteorSwarm's mods to PlanetsLib.

Info:

  • Author: MeteorSwarm

Functions

Public.deep_equals (table1, table2) Checks if two objects are identical.
Public.remove (list, objectToRemove) Removes object from list.
Public.replace (list, objectToRemove, replacementObject) Replaces object in list with another object
Public.replace_field (list, field, name, new_name) Searches a list for all items where item[field] == name, and replaces name with new_name.
Public.replace_name (list, name, new_name) Searches a list for all items where item.name == name, and replaces name with new_name.
Public.contains (list, object) Check if object exists in list.
Public.soft_insert (list, objectToAdd) Adds object to list if it doesn't already exist.
Public.merge (old, new) Adds fields of new to old, replacing overlapping fields.
Public.get_concatenation (first, second) Returns a concatenation of the contents of two tables.


Functions

Public.deep_equals (table1, table2)
Checks if two objects are identical. ie returns true if {"space-science-pack",1} and {"space-science-pack",1} are compared from different object references. Special string "_any" always returns true if compared with anything else.

Parameters:

  • table1
  • table2
Public.remove (list, objectToRemove)
Removes object from list. Special string "_any" always returns true if compared with anything else.

Parameters:

  • list
  • objectToRemove
Public.replace (list, objectToRemove, replacementObject)
Replaces object in list with another object

Parameters:

  • list
  • objectToRemove
  • replacementObject
Public.replace_field (list, field, name, new_name)
Searches a list for all items where item[field] == name, and replaces name with new_name.

Parameters:

  • list
  • field
  • name
  • new_name
Public.replace_name (list, name, new_name)
Searches a list for all items where item.name == name, and replaces name with new_name.

Parameters:

  • list
  • name
  • new_name
Public.contains (list, object)
Check if object exists in list.

Parameters:

  • list
  • object local contains = false
Public.soft_insert (list, objectToAdd)
Adds object to list if it doesn't already exist.

Parameters:

  • list table
  • objectToAdd object
Public.merge (old, new)
Adds fields of new to old, replacing overlapping fields. Special argument "_nil"(or "nil"), when added to "new", deletes the equivalent field in "old" without replacing it with anything.

Parameters:

  • old table
  • new table

Returns:

    old table
Public.get_concatenation (first, second)
Returns a concatenation of the contents of two tables.

Parameters:

  • first table
  • second table
generated by LDoc 1.5.0