Skip to content
hatninja edited this page Aug 6, 2022 · 2 revisions

AOCS is designed to provide access to all the major functionality in the program via the global environment. As a note, all major files in the server/ folder are loaded at once before operation.

Global Tables

process

A name hold-over from AOLS2. Process is responsible for the core logic of the program.

protocol

An intermediary class that reads and sends in the protocol of each client. It currently handles the AO2 protocol with support for websockets. Support for other protocols is planned.

server

The object responsible for managing connections and the sending and receiving of packets.

data

Internal module for the reading and writing of server data.

log

Internal module for the printing and recording of messages on the console.

socket, mime

Modules from luasocket used for the program.

bit, sha1

The libraries which were included for handling binary data present in the websocket protocol. BitOp Documentation


Global Functions

Helper functions used in the server code.

findindex(t, v)

Finds a value that matches v in table t, and returns the index where it was found.

findkey(t, v)

Same as findindex, but works for all values in a table, returning the key where a match is found.

clone(t)

Returns a new table that is a copy of table t. This new table can be changed freely without affecting the original.

firstempty(t)

Returns the first empty index of table t.

toprint(v)

Returns a readable form of v. Useful for debugging tables.

bool(v)

Evaluates the "truth" state of v. Tables and strings of no length return false. The number 0 returns false. Strings "0" and "false" return false. Otherwise, value itself is returned.

safe(func, ...)

Call a function func with optional arguments in protected mode. On success, the function returns as it would normally. On error, it returns nil with the error string.

each(func, ...)

Calls the function func for every argument passed into each(). Returns all the results of func in order.

split(input, delimit)

Splits the string input into parts between where the string pattern delimit is found.

tointeger(x)

Mirrors lua's tonumber() function, but removes any fractional part using math.floor().


Clone this wiki locally