Skip to content

Adding Other Types

Dickson Law edited this page Jul 4, 2020 · 1 revision

Adding Other Types

You can make a new struct type compatible with the Lightweight Data Structures ecosystem by implementing the following methods:

  • reduceToData(): Return a JSON-encodable representation of self in terms of only GML elementary types (i.e. untyped structs, arrays, real, string, boolean, undefined).
  • expandFromData(data): Clear self and restore the output of reduceToData() into self.
  • copy(source): Clear self and shallow-copy from the provided source.
  • copyDeep(source): Clear self and then deep-copy from the provided source. If there is no further nesting in your type, you can alias this to copy.
  • clone(source): Return a shallow clone of self.
  • cloneDeep(source): Return a deep clone of self. If there is no further nesting in your type, you can alias this to clone.

Then go to __LDS_CONFIGS__ and add a function entry to global.__lds_registry__ like this that returns a new starter struct of your type:

    MyNewType: function() {
        return new MyNewType();
    },

Clone this wiki locally