Repository navigation
API Documentation
Meisaka Yukara edited this page Mar 15, 2021
·
6 revisions
By default the file scripts/config.lua will be loaded and that script file will be available from the game instance. The following configuration is available to be defined in the configuration:
-
window_width:number- The initial width of the game window -
window_height:number- The initial height of the game window
More configuration can be added as needed, and should be documented here
-
print(message:string, ...)- Prints a message to the default logger, currently the in game console as well as the OS console
-
update(delta:number)- Called every game loop with the amount of time passed (delta) since the last call -
onChatCommand(command:string, args:vector)- Called to handle ChatCommandEvent -
onClientConnected(event:client_connection_info)- Called when a client connects to the server, but before we send anything-
client_connection_info.cancel:bool- Defaults to false, when true, the client will be disconnected -
client_connection_info.reason:string- Sent to the client ifcancelwas true -
client_connection_info.port:number- The TCP or UDP port number the client is connecting from (not typically useful) -
client_connection_info.address:string- The IPv4 or IPv6 address of the client -
client_connection_info.family:string- The client address type, eitheripv4oripv6 -
client_connection_info.protocol:string- The transport the client is connected with, eithertcporudp
-
function onClientConnected(info)
info.cancel = (info.address ~= "192.168.7.7") -- only allow this super special address
info.reason = "Sorry! This server doesn't like you"
print("Client connected:", info.protocol, info.family, info.address .. ":" .. info.port)
end-
onClientDisconnected(event:client_connection_info)- Called when a client is disconnected from the server- provides the same
client_connection_infoas connect, however, the cancel and reason fields have no effect.
- provides the same
The following functions are used to get information about or interact with the host OS and are namespaced under the OS name.
-
OS:quit()orOS:exit()- Stops the game -
OS:get_window_width() -> int- Get the width of the game window -
OS:get_window_height() -> int- Get the height of the game window -
OS:get_mouse_x() -> double- Get the X position of the mouse -
OS:get_mouse_y() -> double- Get the Y position of the mouse