- Documentation
- Client functions
- markAsArray
Function
markAsArray
Marks a table as a list: an empty table reaches the browser page (triggerBrowserEvent, toJSON) as [] instead of {}. Returns the same table.
Syntax
table markAsArray(table t)Arguments
ttable- The table.
Returns
The same table; false if the table already has a different metatable.
Example
local items = markAsArray({}) -- strona dostanie pusta liste []
triggerBrowserEvent(browser, "onItems", items)
See also
toJSONTurns a Lua value (a number, a string, a table, an element) into JSON text, e.g. to store in a file, a database or account data. The format is the same: the result is always a JSON array, and elements are written so thatfromJSONcan read them back. A table that appears a second time (including a table that contains itself) is written as a"^T^n"reference, andfromJSONrestores it as the same table.triggerBrowserEventSends an event from Lua to a local page. In JavaScript you receive it withtrilogy.on("name", fn), without building code in a string.