- Documentation
- Utilities
Category
Utilities
All Lua functions and events in the Utilities category, on the server and the client.
Server functions 17
clearSends every player theDebug Box onClientDebugClearevent (a client script can clear its debug window in it).debugFreezes the whole server for the given time (0-5000 ms). Only for testing behaviour under lag - the server does nothing during that time.Sleep getReturns the list of loaded native modules (DLLs). The Trilogy Hub server does not load modules, so the list is always empty.Loaded Modules getReturns information about a native module. The Trilogy Hub server does not load modules.Module Info getReturns how much data the server has received and sent over the network since it started.Network Usage Data getReturns basic server statistics as columns and rows (uptime, players, vehicles, objects, timers, resources, number of API functions). The category, options and filter arguments are accepted, but the data set is always the same.Performance Stats getReturns the memory used by the server's Lua scripts.Process Memory Stats isReturns the value fromChat Input Blocked setChatInputBlocked.isReturns the value fromShow Collisions Enabled showCol.isReturns the value fromShow Sound Enabled showSound.isReturns whether the download box also appears for small files.Transfer Box Always Visible pregChecks whether a text matches a regular expression (JavaScript syntax). Flags as text (Find "i"- case-insensitive,"m"- multiline,"s"- dot matches newline,"u"- Unicode) or a number.pregReturns all regular expression matches in a text. When the pattern has groups in brackets, each match is a table: the whole match followed by the groups.Match pregReplaces all fragments matching a regular expression. In the replacement,Replace $1,$2insert the groups.setStores a chat input block.Chat Input Blocked showStores turning on the collision preview for players (a tool for map makers).Col showStores turning on the sound source preview for players.Sound
Shared functions 13
formatConverts a number of seconds into a readable form:Duration "45s","3m 05s","1h 02m 05s". Fractions are truncated, negatives give"0s".formatWrites an integer with a separator every three digits (space by default): 1500000 →Number "1 500 000". Fractions are truncated.fromcolorSplits a colour stored as one number (e.g. fromtocolor) into r, g, b, a components - the inverse oftocolor.getReturns whether development mode is on (Development Mode setDevelopmentMode).getReturnsTick Count Seconds getTickCount()in seconds, with a fraction - more convenient for speed and animation calculations.isReturns whether the download progress box is enabled.Transfer Box Visible setTurns development mode on. On the client the second argument unlocks developer tools for pages in script browsers. On the server it stores a flag read withDevelopment Mode getDevelopmentMode(e.g. to enable test commands).setShows or hides the resource download progress box (a bar at the top of the screen). On the server the setting applies to all players, on the client - only to that player.Transfer Box Visible utfReturns the character with the given Unicode code, e.g.Char utfChar(261)→"ą".utfReturns the Unicode code of the text's first character, e.g.Code utfCode("ą")→ 261.utfReturns the length of a text in characters (not bytes). Important for non-ASCII letters:Len #"żółw"is 7 bytes, whileutfLen("żółw")is 4.utfReturns the byte position in a text moved by the given number of characters from a start position - useful when mixing UTF functions withSeek string.find.utfCuts a part of a text by character positions (from 1, both ends inclusive). Negative positions count from the end. Does not break non-ASCII letters, unlikeSub string.sub.