The sense global table contains information and utilities relevant to the environment of the executing Sense package.
The info field contains a sense type table containing information about the entrypoint Sense package.
The config field contains a function that provides access to runtime configuration values, with the ability to fall back to a default value.
config(name: string, fallback: any = nil): (value: any)
The dataPath field contains a function that will provide a filesystem path to a location that the Sense package may write any arbitrary data to. The root directory is ensured to exist before the path is returned, anything beyond that is under the jurisdiction of the Sense itself. Pay attention when working with subdirectories!
dataPath(name: string|nil = nil): (path: string)
\
instead of /
on Windows).The srcPath field contains a function that will provide a filesystem path to a location within the package directory of the entrypoint Sense package. If the name variable is specified, the target file MUST exist, otherwise an empty string is returned. The package directory is not meant to be written into, for storing data, please use dataPath() instead!
srcPath(name: string|nil = nil): (path: string)
\
instead of /
on Windows). The path MUST exist, otherwise the return value is discarded entirely.The vars field contains a table with functions providing access to non-volatile arbitrary variable storage. This is backed by an SQLite database, and is ideal for values that are on their own relatively immutable such as simple values or cache storage. For anything more involved, you should use a file at a path provided by dataPath(). Much like config values, the runtime will provide a certain form of isolation to prevent different Senses from reading each other's variables.
The get field contains a function that allows you to retrieve a variable from storage.
get(name: string): (value: any)
nil
as a fallback.The changed field contains a function that will return the timestamp of when the value was last changed as an amount of milliseconds since January 1st, 1970 at 12:00 AM UTC.
changed(name: string): (timestamp: number)
0
if no value is stored.The set field contains a function allowing you to store a value to a non-volatile variable. If a variable with the same name is already stored, it will be overwritten.
set(name: string, value: any): ()
nil
, this will behave the same as the delete function.This function does not return any values.
This field contains a function that will delete a function from non-volatile storage. If not variable with the given name exists, the call will be ignored.
delete(name: string): ()
This function does not return any values.