Basic Types
Lua Types
nanos world runs Lua 5.4. For more information and tutorials, please refer to the Official Lua 5.4 Reference Manual.
number
Numbers can be integers (64-bit, like 10 or -3) or floats (double-precision, like 3.14). Lua converts between them automatically when needed, e.g. 10 / 2 results in the float 5.0 while 10 // 2 (floor division) results in the integer 5. In this documentation we use integer and float to tell which one a function expects or returns.
string
A sequence of characters (bytes), such as "hello" or 'world'. Strings can hold any binary data and are immutable: functions like string.upper return a new string instead of changing the original one. Use .. to join strings, e.g. "Hello " .. player:GetName().
function
Functions are values like any other: they can be stored in variables and tables, passed as parameters and returned by other functions. That's how callbacks work in nanos world, e.g. Player.Subscribe("Spawn", function(player) ... end).
boolean
Either true or false. In conditions, only false and nil are considered false, everything else (including 0 and the empty string "") is considered true.
nil
Represents the absence of a value. Variables which were never assigned are nil, and many functions return nil when they don't find what you asked for (e.g. Prop.GetByIndex(9999)), so always check for it before using the result.
table
The only data structure in Lua, which works both as an array ({ "a", "b", "c" }, indexed from 1) and as a dictionary ({ name = "John", age = 30 }). Tables grow dynamically and can hold any value, except nil. They are passed by reference: changing a table inside a function changes the original one.
iterator
Iterator allows you to traverse elements of a table with for k, v in ipairs().
any
We use any here in the Docs to represent that any Type can be used.
varargs
Variadic list of values.
Numeric Types
Besides the Lua Types, some methods on the API have specific numeric types, those are converted and treated differently internally.
integer
Whole numbers without any fractional parts.
float
Floating-point type with decimal points.
Special Types
SpecialPath
nanos world supports a special type of Path when loading Textures (.jpg, .png), Sounds (.ogg) or referencing files from WebUI. It allows any Package or WebUI to access files from other Packages or Asset Packs easily.
SpecialPath is a string input which supports the following formats for accessing Assets or Packages files:
Referencing Asset Packs files
assets://[ASSET_PACK_PATH]/[PATH/TO/FILE.jpg]
Referencing Packages files
package://[PACKAGE_PATH]/[PATH/TO/FILE.jpg]
Example accessing images from quaternius Asset Pack:
assets://quaternius/Thumbnails/SK_Revolver_01.jpg
Example accessing a .ogg sound from sandbox Package:
package://sandbox/Client/my_awesome_audio.ogg
Example accessing a .ttf font files from my-fonts Package:
package://my-fonts/Client/Roboto.ttf
SpecialPath input also supports relative and traditional paths!
Steam Avatar
Steam Avatar is a special URL which can load Steam Avatars as images on WebUIs and Widgets.
steam-avatar://player_steam_id
This URL can be automatically retrieved with Player:GetAccountIconURL().