Skip to content
Stjepan Bakrac edited this page May 22, 2020 · 2 revisions

This library facilitates sharing data between packages. Usually this refers to services and their respective libraries but can be just as well be used to communicate between different addons. The shared.client module is used to read the data.

local server = require('shared.server')

Dependency Required

To use this library, you must include shared in the manifest.xml file for your package:

<dependency>shared</dependency>

Tables

The server table has the following entries:



server.new

Creates a new structure based on the provided ftype. It is created in fixed memory and can be accessed by other instances.

Definition

function server.new(name : string = 'data', ftype : ftype) : struct

Parameters

name string

The name of the associated shared object. Can be (and is usually) omitted if the sharing package only uses one shared object.

ftype ftype

The type description of the structure, defined via the struct library.

Return

struct struct

The struct created based on the provided ftype.



server.new_ptr

Creates a new structure based on the provided ftype. It is created in fixed memory and can be accessed by other instances. Returns a pointer to the struct for potential manual sharing. This is a very rarely used function and is not required when using server.new.

Definition

function server.new_ptr(ftype : ftype) : cdata<ptr>

Parameters

ftype ftype

The type description of the structure, defined via the struct library.

Return

ptr cdata

A pointer to the struct created based on the provided ftype.

Clone this wiki locally