Язык программирования для roblox

Luau

Luau is the scripting language creators use in Roblox Studio. It is a fast, small, safe, gradually typed embeddable scripting language derived from Lua 5.1 . Use Luau in scripts to make your experience dynamic and interactive. For a comparison of language features in Luau and C#, see Luau and C# Comparison .

Support in Studio

The Script Editor in Studio supports Luau with autocompletion, syntax highlighting, static linting, type checking, and script analysis. It also shows documentation and function signatures for members of the Roblox Engine API .

Types

Luau includes the following data types:

Luau is dynamically typed by default. Variables, function parameters, and return values can be any data type. This helps you write code faster because you don’t need to provide types for each piece of data. You can still declare explicit types for variables in Luau and enable strict type checking to make type issues obvious and easy to locate.

Data Structures

You can also implement the following data structures using primitive data types:

Metatables are tables with advanced configurations that can achieve functionalities such as storing pairs of keys and values and calculating arithmetic operations.

Features

In Luau, variables and functions can have global and local scope within a script. Luau has logical, relational, and compound assignment operators . You can use control structures and functions to control when Luau executes code. Many operators and variable assignments perform type coercion to change values to the types that Luau expects.

Читайте также:  Фаак 740 программирование пульта

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

A fast, small, safe, gradually typed embeddable scripting language derived from Lua

License

Licenses found

Roblox/luau

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

* Added support for async typechecking cancellation using a token passed through frontend options * Added luaC_enumheap for building debug tools that need a graph of Luau heap In our new typechecker: * Errors or now suppressed when checking property lookup of error-suppressing unions In our native code generation (jit): * Fixed unhandled value type in NOT_ANY lowering * Fast-call tag checks will exit to VM on failure, instead of relying on a native fallback * Added vector type to the type information * Eliminated redundant direct jumps across dead blocks * Debugger APIs are now disabled for call frames executing natively * Implemented support for unwind registration on macOS 14

Git stats

Files

Failed to load latest commit information.

README.md

Luau (lowercase u, /ˈlu.aʊ/) is a fast, small, safe, gradually typed embeddable scripting language derived from Lua.

It is designed to be backwards compatible with Lua 5.1, as well as incorporating some features from future Lua releases, but also expands the feature set (most notably with type annotations). Luau is largely implemented from scratch, with the language runtime being a very heavily modified version of Lua 5.1 runtime, with completely rewritten interpreter and other performance innovations. The runtime mostly preserves Lua 5.1 API, so existing bindings should be more or less compatible with a few caveats.

Luau is used by Roblox game developers to write game code, as well as by Roblox engineers to implement large parts of the user-facing application code as well as portions of the editor (Roblox Studio) as plugins. Roblox chose to open-source Luau to foster collaboration within the Roblox community as well as to allow other companies and communities to benefit from the ongoing language and runtime innovation.

This repository hosts source code for the language implementation and associated tooling, documentation for the language as well as RFCs and other materials. The documentation portion of this repository can be viewed at https://luau-lang.org/

Luau is an embeddable language, but it also comes with two command-line tools by default, luau and luau-analyze .

luau is a command-line REPL and can also run input files. Note that REPL runs in a sandboxed environment and as such doesn’t have access to the underlying file system except for ability to require modules.

luau-analyze is a command-line type checker and linter; given a set of input files, it produces errors/warnings according to the file configuration, which can be customized by using —! comments in the files or .luaurc files. For details please refer to type checking and linting documentation.

You can install and run Luau by downloading the compiled binaries from a recent release; note that luau and luau-analyze binaries from the archives will need to be added to PATH or copied to a directory like /usr/local/bin on Linux/macOS.

Alternatively, you can use one of the packaged distributions (note that these are not maintained by Luau development team):

  • macOS: Install Homebrew and run brew install luau
  • Arch Linux: From the AUR (Arch Linux User Repository), install one of these packages via a AUR helper or manually (by cloning their repo and using makepkg ): luau (manual build), luau-git (manual build by cloning this repo), or luau-bin (pre-built binaries from releases)
  • Alpine Linux: Enable community repositories and run apk add luau

After installing, you will want to validate the installation was successful by running the test case here.

On all platforms, you can use CMake to run the following commands to build Luau binaries from source:

mkdir cmake && cd cmake cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo cmake --build . --target Luau.Repl.CLI --config RelWithDebInfo cmake --build . --target Luau.Analyze.CLI --config RelWithDebInfo

Alternatively, on Linux/macOS you can use make :

make config=release luau luau-analyze

To integrate Luau into your CMake application projects as a library, at the minimum you’ll need to depend on Luau.Compiler and Luau.VM projects. From there you need to create a new Luau state (using Lua 5.x API such as lua_newstate ), compile source to bytecode and load it into the VM like this:

// needs lua.h and luacode.h size_t bytecodeSize = 0; char* bytecode = luau_compile(source, strlen(source), NULL, &bytecodeSize); int result = luau_load(L, chunkname, bytecode, bytecodeSize, 0); free(bytecode); if (result == 0) return 1; /* return chunk main function */

For more details about the use of host API you currently need to consult Lua 5.x API. Luau closely tracks that API but has a few deviations, such as the need to compile source separately (which is important to be able to deploy VM without a compiler), or lack of __gc support (use lua_newuserdatadtor instead).

To gain advantage of many performance improvements it’s highly recommended to use safeenv feature, which sandboxes individual scripts’ global tables from each other as well as protects builtin libraries from monkey-patching. For this to work you need to call luaL_sandbox for the global state and luaL_sandboxthread for each new script’s execution thread.

Luau has an internal test suite; in CMake builds it is split into two targets, Luau.UnitTest (for bytecode compiler and type checker/linter tests) and Luau.Conformance (for VM tests). The unit tests are written in C++, whereas the conformance tests are largely written in Luau (see tests/conformance ).

Makefile builds combine both into a single target and can be ran via make test .

Luau uses C++ as its implementation language. The runtime requires C++11, whereas the compiler and analysis components require C++17. It should build without issues using Microsoft Visual Studio 2017 or later, or gcc-7 or clang-7 or later.

Other than the STL/CRT, Luau library components don’t have external dependencies. The test suite depends on doctest testing framework, and the REPL command-line depends on isocline.

Luau implementation is distributed under the terms of MIT License. It is based on Lua 5.x implementation that is MIT licensed as well.

When Luau is integrated into external projects, we ask to honor the license agreement and include Luau attribution into the user-facing product documentation. The attribution using Luau logo is also encouraged.

About

A fast, small, safe, gradually typed embeddable scripting language derived from Lua

Источник

Оцените статью